Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-42685: Improve placing of simple query windows.#23856

Merged
serhiy-storchaka merged 4 commits into
python:masterpython/cpython:masterfrom
serhiy-storchaka:tkinter-query-dialog-placeserhiy-storchaka/cpython:tkinter-query-dialog-placeCopy head branch name to clipboard
Dec 24, 2020
Merged

bpo-42685: Improve placing of simple query windows.#23856
serhiy-storchaka merged 4 commits into
python:masterpython/cpython:masterfrom
serhiy-storchaka:tkinter-query-dialog-placeserhiy-storchaka/cpython:tkinter-query-dialog-placeCopy head branch name to clipboard

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Dec 19, 2020

Copy link
Copy Markdown
Member
  • If parent is specified and mapped, the query widget is
    centered at the center of parent. Its position and size
    can be corrected so that it fits in the virtual root window.
  • Otherwise it is centered at the center of the screen.

https://bugs.python.org/issue42685

* If parent is specified and mapped, the query widget is
  centered at the center of parent. Its position and size
  can be corrected so that it fits in the virtual root window.
* Otherwise it is centered at the center of the screen.
@terryjreedy

terryjreedy commented Dec 24, 2020

Copy link
Copy Markdown
Member

When checking code, IDLE changed focus to Shell in case there are warning messages. (I want to change this, but...) If there is a syntax error, current code calls messagebox.showerror and tries to put focus on the editor. The latter raised the editor over Shell but focus remains on the modal messagebox until it is dismissed. Error box is centered. After I put the focus line first, nothing changes. Should it? Is not a visible focused parent 'mapped'? idlelib.runscript 206/7.

        self.editwin.text.focus_set()
        tkMessageBox.showerror(title, message, parent=self.editwin.text)

Edit: After reading the patch and tkinter.messagebox, the error box should not be changed as it is a commondialog rather than simple dialog. Do you plan to change the commondialogs also? To me, they need it more.

The only easily trigger simpledialog in IDLE is askinteger('Tab width') for Format => Tabify and Untabify. If I select either of those with a mouse and want to click [OK] to accept the default of 4, I actually prefer the box where it is, up near the menu. Either way, entering a value out of the range puts an error messagebox in the center of the screen.

Edit2: IDLE's query.Query boxes put error messages in red in the entry box. I think that this would be an improvement for askinteger.

@terryjreedy

Copy link
Copy Markdown
Member

I have read the code but not checked it in detail. It does center 'Tab width' and I consider this a better default position even if not the best for this particular box. The 5 types of query.Query boxes are centered and I am satisfied with that and have never considered moving any of them.

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Dialogs in commondialog are implemented in Tk and may use native OS dialogs. They are out of control Tkinter and may be out of control of Tk. Dialogs in simpledialog are implemented in Python and try to mimic dialogs in commondialog (more or less).

This PR just adds the code used to place native Tk dialogs rewritten to Python.

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Moved the code to separate function (which corresponds Tk private function :tk:PlaceWindow) and resused it in SimpleDialog. There was similar code, but the new code better handles corner cases and supports virtual root window.

It can be reused also in IDLE, but I left this to separate PR.

@serhiy-storchaka serhiy-storchaka merged commit c6c43b2 into python:master Dec 24, 2020
@serhiy-storchaka serhiy-storchaka deleted the tkinter-query-dialog-place branch December 24, 2020 18:26
@terryjreedy

Copy link
Copy Markdown
Member

If I decide to use _place_window before 3.8 or 3.9 leave maintenance, I will put a copy in idlelib for those versions.

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
* If parent is specified and mapped, the query widget is
  centered at the center of parent. Its position and size
  can be corrected so that it fits in the virtual root window.
* Otherwise it is centered at the center of the screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.