鱼C论坛

 找回密码
 立即注册
查看: 2712|回复: 3

求助!!!关于Python报错

[复制链接]
发表于 2018-12-27 19:25:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import tkinter as tk
  2. import sys
  3. import os
  4. import time

  5. class App:
  6.     def __init__(self, root):

  7.         frame = tk.Frame(root)
  8.         frame.pack()

  9.         self.Calc = tk.Button(frame, text="计算器", fg="blue", command=self.calc)
  10.         self.Calc.pack(side=tk.LEFT)

  11.         self.Notepad = tk.Button(frame, text="记事本", fg="black", command=self.notepad)
  12.         self.Notepad.pack(side=tk.LEFT)

  13.         self.Time = tk.Button(frame, text="时间", fg="red", command=self.time).pack()
  14.         self.Time.pack(side=tk.LEFT)

  15.     def calc(self):
  16.         os.system("calc")
  17.         
  18.     def notepad(self):
  19.         os.system("notepad")

  20.     def time(self):
  21.         top = Toplevel()
  22.         top.title("时间")
  23.         msg = Message(top, text="现在是:" + time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
  24.         msg.pack()

复制代码


运行后为什么会报错???
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-12-27 19:35:30 | 显示全部楼层
本帖最后由 heidern0612 于 2018-12-28 14:10 编辑

30行最后少个括号。

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-12-27 20:07:48 | 显示全部楼层
heidern0612 发表于 2018-12-27 19:35
30行最后少个括号。
  1. import tkinter as tk
  2. import sys
  3. import os
  4. import time

  5. class App:
  6.     def __init__(self, root):

  7.         frame = tk.Frame(root)
  8.         frame.pack()

  9.         self.Calc = tk.Button(frame, text="计算器", fg="blue", command=self.calc)
  10.         self.Calc.pack(side=tk.LEFT)

  11.         self.Notepad = tk.Button(frame, text="记事本", fg="black", command=self.notepad)
  12.         self.Notepad.pack(side=tk.LEFT)

  13.         self.Time = tk.Button(frame, text="时间", fg="red", command=self.time).pack()
  14.         self.Time(side=tk.LEFT)

  15.     def calc(self):
  16.         os.system("calc")
  17.         
  18.     def notepad(self):
  19.         os.system("notepad")

  20.     def time(self):
  21.         top = tk.Toplevel()
  22.         top.title("时间")
  23.         msg = tk.Message(top, text="现在是:" + time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
  24.         msg.pack()

  25. root = tk.Tk()
  26. app = App(root)

  27. root.mainloop()
复制代码

又出错了。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-12-27 20:14:13 | 显示全部楼层
去掉34行的(root)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-23 12:51

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表