[Tkinter-discuss] Control position of Tkinter common dialogs?

Firat Ozgul ozgulfirat at gmail.com
Tue Oct 26 12:05:34 CEST 2010


Hello,

I do not know whether there is an easier way to accomplish what you want,
but maybe you can create a new toplevel window in the middle of the screen,
then make it invisible and position the dialog windows relative to this new
toplevel... Like this: http://paste-it.net/public/q2a5594/

I know, this is not nice. Maybe someone else will offer a more "palatable"
alternative.

Firat

2010/10/25 <python at bdurham.com>

> Python 2.7 under Windows: How can we control the position of
> Tkinter's common dialogs?
>
> Here's what we've discovered:
>
>  * Certain common dialogs always open up relative to their
>    parent window
>
>  * Certain common dialogs always open up centered on the user's
>    desktop
>
>  * All common dialogs appear to ignore the optional parent=
>    parameter
>
> Questions:
>
>  * How can we force a dialog to open up relative to its parent
>    window?
>
>  * How can we force a dialog to open up centered on the user's
>    desktop?
>
> Background:
>
> import tkColorChooser as colorchooser
> import tkFileDialog as filedialog
> import tkMessageBox as messagebox
>
> # always open up relative to parent windows
> fileOpen   = filedialog.askopenfilename()
> fileOpens  = filedialog.askopenfilenames()
> fileSaveAs = filedialog.asksaveasfilename()
> color      = colorchooser.askcolor()
>
> # always open up centered on desktop
> folderOpen = filedialog.askdirectory()
> messagebox.askquestion()
>
> Malcolm
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20101026/332c6ce8/attachment.html>


More information about the Tkinter-discuss mailing list