作爲我登錄GUI的一部分,一旦輸入了正確的詳細信息,用戶就會進入主屏幕頁面。NameError:全局名稱'WTI'未定義
def login():
content = nameentry.get()
content1 = IDentry.get()
if content == "1" and content1 == "1":
root.destroy(), execfile("Homescreenscroll - Copy3.1.py")
然而,當Homescreenscroll - Copy3.1.py打開並運行時,它說
Exception in thread Thread-1: Traceback (most recent call last):
File "C:\Users\Isaac\Desktop\Py\lib\threading.py", line 530, in __bootstrap_inner
self.run()
File "C:\Users\Isaac\Desktop\Py\lib\threading.py", line 483, in run
self.__target(*self.__args, **self.__kwargs)
File "Homescreenscroll - Copy3.1.py", line 5862, in trick
WTI['text'] = row[0]
NameError: global name 'WTI' is not defined
即使它是在明確規定 'Homescreenscroll - Copy3.1.py' 文件
它是在 'Homescreenscroll - Copy3.1.py' 這個線程的部分文件:
WTI = Label(text = "")
def trick(threadName, sleepTime):
while 1 < 2:
db=MySQLdb.connect(host = "xxx",
user = "xxx",
passwd = "xxx",
db = "test")
cursor = db.cursor()
cursor.execute("""xxxx""", (xxxxx))
cursor.execute("""xxxx""", (xxxx))
db.commit()
row=cursor.fetchone()
WTI['text'] = row[0]
try:
t = threading.Thread(target=trick, args=("Trick running", 5))
t.daemon = True
t.start()
except: Exception,
print "start up"
您的'登錄'功能和'嘗試'部分在這裏看起來是空的,請修復縮進。 – Elisha 2014-08-31 10:50:26
我猜'標籤'它是一個'Tkinter'對象。請添加此信息。此外,嘗試在'trick'函數的開頭添加行'global WTI' – Elisha 2014-09-02 13:52:06