简体   繁体   English

如何在Python tkinter的小部件中隐藏值?

[英]How can I hide a value in a widget in Python tkinter?

I am new to Python, I am from Android background. 我是Python的新手,来自Android背景。 Like in Android we can set a value to any widget (that value is not visible) like, 像在Android中一样,我们可以为任何窗口小部件(该值不可见)设置一个值,例如,

textView.setTag(value)
textView.getTag()

Similarly, is there anything in Python tkinter? 同样,Python tkinter中有什么吗?

You can set an attribute directly on the widget, and "hide" it there, that should not have adverse consequences: 您可以直接在窗口小部件上设置一个属性,然后将其“隐藏”在该窗口小部件中,这样不会产生不利影响:

widget = tk.Frame(root, ...)
widget._my_hidden_value = 42

There is the caveat that nothing is ever really hidden in python... And the question: "why would you need to do that?" 需要警告的是,python中什么都没有真正隐藏起来……还有一个问题:“为什么要这么做?”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM