New submission from Dominic Mayers <dominic_may...@yahoo.com>:

Currently, it's not possible to center or change the coordinates in anyway of 
an askstring, askfloat or askinteger dialog in simpledialog.py. One can see 
this by looking at the code:

        if parent.winfo_viewable():
            self.transient(parent)

        if title:
            self.title(title)

        self.parent = parent

        self.result = None

        body = Frame(self)
        self.initial_focus = self.body(body)
        body.pack(padx=5, pady=5)

        self.buttonbox()

        if not self.initial_focus:
            self.initial_focus = self

        self.protocol("WM_DELETE_WINDOW", self.cancel)

        if self.parent is not None:
            self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
                                      parent.winfo_rooty()+50))

Here self.parent is never None, because the first statement would create a run 
time error if parent was None. So, the geometry always depends on the parent. 
Moreover, if the parent is not viewable, `parent.winfo_rootx()` and 
`parent.winfo_rooty()` are both 0. So, we can only set the coordinates of a 
simple dialog using a viewable parent. This contradicts a bit "simple" in 
"simpledialog". For example, what about an application that does not have a 
root window, like git for example, but, which unlike git, needs to create 
simple dialogs in some occasions. 

I am aware that a messagebox does not use the code that is presented above, but 
a messagebox is not a simple dialog - it's only a message. 

I am also aware of the class SimpleDialog, which also does not use this code, 
but it only works with buttons. It's not like askstring, askinteger and 
askfloat.

----------
messages: 359147
nosy: dominic108
priority: normal
severity: normal
status: open
title: In tkinter, simple dialogs, askstrings, etc. with flexible coordinates 
and no viewable parent.
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39177>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to