所以我有一个根控件,我想创建一个弹出窗口,接受教授10门学科的教师人数。(大约3名数学教师、2名英语教师等)
我想使用用户在for循环中输入的数字。任何关于我可以一个接一个地接受多个输入的另一种方式的建议都将不胜感激
from tkinter import *
from random import *
def start():
popup = Toplevel() #this doesnt throw an error when kept in main part of program, why?
popup.geometry('400x300')
for x in ['chem','math','eng']:
accept(x)
def accept(sub):
global entry, label2
label2=Label(popup,text="Enter the number of {} teachers".format(sub))
label2.pack()
entry=Entry(popup) #entry box
entry.pack()
nextb=Button(popup,text='NEXT',command=lambda:nextentry(sub))
nextb.pack()
def nextentry(subject):
global entry
n=int(entry.get())
l=[i+1 for i in range(n)] #i basically want the int of the input, i'm getting an error helppp??
for k in range(n):
allsec[k].append(subject+str(choice(l)))
entry.delete(first=0,last='end')
#----------MAIN----------#
allsec=[[],[],[]]
root=Tk()
root.geometry("600x400")
l1=Label(root,text='USER INPUT')
button=Button(root,text='Start',command=start)
[i.pack() for i in [l1,button]]
root.mainloop()
print(allsec)
目前没有回答
相关问题 更多 >
编程相关推荐