question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tkinter apps don't work properly when graphics backend is set to Tkinter

See original GitHub issue

Problem Description

There are some problems when running tkinter scripts with graphics backend set to Tkinter.

  • Application won’t close properly (after closing window something is still running in the background, so the console is busy). Somehow this is the solution:
        self.master.quit() # stops the mainloop?
        self.master.destroy()
  • Widgets won’t change state properly
  • I can’t start application without passing root object to main class (descendant of the Frame class):
    root = tk.Tk()
    app = SomeClass(master=root)
    app.master.title('PyExplore - Python Data Exploration Tool - version 0.1')
    app.mainloop()

What steps will reproduce the problem?

  1. Set graphics backend to Tkinter
  2. Run some tkinter script like the one below:
import tkinter as tk
import tkinter.ttk as ttk
 
def check_test():
    print("state: {}".format(chk_state.get()))

window = tk.Tk()
window.geometry('350x200+1000+400')
chk_state = tk.IntVar(value=-1)
#chk_state.set(True) #set check state
chk = ttk.Checkbutton(window, text='Choose', var=chk_state, command=check_test)
chk.grid(column=0, row=0)
window.mainloop()
  1. Try to change checkbox state
  2. Try to close application

What is the expected output? What do you see instead?

I would expect something like this:

  • widgets change state properly
  • after closing window console is released

expected_output

What I got looks like this:

actual_output

Paste Traceback/Error Below (if applicable)


PASTE TRACEBACK HERE

Package Versions

  • Spyder: 3.2.8
  • Python: 3.6.5
  • Qt: 5.9.4
  • PyQt: 5.9.1
  • Operating System: Windows 10

Dependencies

IPython >=4.0    :  6.3.1 (OK)
cython >=0.21    :  0.28.2 (OK)
jedi >=0.9.0     :  0.12.0 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
numpy >=1.7      :  1.14.2 (OK)
pandas >=0.13.1  :  0.22.0 (OK)
pycodestyle >=2.3:  2.4.0 (OK)
pyflakes >=0.6.0 :  1.6.0 (OK)
pygments >=2.0   :  2.2.0 (OK)
pylint >=0.25    :  1.8.4 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
rope >=0.9.4     :  0.10.7 (OK)
sphinx >=0.6.6   :  1.7.4 (OK)
sympy >=0.7.3    :  1.1.1 (OK)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, May 6, 2018

@czatom, Tk under Windows doesn’t work well if you’re using Anaconda, and I think that’s the fault of Anaconda. Is this the case for you?

0reactions
CAM-Gerlachcommented, Dec 20, 2018

Here’s a link to the Roadmap; Beta 3 will be the one with the key changes I mentioned. The final release should follow in perhaps early March.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tkinter: "Python may not be configured for Tk" - Stack Overflow
After installing the packages, this hello-world example seems to be working fine on Python 2.7: $ cat hello.py from Tkinter import * root ......
Read more >
How to Program a GUI Application (with Python Tkinter)!
Follow me https://twitter.com/keithgalli for more Python content!In this video, we learn how to build an application with a graphical user ...
Read more >
Create GUI App with Tkinter and SQLite - YouTube
Today we will create a highly sophisticated Tkinter application, which is PERFECT for beginners and even intermediate Python developers!
Read more >
Desktop GUI App With Python & Tkinter - YouTube
In this video we will build a CRUD GUI app with Python, the Tkinter library and Sqlite3Sponsor: Linode Cloud HostingGet $20 Free by...
Read more >
Tkinter Application to Switch Between Different Page Frames
You can add images and graphs to these pages and add complex functionality. The pages have two buttons as well. Every time a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found