Reputation: 93
I have a button labeled import (down arrow) and I am trying to determine it's location so I can create a popup menu to say 1. from device 2. from folder.
I can't seem to find anymore than allocation in the api docs, which is relative to the application window. Please help, I will send imaginary cookies ^_^.
using PyGI if it matters.
Upvotes: 1
Views: 1203
Reputation: 93
I figured out the answer before but couldn't self answer yet.
The process is as follows:
determine the location of the widget relative to it's GdkWindow : widget_x, widget_y
x = gdk_window_x + widget_x
y = gdk_window_y + widget_y
as everything in the graphics world measures from top left (unless your weird :-)), you now have the location of the top left pixel of your widget.
Upvotes: 1
Reputation: 3855
You can get the position of the window relative to the screen using window.get_position()
. Since you already know how to get the position of the button relative to the window, it should be a matter of adding up both to get the coordinates (relative to the screen) in which to place the popup.
Upvotes: 0