0
import sys
import tkinter
counter = 0
def update():
global count, b
counter += 1
b.config(text = "click cont = " + str(count))
print("updating")
root = tkinter.Tk()
b = tkinter.Button(root)
b.configure(background="yellow", text="click count = 0", command=update)
b.pack()
root.mainloop()
Traceback (most recent call last):
File "C:/Users/miopo/untitled-1.py", line 12, in <module>
root = tkinter.Tk()
File "C:\Users\miopo\AppData\Local\Programs\Python\Python36-32\Lib\tkinter\__init__.py", line 2012, in __init__
baseName = os.path.basename(sys.argv[0])
builtins.IndexError: list index out of range
i use Wing 101 as ide
– Enzo Carvalho
How did you execute the file? By default, if the class
Tk
do not possess the value ofbasename
defined in your call it will seek the name of the script executed from the command line arguments; and the first argument,sys.argv[0]
, always is defined in the execution.– Woss
i ran using Wing 101 I just typed the code in the ide and selected run debug
– Enzo Carvalho
Enzo, tries to run your file direct from the command line, other than by IDE.
– Woss
From the command line your code worked perfectly here: https://i.imgur.com/aEAgvyS.jpg
– Woss