This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients kbk, markroseman, roger.serwy, terry.reedy
Date 2015-09-19.05:29:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1442640591.99.0.101949585039.issue25173@psf.upfronthosting.co.za>
In-reply-to
Content
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 pep8, 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.)
History
Date User Action Args
2015-09-19 05:29:52terry.reedysetrecipients: + terry.reedy, kbk, roger.serwy, markroseman
2015-09-19 05:29:51terry.reedysetmessageid: <1442640591.99.0.101949585039.issue25173@psf.upfronthosting.co.za>
2015-09-19 05:29:51terry.reedylinkissue25173 messages
2015-09-19 05:29:47terry.reedycreate