首页 > 解决方案 > Automatic input jump tkinter

问题描述

I am new to python and my question is if there is a way to enter data in an entry and when it reaches the indicated number of characters it will automatically jump to the next entry

I need something like this

sample image

标签: pythontkintertkinter-entry

解决方案


如果您想这样做,我强烈建议您使用该.trace()方法。此方法在后台执行的操作 --> 每当触发所述条件时,它都会调用一个函数。例如:

name_of_stringvar = StringVar()
Entry(root, textvariable = name_of_stringvar)
name_of_stringvar.trace('w', function_name)

因此,每当在 中输入内容时Entry(),它都会转到函数(function_name在这种情况下)。您可以说明检查第一个条目的最大字符数的条件。然后当超出限制时,使用该focus_force()方法将光标移动到第二个条目。


推荐阅读