鱼C论坛

 找回密码
 立即注册
查看: 3988|回复: 2

tkinter如何获取界面上所有输入框的数据?

[复制链接]
发表于 2022-11-25 15:29:07 | 显示全部楼层 |阅读模式
5鱼币
界面上输入框tk.Entry()的行数 count 是会变的, 不一定是3行.
如何在点击 Button 按钮后能得到界面上所有输入框的数据?

  1. import tkinter as tk


  2. window = tk.Tk()
  3. window.title('输入框行数不确定')
  4. window.geometry('300x200+100+100')


  5. def get():
  6.     print(nt.get())

  7. count = 3
  8. y1 = 0
  9. for i in range(count):
  10.    
  11.     nt = tk.IntVar()
  12.     tk.Entry(window,textvariable=nt,width=20).place(x=10, y=y1)
  13.     nt.set(0)

  14.     y1 += 30


  15. tk.Button(window,text='Get number',bg='lightblue',width=20,relief='raised',command=get).place(x=10,y=120)

  16. window.mainloop()
复制代码

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2022-11-27 12:34:43 | 显示全部楼层
点击前保存
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2022-11-28 10:03:01 | 显示全部楼层

能否写个代码出来看一下?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-22 23:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表