Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Using tkinter in Spyder
#1
tkinter isn't working on Spyder for some reason. do I have to uninstall it?

import tkinter as tkr

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

def donothing():
    filewin = Toplevel(root)
    button = Button(filewin, text="Do nothing")
The last two lines have the yellow triangle with the exclamation mark, indicating some kind of an undefined root.

I had a normal terminal that was not an IDE and everything was working fine, but now it's not working..
Yoriz wrote Jul-25-2019, 05:19 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote
#2
The code has the following problems that is nothing to do with spyder not letting it work.

  1. root has not been defined

  2. Toplevel does not have tkr. in front of it.

  3. Button does not have tkr. in front of it.

  4. donothing has not been called.

  5. if donothing is called it will need to be called before the GUI mainloop is started or there will be a application has been destroyed error
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)