在我的程序中,我希望能够按下一个按钮,打开一个新的tkinter窗口。我有这个工作,但我看到,当你再次按下按钮,相同的窗口打开。我如何防止这种情况?
代码:
def login_success():
print('Login success') #confirmation that Go button works, funtion will change
def login_screen():
global screen
root.geometry('300x350')
root.title('Login')
global username_login
global password_login
username_login = StringVar() #turns global variable into string
password_login = StringVar()
Label(text = 'TGUP' , bg = 'light blue', width ='300', height = '2', font =('Calibri',13)).pack()
Label(text = '').pack()
Button(text = 'Register', height='2',width='30', command=Reg).pack() #opens new window
Label(text='').pack()
Label(text = 'Login', fg = 'purple', font=10).pack()
Label(text = 'Username').pack()
username_entry1 = Entry(textvariable = username_login, bg='light grey').pack() #entry box for inputs
Label(text = 'Password').pack()
password_entry1 = Entry(textvariable = password_login, bg='light grey', show='*').pack()
Button(text = 'Go', width = '10', height='2', fg='green', command=login_success ).pack()
Label(text='').pack()
Button(text='Exit', height='2',width='20', fg='red' ,command=root.destroy).pack() #destroys window
暂无答案!
目前还没有任何答案,快来回答吧!