Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get bbox coordinates of selected cell #141

Open
Pocket1601 opened this issue Dec 16, 2022 · 1 comment
Open

Get bbox coordinates of selected cell #141

Pocket1601 opened this issue Dec 16, 2022 · 1 comment

Comments

@Pocket1601
Copy link

Pocket1601 commented Dec 16, 2022

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!

@ragardner
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants