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

Minor revision to the <BaseWidget._setup> method in Tkinter #59508

Closed
DrewFrench mannequin opened this issue Jul 9, 2012 · 5 comments
Closed

Minor revision to the <BaseWidget._setup> method in Tkinter #59508

DrewFrench mannequin opened this issue Jul 9, 2012 · 5 comments
Assignees
Labels
3.10 only security fixes topic-tkinter type-feature A feature request or enhancement

Comments

@DrewFrench
Copy link
Mannequin

DrewFrench mannequin commented Jul 9, 2012

BPO 15303
Nosy @ezio-melotti, @serhiy-storchaka
PRs
  • bpo-15303: Support widgets with boolean value False in Tkinter #23904
  • Files
  • tkbugfix.py: A revised version of the <BaseWidget._setup> method in Tkinter
  • tkinter_widget_is_none.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/serhiy-storchaka'
    closed_at = <Date 2020-12-25.19:48:59.890>
    created_at = <Date 2012-07-09.08:25:49.856>
    labels = ['type-feature', 'expert-tkinter', '3.10']
    title = 'Minor revision to the <BaseWidget._setup> method in Tkinter'
    updated_at = <Date 2020-12-25.19:48:59.889>
    user = 'https://bugs.python.org/DrewFrench'

    bugs.python.org fields:

    activity = <Date 2020-12-25.19:48:59.889>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2020-12-25.19:48:59.890>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2012-07-09.08:25:49.856>
    creator = 'Drew.French'
    dependencies = []
    files = ['26326', '28410']
    hgrepos = []
    issue_num = 15303
    keywords = ['patch']
    message_count = 5.0
    messages = ['165070', '175233', '175236', '178007', '383746']
    nosy_count = 4.0
    nosy_names = ['gpolo', 'ezio.melotti', 'serhiy.storchaka', 'Drew.French']
    pr_nums = ['23904']
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue15303'
    versions = ['Python 3.10']

    @DrewFrench
    Copy link
    Mannequin Author

    DrewFrench mannequin commented Jul 9, 2012

    In the <BaseWidget._setup> method, <master> is evaluated as a Boolean (when Tkinter attempts to find a parent for the widget). I think it should really be evaluated against <None>, seeing as that is the default <master> keyword argument value for most widgets. I ran into problems with this when making a container widget class that inherited from the <Canvas>, 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.

    @DrewFrench DrewFrench mannequin added type-bug An unexpected behavior, bug, or error topic-tkinter labels Jul 9, 2012
    @ezio-melotti
    Copy link
    Member

    Can you provide a patch in diff format?
    You can find more information about how to do it on the devguide.

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Nov 9, 2012

    Please include a short version of the widget class you mentioned. It must be only long enough to show the issue.

    @serhiy-storchaka
    Copy link
    Member

    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.

    @serhiy-storchaka serhiy-storchaka self-assigned this Jul 24, 2016
    @serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Jul 24, 2016
    @serhiy-storchaka
    Copy link
    Member

    New changeset bb70b2a by Serhiy Storchaka in branch 'master':
    bpo-15303: Support widgets with boolean value False in Tkinter (GH-23904)
    bb70b2a

    @serhiy-storchaka serhiy-storchaka added the 3.10 only security fixes label Dec 25, 2020
    @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
    3.10 only security fixes topic-tkinter type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants