Author dominic108
Recipients dominic108
Date 2020-01-01.07:21:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577863304.66.0.670645943584.issue39177@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-01-01 07:21:44dominic108setrecipients: + dominic108
2020-01-01 07:21:44dominic108setmessageid: <1577863304.66.0.670645943584.issue39177@roundup.psfhosted.org>
2020-01-01 07:21:44dominic108linkissue39177 messages
2020-01-01 07:21:44dominic108create