From e6e9041422e957811fbea92bcb7e6e85fa2200ad Mon Sep 17 00:00:00 2001 From: itsHenry35 <2671230065@qq.com> Date: Sat, 17 Jun 2023 22:30:04 +0800 Subject: [PATCH] fix: sms not defined error while closing --- gui/login1.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/gui/login1.py b/gui/login1.py index 40e34bd..9e8b638 100644 --- a/gui/login1.py +++ b/gui/login1.py @@ -2,6 +2,7 @@ from ttkbootstrap.constants import * import importlib import tkinter.messagebox as mb +import sys def login1(): global sms @@ -18,6 +19,16 @@ def switchtosms(): sms = 'True' username_ = username.get().replace('\r','').replace('\n','').replace('\t','') root.destroy() + if sms == 'False': + return {'success' : 'True', + 'usrname':username_, + 'pwd':password_, + } + if sms == 'True': + return { + 'success' : 'False', + 'phonenum' : username_ + } def nextpage(): global username_ global password_ @@ -49,16 +60,10 @@ def nextpage(): submit.grid(row=3, column=2) root.mainloop() importlib.reload(ttk.style) - if sms == 'False': - return {'success' : 'True', - 'usrname':username_, - 'pwd':password_, - } - if sms == 'True': - return { - 'success' : 'False', - 'phonenum' : username_ - } + try: + sms + except NameError: + sys.exit() if __name__ == '__main__': print(login1()) \ No newline at end of file