Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dialog opening when I press a button in my application and I want it to center above the application's main window, but I can't find a way to do this. I'm using Quickly (Python) and Glade.

In Glade I've tried the following settings:

  • Window Type = Popup
  • Modal = Yes
  • Window Position = Center on Parent

But I simply can't get the behaviour I'm after. When using the "Window Type" option "Top level" the dialog opens in the center of the screen. When I use "Window Type" = "Popup" it opens in the very top left corner, with the window controls unaccessible.

I know this must be a very basic setting but I've just started developing with GTK and Python so I obviously managed to miss this.

Thanks for any advice! :)

share|improve this question
up vote 4 down vote accepted

When choosing the Center on Parent position, you must also let the dialog know which window is the parent ofcourse. This can either be done in Glade, but only if the parent window is inside the same Glade-file. Or by calling this method:

share|improve this answer
How do I reference the main window ( - MyappWindow()) from my dialog I'm new to Python so excuse my inexperience. I tried "from myapp import MyappWindow" and then "self.set_transient_for(MyappWindow)". I have created everything with Quickly so it is the default set up after running "quickly add dialog goto". – Niklas Sep 13 '12 at 14:52
Somewhere in your code, you'll call the dialog with something like dialog = GotoDialog(), just pass the main window instance along with it: dialog = GotoDialog(self). – Timo Sep 13 '12 at 22:22
I tried doing it in every possible way I could think of but what fixed it was setting it from the window that opened the dialog, like this: goto = GotoDialog() and goto.set_transient_for(self) – Niklas Sep 14 '12 at 10:21
Ah yes, that's possible too. I just like to set it in the dialog itself, so you can call the dialog from any other window, and it will always center on the calling parent. – Timo Sep 14 '12 at 10:49
That's how I'd like to do it but I couldn't get it to work. If you have the time can you post a code snippet showing the set up within the dialog and it's constructor? – Niklas Sep 15 '12 at 12:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.