tksheet icon indicating copy to clipboard operation
tksheet copied to clipboard

Get bbox coordinates of selected cell

Open Pocket1601 opened this issue 2 years ago • 1 comments

Hello, @ragardner! Really wanted to say thank you for create this cool thing like "TKSHEET"! I started to find one of the most usefull table view widget and yours was the best choice for me!

But I can't figure it out how I could get specific coordinates by using "bbox". Could you help me to solve this issue? I just need to know how I can get selected cell and insert this data to bbox -> after get tuple of coordinates (x1, y1, x2, y2).

Because for this moment, I can use bbox only with sheet widget. Like sheet.bbox(). And of course I need to insert between brackets some kind of information, so this function could give me information, like on which cell I clicked and bring me coordinates of this cell.

I tried to do it like this:

def check(event):
    r = sheet.identify_row(event, exclude_index = False, allow_end = True)
    c = sheet.identify_column(event, exclude_header = True, allow_end = True)
    box = sheet.bbox(r, c)
    print(box)

sheet.bind("<ButtonPress-1>", check)

But values from print(box) are so strange.

documentation said: "The returned integers specify the offset of the upper left corner in the master widget and the width and height."

Because, if I clicked on cell (row: 0, column: 0) -> I'm getting (0, 0, 0, 21), but then I clicked on cell (row: 0, column: 1) -> I'm getting (0, 0, 1252, 21). Question is: why first and a second values are not changing, and why third value (1252) is so big, I don't even have cell with this width. I think I do something wrong maybe.

So, thanks in advance!

Pocket1601 avatar Dec 16 '22 08:12 Pocket1601

Sorry for the late reply, bbox is not a tksheet function it's a tkinter function and by using it on a Sheet() object you're asking what is the bbox of the frame (because the Sheet() object is really just a frame

I am not sure what data you're trying to insert? Do you mean change the text of a cell?

ragardner avatar Mar 15 '23 08:03 ragardner