0

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

1
  • fix your typo in var = StringVar(), add this instruction before that: root = Tk() and modify the last line to root.mainloop() ... and do not hurry to ask :) Commented Jul 3, 2016 at 13:53

2 Answers 2

3

following line is missing ()

var = StringVar()
               ^^

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

master = Tk()
var = StringVar()
Sign up to request clarification or add additional context in comments.

Comments

1

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 :))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.