Adde21_30 Adde21_30 - 5 months ago 139
Python Question

Python TypeError: set() missing 1 required positional argument: 'value'

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

Answer

following line is missing ()

var = StringVar()
               ^^

And creation of StringVar should be done after creating root windows:

master = Tk()
var = StringVar()