Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Popover location coordinates for button in table row
-
Hi all-
I’m trying to present a popover triggered by a button in a TableViewCell.
My underlying table is a TreeNode (from File Picker) and so I can’t use row_height * row index calculation.
Converting button.center to screen_coordinates is where I’m getting stuck (I think this is how to accomplish the task)Any thoughts?
-
def b_action(sender): vi = ObjCInstance(b).view() r = vi.convertRect_toView_(vi.bounds(),None) # x,y in screen coordinates, not in view x,y,w,h = r.origin.x,r.origin.y,r.size.width,r.size.height po = ui.View() po.frame = (0,0,200,200) po.present('popover',popover_location=(x+w/2,y+h))
-
Thank you again for saving my project (and sanity)
I had read that thread before, but didn’t make the connection.Here’s what worked for me:
I ended up usingvi = ObjCInstance(b)
Since my object ‘b’ is ui.Button
Also, the popover location was off by the title bar height. Used GetTitleBarHeight() from here. Adjusted popover padding with help from here.
I appreciate how helpful this community is. I’m learning a lot.
-
@crazyfox, for future reference, note the convenient
ui
module functionsconvert_point
andconvert_rect
.