为了账号安全,请及时绑定邮箱和手机立即绑定

在 Tkinter 中使用多个输入窗口

在 Tkinter 中使用多个输入窗口

慕标5832272 2021-06-11 17:43:23
我正在尝试创建多个输入窗口,但是当我回答完问题时,出现错误。import tkinterfrom tkinter import ttkwindow2 = False#--------ACTION 2-----------def action2():    window2 = False    global e4    Address = e4.get()    print("The address is", Address)    global e5    ConsDate = e5.get()    print("The date of construction is", ConsDate)    global e6    LastRemoDate = e6.get()    print("The date of the last remodel is", LastRemoDate)#----------SECOND WINDOW---------def window2():    window2 = tkinter.Tk()     window2.title("Name Software")    TitleLabel = ttk.Label(window2, text = "Name Information")    TitleLabel.grid(row = 0, column = 1)    L4 = ttk.Label(window2, text = "What is your address?")    L4.grid(row =1, column = 0)    e4 = ttk.Entry(window2, width = 50)    e4.grid(row = 1, column = 1)    L5 = ttk.Label(window2, text = "What is the original date of construction?")    L5.grid(row = 2, column = 0)    e5 = ttk.Entry(window2, width = 50)    e5.grid(row = 2, column = 1)    L6 = ttk.Label(window2, text = "What is the date of the last remodel?")    L6.grid(row = 3, column = 0)    e6 = ttk.Entry(window2, width = 50)    e6.grid(row = 3, column = 1)    btn = ttk.Button(window2, text = "Submit Answers", command = action2)    btn.grid(row = 5, column = 1)window2()当我运行它时,它给了我错误Line 12, in action2Address = e4.get()NameError: name 'e4' is not defined我该如何解决?我从脚本的其他部分复制了它并更改了问题。第一部分有效,但这不起作用。任何帮助表示赞赏。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 134 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信