这是我的代码:
#-*- coding:utf-8 -*-
import Tkinter as tk
class App:
def __init__(self,root):
frame=tk.Frame(root)
frame.pack()
self.hi_there = tk.Button(frame,text='打招呼',fg = command = self.say_hi)
self.hi_there.pack()
def say_hi(self):
print('互联网的广大朋友们大家好,我是小甲鱼')
root=tk.Tk()
app=App(root)
root.mainloop()
答案 0 :(得分:2)
fg = command = self.say_hi
语法无效;更改为command = self.say_hi
然后运行