pythongtkmate

How to get window origin (position) in mate applet?


I try to get window origin in a mate panel applet.
To be more precise I want to know the position of my applet (x and y) on the screen because I have a button which show/hide a Gtk.window but I need to move that window next to my button (above, below, right, left depending on where the mate panel is)

enter image description here

The only way that I found is to call get_origin but there is a problem. It should return a tuple x,y but instead like the c function it require two integers and since python use pass by value of course it doesn't work.

This code is valid but useless:

window = self.get_window()
x = 0
y = 0
window.get_origin(x, y)

All other "way to use" get_origin (that you can found in any doc) does not work because it require 3 args (I don't know why)

So I'm looking for a way to get the position of my applet (even if it's not accurate) or to move my window next to my button.


Solution

  • I found an alternative get_root_coords

    window = self.get_window()
    x,y = window.get_root_coords(0, 0)
    

    It works even with multiple screens and I'm able to move my Gtk.Window next to my button with it.