Issue 15303: Minor revision to the <BaseWidget._setup> method in Tkinter (original) (raw)

Created on 2012-07-09 08:25 by Drew.French, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkbugfix.py Drew.French,2012-07-09 08:25 A revised version of the <BaseWidget._setup> method in Tkinter
tkinter_widget_is_none.patch serhiy.storchaka,2012-12-23 18:55 review
Pull Requests
URL Status Linked Edit
PR 23904 merged serhiy.storchaka,2020-12-23 06:09
Messages (5)
msg165070 - (view) Author: Drew French (Drew.French) Date: 2012-07-09 08:25
In the <BaseWidget._setup> method, is evaluated as a Boolean (when Tkinter attempts to find a parent for the widget). I think it should really be evaluated against , seeing as that is the default keyword argument value for most widgets. I ran into problems with this when making a container widget class that inherited from the , then implementing the <__len__> magic method. When the length was zero the widget would evaluate as false, which would prevented me from packing widgets inside my container widget. I attached a revised version of the method.
msg175233 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-09 13:16
Can you provide a patch in diff format? You can find more information about how to do it on the devguide.
msg175236 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2012-11-09 14:11
Please include a short version of the widget class you mentioned. It must be only long enough to show the issue.
msg178007 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-23 18:55
Here is a patch against 3.4 which contains proposed OP change and a lot of similar changes in different places. I'm not sure that this should be considered as a bug fix and not as an enhancement. Drew, as a workaround you can implement __bool__() method which returns True for your widget. Or even better, do not make your container sequence-like.
msg383746 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-25 15:04
New changeset bb70b2afe39ad4334a9f3449cddd28149bd628b6 by Serhiy Storchaka in branch 'master': bpo-15303: Support widgets with boolean value False in Tkinter (GH-23904) https://github.com/python/cpython/commit/bb70b2afe39ad4334a9f3449cddd28149bd628b6
History
Date User Action Args
2022-04-11 14:57:32 admin set github: 59508
2020-12-25 19:48:59 serhiy.storchaka set status: open -> closedstage: patch review -> resolvedresolution: fixedversions: + Python 3.10, - Python 3.6
2020-12-25 15:04:29 serhiy.storchaka set messages: +
2020-12-23 06:09:00 serhiy.storchaka set pull_requests: + <pull%5Frequest22758>
2016-07-24 11:04:03 serhiy.storchaka set assignee: serhiy.storchakatype: behavior -> enhancementversions: + Python 3.6, - Python 3.4
2014-01-09 19:50:06 serhiy.storchaka set priority: normal -> low
2012-12-23 18:55:10 serhiy.storchaka set files: + tkinter_widget_is_none.patchversions: + Python 3.4, - Python 2.7keywords: + patchnosy: + serhiy.storchakamessages: + stage: needs patch -> patch review
2012-11-09 14:11:36 gpolo set messages: +
2012-11-09 13:16:40 ezio.melotti set nosy: + gpolo, ezio.melottimessages: + stage: needs patch
2012-07-09 08:25:49 Drew.French create