|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
WIN10,python版本3.7.6
----------------------------------
import tkinter as tk
class APP:
def __init__(self, master):
frame = tk.Frame(master)
frame.pack()
self.hi_there = tk.Button(frame, text='打招呼', fg='blue')
self.hi_there.pack()
#def say_hi(self):
#print('互联网的广大朋友们,大家好!我是你们的小甲鱼哦…')
root = tk.TK()
app = APP(root)
root.mainloop()
无法正常运行,提示如下:
Traceback (most recent call last):
File "D:\work\p15_2.py", line 20, in <module>
root = tk.TK()
AttributeError: module 'tkinter' has no attribute 'TK'
不知道什么情况?代码完全按照小甲鱼视频,视频里却可以运行
可以的这样:
- import tkinter as tk
- class TK(tk.Tk):
- pass
- class APP:
- def __init__(self, master):
- frame = tk.Frame(master)
- frame.pack()
- self.hi_there = tk.Button(frame, text='打招呼', fg='blue')
- self.hi_there.pack()
-
- # def say_hi(self):
- # print('互联网的广大朋友们,大家好!我是你们的小甲鱼哦…')
-
- root = TK()
- app = APP(root)
- root.mainloop()
复制代码
|
|