-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
IDLE - several common dialogs don't have correct parent set #69360
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
Comments
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. |
General comments on 'master' versus 'parent': 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). --- 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) 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.) |
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). |
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. |
Attached masterparent27.patch, same thing for 2.7 branch |
New changeset e406d62014f7 by Terry Jan Reedy in branch '2.7': New changeset e494316a9291 by Terry Jan Reedy in branch '3.4': |
Opened bpo-25237 about Dialog+subclass docs. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: