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

Using of simple dialogs without default root window #86887

Closed
serhiy-storchaka opened this issue Dec 22, 2020 · 3 comments
Closed

Using of simple dialogs without default root window #86887

serhiy-storchaka opened this issue Dec 22, 2020 · 3 comments
Labels
3.10 only security fixes topic-tkinter type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 42721
Nosy @terryjreedy, @serhiy-storchaka
PRs
  • bpo-42721: Improve using simple dialogs without root window #23897
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-12-25.19:43:34.178>
    created_at = <Date 2020-12-22.20:35:40.957>
    labels = ['type-feature', 'expert-tkinter', '3.10']
    title = 'Using of simple dialogs without default root window'
    updated_at = <Date 2020-12-25.19:43:34.177>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-12-25.19:43:34.177>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-25.19:43:34.178>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2020-12-22.20:35:40.957>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42721
    keywords = ['patch']
    message_count = 3.0
    messages = ['383612', '383666', '383756']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'gpolo', 'serhiy.storchaka']
    pr_nums = ['23897']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue42721'
    versions = ['Python 3.10']

    @serhiy-storchaka
    Copy link
    Member Author

    Currently, standard message boxes in tkinter.messagebox (like showinfo() or askyesnocancel()) can be called without master or default root window. If arguments master or parent are not specified and there is no default root window is still created, the root window is created and set as the default root window. It is kept visible after closing a message box. It was done for testing from REPL. It affects also tkinter.colorchooser.askcolor().

    The drawback is that the root window is kept visible and that it is set as the default root window (so following explicit calls of Tk(), with possible different arguments does not set the default root window).

    Simple query dialogs in tkinter (like askinteger()) initially had the same behavior. But later it was broken, and currently they do not work if master and parent are not specified and the default root window is not set.

    Proposed PR improves behavior of message boxes and colorchooser and restore the lost feature for query dialogs. Now if master and parent are not specified and the default root window is not set, the new temporary hidden root window is created, but is not set as the default root window. It will be destroyed right after closing the dialog, so it will not affect other widgets.

    @serhiy-storchaka serhiy-storchaka added 3.10 only security fixes topic-tkinter type-feature A feature request or enhancement labels Dec 22, 2020
    @terryjreedy
    Copy link
    Member

    The does not affect IDLE, as the two ask... calls pass parent. (And I may someday replace them with query.Query subclasses.) But I do prefer that tkinter act consistently and sensibly for others. The PR's initial commit message adds this justification for the particular behavior: "It will help to use these simple dialog windows in programs which do
    not need other GUI." I agree with this goal.

    Contrary to the message above, temporary root is set as _default_root and the latter is then set back to None. Consequently, there can be no temporary if _default_root cannot be set. Changing this would be messy enough that I think it reasonable to presume and require that people not otherwise needing a GUI will not call no_default_root, or learn to call Tk() if using an installation with patched tkinter.

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 675c97e by Serhiy Storchaka in branch 'master':
    bpo-42721: Improve using simple dialogs without root window (GH-23897)
    675c97e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes topic-tkinter type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants