Passing StringVar object from Entry to Label within functions in tkinter

后端 未结 2 1831
旧巷少年郎
旧巷少年郎 2021-01-25 21:06

Hi I\'ve been struggling to get this to work, each time i change something I receive another error. I\'ve been trying to create an entry box with a function and then get the var

2条回答
  •  自闭症患者
    2021-01-25 21:55

    This is the correct way to create a StringVar object:

    text = StringVar() # note additional ()
    

    Can you explain me what x is in the following statement:

    lambda: x.myFunc(self.my_variable.get(self))
    

    x is not visible inside the class, because it's declared outside the class.

    myFunc is not indented correctly: you should indent it like the __init__ method.

    I really recommend you to watch some tutorials on OOP before proceeding. You are basically trying to guess how OOP works.

提交回复
热议问题