我已經構建的應用程序定義的,源開始這樣的:NameError:名稱「TK」沒有在對象類
from tkinter import Text
from tkinter import Label
from AESEncDec import *
from MD5Hashing import *
from RSAEncDec import *
color = 'lightblue' #color our background
class Application(Frame):
def __init__(self, root=None):
Frame.__init__(self, root)
self.frame_width = 700
self.frame_height = 400
但它最後一塊不能執行:
#create object TK class
the_window = Tk(className = " Cryptographic")
#create object Application
app = Application(the_window)
#run our Application
app.mainloop()
並且它給出NameError:
Traceback (most recent call last): File "/home/artur/Documents/MScProject/MSc Project/Task #179276/main_program.py", line 169, in the_window = Tk(className = " Cryptographic") NameError: name 'Tk' is not defined
在這種情況下我應該如何正確定義它?
你需要導入Tk嗎? – AK47
你確實意識到這與你的[上一個問題](https://stackoverflow.com/questions/46252200/nameerror-name-frame-is-not-defined-python)的問題完全相同,只是使用了不同的名稱忘了導入? –