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

IDLE - several common dialogs don't have correct parent set #69360

Closed
roseman mannequin opened this issue Sep 19, 2015 · 7 comments
Closed

IDLE - several common dialogs don't have correct parent set #69360

roseman mannequin opened this issue Sep 19, 2015 · 7 comments
Assignees
Labels
topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@roseman
Copy link
Mannequin

roseman mannequin commented Sep 19, 2015

BPO 25173
Nosy @terryjreedy, @kbkaiser, @serwy, @roseman
Files
  • masterparent.patch
  • masterparent27.patch
  • 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 = 'https://github.com/terryjreedy'
    closed_at = <Date 2015-09-26.03:44:01.637>
    created_at = <Date 2015-09-19.02:26:48.129>
    labels = ['expert-IDLE', 'type-bug']
    title = "IDLE - several common dialogs don't have correct parent set"
    updated_at = <Date 2015-09-26.03:44:01.636>
    user = 'https://github.com/roseman'

    bugs.python.org fields:

    activity = <Date 2015-09-26.03:44:01.636>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2015-09-26.03:44:01.637>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2015-09-19.02:26:48.129>
    creator = 'markroseman'
    dependencies = []
    files = ['40517', '40518']
    hgrepos = []
    issue_num = 25173
    keywords = ['patch']
    message_count = 7.0
    messages = ['251048', '251052', '251086', '251094', '251095', '251627', '251634']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'kbk', 'roger.serwy', 'markroseman', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25173'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    @roseman
    Copy link
    Mannequin Author

    roseman mannequin commented Sep 19, 2015

    The confirmation, file, etc. common dialogs in tkinter accept both a 'master' and a 'parent' argument. Master is not required (it will use parent if not provided). Parent is used to associate the dialog with a given window. On Mac OS X, using parent further turns this into a 'sheet' attached to that window.

    Most places in IDLE we're correctly using parent, but there are several places that master is provided, but not parent, e.g. IOBinding.py. This is most noticeable doing a 'do you want to save before closing...' where now it is not attached to the window on Mac, but it should be.

    Need to go through the code, every place the common dialogs are used and check if master/parent are being used correctly.

    @roseman roseman mannequin added the topic-IDLE label Sep 19, 2015
    @terryjreedy
    Copy link
    Member

    General comments on 'master' versus 'parent':
    This seems to be a matter of confusion in tkinterland. When I have asked before about the difference, all I have gotten is that they are more or less the same.

    http://effbot.org/tkinterbook/entry.htm, for instance, used 'parent' and 'master' interchangeably in the text, says the signature is 'master=None', copying the docstring, and then says "*master*\n\tParent widget". Thinking "Ah, they are the same thing" is quite easy after reading this.

    A widely recommended reference, http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html, which has otherwise been very helpful to me, documents widgets as having a required 'parent'. (I don't blame it for avoid the complication of a default Tk().) But Widget(parent=root) and Widget(master=root) are not normally the same.

    But simple tests may not obviously show a difference, because 'master=None' really means 'master=<hidden default Tk()', unless one has disallowed such, and invalid options are sometimes accepted (at least initially).

    ---
    Specific comments about 'master' versus 'parent' in relation to this issue, which concerns tkinter.commondialog.Dialog and subclasses, especially messagebox.Message: From experiments and code reading, I discovered the following.

    Commondialog.Dialog is does not wrap a tk widget, but is a common baseclass for multiple widget wrappers. The 'master' parameter is used as a master for a Frame. The Frame was needed 20 years ago. Is this still true today? It is not used at all by messagebox.Message. If master is not given, the parent option is used for its value.

    The complete set of options (from an exception) is -default, -detail, -icon, -message, -parent, -title, or -type. All but 'detail' are discussed in comments and http://effbot.org/tkinterbook/tkinter-standard-dialogs.htm. Perhaps 'detail' was added since the code and book were written. The latter says

    parent (widget)
    Which window to place the message box on top of. When the message box is closed, the focus is returned to the parent window.

    For message boxes, it seems we should use parent=xyz, unless we want the box free-floating, which might be never, especially given the extra meaning on Mac. It also seems that we need not use master=abc unless we omit parent=xyz or xyz is not suitable as a Frame master. (Are there any restrictions on this?)

    I need to know if any of the other dialog wrapper use 'master', or if a different usage rule is needed for them.

    Grepping (find in files) 'master=' gets 23 hits, 8 in IOBinding, and in 8 different files. Not all of these are for messagebox. Grepping 'master =' finds 1 more use in a message box call in IOBinding. (This is a style error, which can be fixed when working on a file). Grepping 'tkinter.messagebox' gets 14 imports, so many files are not using 'master' in messagebox calls.

    If you provide a messagebox patch or patches for both 2.7 and 3.4, I will review and presumably apply. We can then consider the other dialogs.

    (When we re-write files to PEP-8, we will use the 3.x 'messagebox' and rename tkMessageBox in the 2.7 file. I am thinking about doing the switch now, and adding 'tkMessageBox' as a back-compatibility alias. It would be best to do this when adding mbox tests.)

    @terryjreedy terryjreedy self-assigned this Sep 19, 2015
    @terryjreedy terryjreedy added the type-bug An unexpected behavior, bug, or error label Sep 19, 2015
    @roseman
    Copy link
    Mannequin Author

    roseman mannequin commented Sep 19, 2015

    No comment on state of Tkinter documentation. ;-)

    I'll have a go through the uses of 'master' in IDLE and see which others should be changed, and put together a patch. Plus double-check with all the other dialogs in lib/tkinter to see if there are any other gotchas to be aware of.

    The 'detail' option appears to be 8.5 only, added in 2004 (http://www.tcl.tk/cgi-bin/tct/tip/152.html).

    @roseman
    Copy link
    Mannequin Author

    roseman mannequin commented Sep 19, 2015

    I think both master and parent are needed, for the likely rare case when you don't want a dialog attached to any window, but it needs a Tk window handle to build the dialog from.

    Ran across that in SearchEngine, which has a root window just for the purpose of creating dialogs, but the search engine doesn't know what search dialog is invoking it (a bad example, as in this case, the dialogs should be the ones display the error, not the search engine).

    Anyway, have attached masterparent.patch for default branch which updates those message and file dialogs that make sense to use parent instead of master.

    @roseman
    Copy link
    Mannequin Author

    roseman mannequin commented Sep 19, 2015

    Attached masterparent27.patch, same thing for 2.7 branch

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 26, 2015

    New changeset e406d62014f7 by Terry Jan Reedy in branch '2.7':
    Issue bpo-25173: Replace 'master' with 'parent' in tkinter.messagebox calls.
    https://hg.python.org/cpython/rev/e406d62014f7

    New changeset e494316a9291 by Terry Jan Reedy in branch '3.4':
    Issue bpo-25173: Replace 'master' with 'parent' in tkinter.messagebox calls.
    https://hg.python.org/cpython/rev/e494316a9291

    @terryjreedy
    Copy link
    Member

    Opened bpo-25237 about Dialog+subclass docs.

    @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
    topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant