简体   繁体   English

禁用在Spinbox Python Tkinter中单击

[英]Disable clicking in spinbox python tkinter

I have a project where I need to be able to adjust stock in a python Tkinter program, to do this I am using a spinbox which allows the program to know how many items the user wants to add or subtract. 我有一个项目,需要在python Tkinter程序中调整库存,为此,我正在使用一个旋转框,该框允许程序知道用户要添加或减去多少个项目。 I have the from_ and to set to values but I can't figure out how to stop the user clicking in the field and changing the value to something outside of the range manually. 我有from_to设定值,但我无法弄清楚如何阻止用户点击该栏,并手动更改范围之外的价值的东西。

I am fairly new to python so any help is appreciated. 我是python的新手,因此不胜感激。

When you define your spinbox, just set argument state to "readonly" . 定义Spinbox时,只需将参数state设置为"readonly" Example: 例:

w = Spinbox(master, from_=0, to=10, state = 'readonly')

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

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