tkinter in Spyder

Question:

I am trying my first steps in tkinter. I use Spyder as IDE in Python 3.5.1 |Anaconda 4.0.0.

I want to run the very simple script below but it always crashes my Spyder. In a normal shell/bash it runs though and opens the canvas.

import tkinter as tkr

tk = tkr.Tk()
canvas = tkr.Canvas(tk, width=500, height=500)
canvas.grid()
tk.mainloop()

Under Preferences for the Ipython Console I already tried different settings (i.e. Qt, Automatik, Tkinter) but none of it did help.

What am I doing wrong (and how can I do it better)?

many thanks in advance

Asked By: Al_Iskander

||

Answers:

update to Spyder 3.0.1

https://pythonhosted.org/spyder/

https://github.com/spyder-ide/spyder/releases/tag/v3.0.1

I just did this on win 10: no crash, got blank “tk” separate window

Answered By: f5r5e5d
  • In the Spider menu bar, go to: Tools > Preferences
  • A window will open, then on left side go to: Completion and linting
  • In the right side, go to: introspection and below you will see different modules available in your current spider
  • In the section "Preload the following modules…", add tkinter to the end of the list

enter image description here

Answered By: Beast Mr

You should try to change the graphics backend
Go to tools/preferences/I-python Console/Graphics and in backend change it to Tkinter.
That should do it!!

Answered By: yugantyugz

I found this suggestion while trying to get tkinter to display a GIF image in a label. First, on a Mac, the Tools menu item does not contain Preferences–look under the "python" menu instead. Even so, I have the
IPython Console Graphics backend set to Tkinter and tkinter is added to Completion and Linting. But all I get when launching from Spyder is an empty frame entitled "tk #442", whereas when I launch from the command line I get a frame with a nice GIF image as expected.

Answered By: RadlyEel
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.