Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:40:16+00:00 2026-05-24T18:40:16+00:00

I use a Tkinter window to visualize some output of my programm. The window

  • 0

I use a Tkinter window to visualize some output of my programm. The window is threaded (see basic structure below) and basically it works quite fine. So far, I only have trouble closing the window. When I clicke the “X” button for closing the window it works.

However, when I call the Monitor.close() method from the main programm that starts the monitor thread, the window just freezes (e.g., it doesn’t react on clicking the “X” button) and the thread monitor keeps running. Thus, the main program does not exit.

So, at the moment, I also have to close first the window “manually” by clicking the closing button and then the main program. Not a big issue, but it would be great, if the main program could close the window by itself. Any hints?

Thanks and best regards,

Christian

class Monitor(threading.Thread):

    def __init__(self):
        threading.Thread.__init__(self)
        self.start()

    def close(self):
        self.root.quit()
        self.root.destroy()

    def run(self):
        self.root=Tkinter.Tk()
        self.root.protocol("WM_DELETE_WINDOW", self.close)
        self.root.mainloop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:40:19+00:00Added an answer on May 24, 2026 at 6:40 pm

    Python Threading and Tk(inter) used in this way do not mix well, as they violate the Tcl/Tk threading model of using Tk just from one thread.

    It works great with message passing though, just not with direct calls from a thread. So you need to add some message passing via Queue to this.

    Have a look at http://effbot.org/zone/tkinter-threads.htm for an example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Playing around with Python - tkInter - Entry widget - when I use validatecommand
Use case: I've just entered insert mode, and typed some text. Now I want
I'm trying to center a tkinter window. I know I can programatically get the
When I try to use the KeyRelease event on the Tkinter Text widget, it
I embedded a matplotlib graph of a sphere into Tkinter. Now for some reason
So I'm making a very small program for personal use in tkinter, and I've
I'm trying to use tkinter to periodically refresh a square grid. Each square in
I would want to use time to enable event's callback function in Tkinter. How
I want to embed a terminal in my main Tkinter window. I would like
I'm currently trying to graph a sphere in a tkinter window using matplotlib. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.