[英]Is there a function to create user generated entry spaces in tkinter from which we can get inputs?
Hello Everyone I am a Student developer developing a student database program GUI.大家好,我是一名学生开发人员,正在开发学生数据库程序 GUI。 I am using Python and tkinter for the same.
我正在使用 Python 和 tkinter。 So in the program i want to get inputs from the user in entry spaces who's number is not same every time.
所以在程序中,我想从用户输入的输入空间中获取每次输入都不相同的输入。 so i want to know that without hard coding the spaces how to get those spaces.
所以我想知道没有硬编码空间如何获得这些空间。 The number of spaces will be defined in the start of the program by the user.
空格数将由用户在程序开始时定义。
All you need to do is create the widgets in a loop, and save them in a list.您需要做的就是在循环中创建小部件,并将它们保存在列表中。
The following example requires that the number of entries be passed in as an argument:以下示例要求将条目数作为参数传入:
import tkinter as tk
import sys
root = tk.Tk()
num_inputs = int(sys.argv[1])
entries = []
for i in range(num_inputs):
entry = tk.Entry(root)
entries.append(entry)
entry.pack(side="top", fill="x")
root.mainloop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.