Reputation: 87
It tells me "TypeError: set() missing 1 required positional argument: 'value'" and I am really new so I can't figure out what I did wrong. When using pyCharm and hovering over the argument in set() it says "Expected type 'Variable', got 'int' instead". I don't know what that means. Here's the code:
from tkinter import *
var = StringVar
hoho = 0
master = Tk()
var.set (hoho)
photo = PhotoImage(file="C:\\Users\\josa\\Downloads\\Kappa.pmm")
w = Label(image=photo)
w.photo = photo
w.pack()
w = Label(master, text=var, )
w.pack()
mainloop()
PS: sorry for asking a question that might seem dumb
Upvotes: 0
Views: 16300
Reputation: 369
You are missing parentheses after StringVar
. it should be StringVar()
, because the set()
method only work on StringVar()
object.
Your code should be like this:
from tkinter import *
var = StringVar() #With parentheses
var.set("Whatever String object you want")
Now it should work :))
Upvotes: 1
Reputation: 368924
following line is missing ()
var = StringVar()
^^
And creation of StringVar
should be done after creating root windows:
master = Tk()
var = StringVar()
Upvotes: 3