1

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.

Duffydake
  • 917
  • 7
  • 18
  • Is this pygtk or python-gobject (`from gi import`)? – andlabs Apr 08 '16 at 01:23
  • @andlabs it's I guess python-gobject `from gi.repository import Gtk` and Gtk 2.0 not Gtk3 – Duffydake Apr 08 '16 at 01:27
  • I don't understand the problem. Using `get_origin()` should work. Are you calling it after the window was mapped? – elya5 Apr 08 '16 at 15:34
  • @elya5 if I can do `x,y = window.get_origin()` I guess, but it's not the case and it return always 1. All other functions that I tried work as expected, so I need something else which do the same thing. I call it when I click on my button so yes the window is mapped. – Duffydake Apr 08 '16 at 15:59

1 Answers1

0

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.

Duffydake
  • 917
  • 7
  • 18