0

The following is the functional issue I'm dealing with. While this example doesn't do it, word is being set by a for loop, so I can't just set "dave" with a string. However, if you run it, you can see that "word" is printing "smith" and "dave" is printing "PYVAR0." How can I fix it so "dave" prints "smith"?

from Tkinter import *
import ttk
root = Tk()
word = "smith"
print word
dave = StringVar()
dave.set(word)
print dave

1 Answer 1

1

You need to invoke dave.get:

print dave.get()

Doing so will return the string value contained in the StringVar.

Sign up to request clarification or add additional context in comments.

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.