Skip to content

Threading issue with Tkinter Frame.insert #51182

Closed

Description

@moraygrieve
BPO 6933
Nosy @terryjreedy, @serhiy-storchaka
Files
  • example.py
  • 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 = None
    closed_at = <Date 2013-03-08.21:53:48.998>
    created_at = <Date 2009-09-17.17:01:00.082>
    labels = ['invalid', 'type-bug', 'expert-tkinter']
    title = 'Threading issue with Tkinter Frame.insert'
    updated_at = <Date 2018-05-13.04:56:37.532>
    user = 'https://bugs.python.org/moraygrieve'

    bugs.python.org fields:

    activity = <Date 2018-05-13.04:56:37.532>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-03-08.21:53:48.998>
    closer = 'terry.reedy'
    components = ['Tkinter']
    creation = <Date 2009-09-17.17:01:00.082>
    creator = 'moraygrieve'
    dependencies = []
    files = ['14914']
    hgrepos = []
    issue_num = 6933
    keywords = []
    message_count = 6.0
    messages = ['92781', '92782', '174639', '180034', '183767', '316452']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'moraygrieve', 'Ramchandra Apte', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6933'
    versions = ['Python 2.6']

    Activity

    1. moraygrieve commented on Sep 17, 2009

      moraygrievemannequin
      MannequinAuthor

      The attached file has an example where a Tk GUI is launched as a
      seperate thread - this all works fine in Python 2.5, but in Python 2.6
      the thread hangs.

      The issue seems to be in the line;

      self.messageBoxDetails.insert(INSERT, "Hello world")

      Comment this line out, or use an empty string rather than "Hello World",
      and the example works in both Python 2.5 and Python 2.6. I have not been
      able to seen any related issues to this and wonder if this is a bug in
      the 2.6 Tkinter module.

    2. moraygrieve commented on Sep 17, 2009

      moraygrievemannequin
      MannequinAuthor

      I should say this is running on Windows XP

    3. RamchandraApte commented on Nov 3, 2012

      RamchandraAptemannequin
      Mannequin

      Bump.

    4. serhiy-storchaka commented on Jan 15, 2013

      @serhiy-storchaka
      Member

      Tkinter as perhaps any other GUI library must be used only from one thread.

    5. terryjreedy commented on Mar 8, 2013

      @terryjreedy
      Member

      Quoting from msg179101 on bpo-16823, which I turned into a doc issue:
      '''
      What you are doing appears to be unsupported (invalid). From
      http://www.astro.washington.edu/users/rowen/TkinterSummary.html
      "all Tkinter access must be from the main thread (or more precisely,
      from the thread that calls the mainloop). Violating this is likely to
      cause nasty and mysterious symptoms such as freezes and core dumps."
      '''
      You got the freeze part. I suspect what changed from 2.5 to 2.6 was the tcl/tk version delivered with Python on Windows.

    6. terryjreedy commented on May 13, 2018

      @terryjreedy
      Member
      I changes the import to theading instead of thread and the start line to
      	threading.Thread(target=example)
      On 3.7 with tcl/tk 8.6 with thread support, I see the gui when mainloop is called in the thread, and then the >>> prompt appears.  On 2.7 with tk 8.5 without thread support, I see no hang but only >>>, no box, after the same time delay.  

      With thread support, thread calls work. Without, success varies, and so do failure modes. See bpo-33479 for proposed doc on tkinter and thread safety.

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions