Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

        
AI编程,程序员挑战年入30~100万高级指南 - 职业规划
SpringBoot+SpringSecurity+Vue权限系统高级实战课程        

IDEA永久激活

Java微信小程序电商实战课程(SpringBoot+VUe)

     

AI人工智能学习大礼包

     

PyCharm永久激活

66套java实战课程无套路领取

     

Cursor+Claude AI编程 1天快速上手视频教程

     
当前位置: 主页 > Java文档 > Python技术 >

learning tkinter PDF 下载


分享到:
时间:2024-08-13 11:39来源:http://www.java1234.com 作者:转载  侵权举报
learning tkinter
失效链接处理
learning tkinter PDF 下载

 
 
相关截图:
 

主要内容:

Adding validation to an Entry widget
To restrict the characters that can be typed into an entry widget, only numbers for instance, a
validate command can be added to the entry. A validate command is a function that return True if
the change is accepted, False otherwise. This function will be called each time the content of the
entry is modified. Various arguments can be passed to this function, like the type of change
(insertion, deletion), the inserted text, ...
def only_numbers(char):
return char.isdigit()
validation = parent.register(only_numbers)
entry = Entry(parent, validate="key", validatecommand=(validation, '%S'))
The validate option determines the type of event that triggers the validation, here, it's any
keystroke in the entry. The '%S' in the validatecommand option means that the inserted or deleted
character is passed in argument to the only_numbers function. The full list of possibilities can be
found here.
Getting int From Entry Widget
When using the .get() method whatever is in the entry widget will be converted into a string. For
example, regardless of the type of input(It can be a number or sentence), the resulting outcome
will be a string. If the user types 4 the o
 


 
 
------分隔线----------------------------


锋哥推荐