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
tkinter: add _get_master() and use it consistently #48593
Comments
Hi, I've added a new function called setup_master. This function is responsible for returning an usable master to the There are two patches, the first adds the function, the second applies |
Any chance I can get this in ? I'm using something very similar to test |
I am still confused about the master/parent business and why required args are documented as optional. (Besides bpo-18131, I also discovered that messageboxes usually, but not always, require parent=something passed, to be collected into **options. I need to read more before I can really review and think about applying this. Why isn't _default_root initialized to something useful instead of None. If it were, _support_default_root would not be needed. The new function is slightly different from the code it replaces. The main difference I see with Misc.setup is that your code does *not* stash Tk() in _default_root. Since every Tk() call creates a new screen window, I do not see how this is correct. On the plus side, I believe your patch would fix part of the problem I reported in bpo-18131. |
After searching through tkinter.py for '_default_root', the patch looks better. The point I missed before is that Tk().__init__(self,...) normally calls _loadtk(self) which installs self as _default_tk if it was None before. So the new function will return the same Tk object each call after the first (unless _default_tk is somehow reset to None.) This also means that the assignment in BaseWidget.setup, "_default_root = Tk()", which the patch deletes, is redundant and misleading, and should go. I think 'getmaster' or 'get_master' would be a better name than 'setup_master' as setting up a new master is the 2nd backup choice and will happen only once in a session. Most call will get an existing master -- either the one passed in or the once stored as _default_root The patch needs to be updated for 3.4 and run with current tests. |
Changing status back to 'needs patch' per Terry's comment that the patch needs to be updated (now for 3.5). |
The new function should be private. I closed bpo-18131 as partially a duplicate of this. It has a couple of other suggested wordings for the exception. I consider the current behavior, in particular the failure of Variable and subclasses when the supposedly optional master is not passed, to be buggy. So I think backporting should be considered when we settle on a patch. |
Serhiy, have your patches on other issues make this one obsolete, or partially so? |
I do not think that popping up a root window on first call of Variable() or getboolean() is a good idea. bpo-42630 fixed errors in other way. A root window is not automatically created for non-graphic objects (like Variable), instead a RuntimeError with relevant error message is raised. |
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: