所以最近我一直在尝试学习 wxpython,但我一直收到这个错误,我知道这个错误说没有足够的参数,但是在计算函数下它有两个参数。
import wx
import math
class game(wx.Frame):
def __init__(self,parrent,id):
c3 = "0"
wx.Frame.__init__(self,parrent,id,"Form", size=(250,160))
panel=wx.Panel(self)
box2=wx.TextEntryDialog(None, "Input b", "Pythagorean theorem", "")
if box2.ShowModal()==wx.ID_OK:
b=box2.GetValue()
box1=wx.TextEntryDialog(None, "Input A", "Pythagorean theorem", "")
if box1.ShowModal()==wx.ID_OK:
a=box1.GetValue()
def compute(self, event):
a2=int(a)**2
b2=int(b)**2
c = a2 + b2
c2=math.sqrt(c)
c3=str(c2)
button=wx.Button(panel, label="Compute",pos=(90,70), size=(60,40))
self.Bind(wx.EVT_BUTTON, compute, button)
wx.StaticText(panel, -1, c3, (10,10))
if __name__=="__main__":
app=wx.PySimpleApp()
frame=game(parrent=None, id=-1)
frame.Show()
app.MainLoop()
错误:“compute() 正好采用 2 个参数(给定 1 个)”