求助!!!关于Python报错
import tkinter as tkimport sys
import os
import time
class App:
def __init__(self, root):
frame = tk.Frame(root)
frame.pack()
self.Calc = tk.Button(frame, text="计算器", fg="blue", command=self.calc)
self.Calc.pack(side=tk.LEFT)
self.Notepad = tk.Button(frame, text="记事本", fg="black", command=self.notepad)
self.Notepad.pack(side=tk.LEFT)
self.Time = tk.Button(frame, text="时间", fg="red", command=self.time).pack()
self.Time.pack(side=tk.LEFT)
def calc(self):
os.system("calc")
def notepad(self):
os.system("notepad")
def time(self):
top = Toplevel()
top.title("时间")
msg = Message(top, text="现在是:" + time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
msg.pack()
运行后为什么会报错??? 本帖最后由 heidern0612 于 2018-12-28 14:10 编辑
30行最后少个括号。
heidern0612 发表于 2018-12-27 19:35
30行最后少个括号。
import tkinter as tk
import sys
import os
import time
class App:
def __init__(self, root):
frame = tk.Frame(root)
frame.pack()
self.Calc = tk.Button(frame, text="计算器", fg="blue", command=self.calc)
self.Calc.pack(side=tk.LEFT)
self.Notepad = tk.Button(frame, text="记事本", fg="black", command=self.notepad)
self.Notepad.pack(side=tk.LEFT)
self.Time = tk.Button(frame, text="时间", fg="red", command=self.time).pack()
self.Time(side=tk.LEFT)
def calc(self):
os.system("calc")
def notepad(self):
os.system("notepad")
def time(self):
top = tk.Toplevel()
top.title("时间")
msg = tk.Message(top, text="现在是:" + time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
msg.pack()
root = tk.Tk()
app = App(root)
root.mainloop()
又出错了。。 去掉34行的(root)
页:
[1]