September 7th, 2005, 12:27 AM
So, in a python program I wrote, the whole interface is in a window only 200x230 pixels. Thus, when I open a tkMessageBox on errors, the dialog opened is dead center on the screen, which is not necessarily where the original progam window is. Is there a way to move the dialog opened so that it's always centered over the program window? I'd just open the program window in the dead center of the screen, too, but the user can move that window around before creating an error.
September 7th, 2005, 12:49 AM
I just wrote a little snippet, and my tkMessageBox is always centered over the root-window, even if I move it around. You could try the parent-option like tkMessageBox.showerror("Error","Error",parent=root_window), but I don't know if that has the effect you want.
September 7th, 2005, 09:57 AM
Nope, that didn't seem to do anything at all, unfortunately. What system are you using?
September 7th, 2005, 10:05 AM
Linux (Ubuntu Hoary).
One thing you could do is to write your own dialog box, get the coordinates of the mainwindow with
and place your dialog with
x,y = mainwindow.winfo_rootx(), mainwindow.winfo_rooty()
my_dialog.geometry("+%d+%d" % (x,y))
September 7th, 2005, 10:26 AM
I might try that. I hadn't actually be saving the dialog and configuring it, just using the helper functions. Might just ignore it, too. Windows XP SP2 seems to insist on having the message boxes appear on the dead center of the screen regardless of the box's parent.