Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

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

  • 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
Copy link
Member

terryjreedy commented Dec 24, 2020

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
Member

terryjreedy commented Dec 24, 2020

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
Member Author

serhiy-storchaka commented Dec 24, 2020

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
Member Author

serhiy-storchaka commented Dec 24, 2020

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
3 checks passed
@serhiy-storchaka serhiy-storchaka deleted the tkinter-query-dialog-place branch Dec 24, 2020
@terryjreedy
Copy link
Member

terryjreedy commented Dec 24, 2020

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.

None yet

4 participants