我想在 Tkinter 中制作一个简单的计算器。我有几行代码,想检查它是否有效。但后来我收到这样的错误:“Calc(T.Tk()).run() 这个构造函数不接受任何参数”。这是我的代码:
# -*- coding: utf-8 -*-
import Tkinter as T
from Tkinter import W, E
class Calc():
def _init_(self,main):
self.main = main
self.main.title('Calculator')
self.main.config(bg = 'black')
self.e = T.Entry(self.main, justify = 'center')
self.e.grid(row = 0, columnspan = 5, sticky = W + E)
self.e.pack()
def run(self):
self.main.mainloop()
Calc(T.Tk()).run()