简体   繁体   English

是否有一个函数可以在 tkinter 中创建用户生成的入口空间,我们可以从中获取输入?

[英]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.

相关问题 tkinter中的用户输入是否存储为“条目”而不是“ int”? - User inputs in tkinter are stored as 'Entry' instead of 'int'? 我们如何检查输入项是否为空,同时又从用户那里获取输入项,该输入项是否转换为float? - How can we check input entry is empty or not which is converted into float while getting the input from the user? 如何从 tkinter 中的条目中获取可用作 function 的数据? - How can I get the data from Entry in tkinter that can be used as function? python,tkinter 条目到达 function(错误来自 F 按钮的 ZC1C425268E68385D14AB5074C17ZA49) - python, tkinter entry get to function (error was with function call from button) 单击“按钮”,从条目(Tkinter)获取用户输入 - Get user input from Entry (Tkinter) on click of Button 从输入字段tkinter存储用户输入 - Store user entry from entry field, tkinter 在 tkinter 中计算入口输入 - calculating entry inputs in tkinter 如何从 tkinter 中的条目小部件返回用户输入 - how can I return the user input from entry widget in tkinter 从Entry小部件获取值并创建变量Tkinter列表 - Get values from Entry widgets and create list of variables Tkinter 如何从 tkinter 输入框获取输入到另一个 function 中的变量? - How to get input from a tkinter entry box, to a variable in another function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM