在這裏,在我的面板打印是我的代碼爲什麼我不能讓靜態文本使用wxPython的
import wx
class justin(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'frame', size=(800, 500))
panel=wx.Panel(self)
panel.SetBackgroundColour("red")
self.box1=wx.TextCtrl(panel, -1, "type number")
self.box2=wx.TextCtrl(panel, -1, "type number")
self.box1.SetBackgroundColour("gray")
self.box2.SetBackgroundColour("gray")
siz=wx.BoxSizer(wx.VERTICAL)
siz.Add(self.box1, 1)
siz.Add(self.box2, 1)
panel.SetSizer(siz)
button=wx.Button(panel, label="enter", pos=(250, 200), size=(100, 50))
self.Bind(wx.EVT_BUTTON, self.yesitstrue, button)
def yesitstrue(self, event):
a=(float(self.box1.GetValue()))
b=(float(self.box2.GetValue()))
answer = a+b
wx.StaticText(self.panel,id, answer, pos=(200, 100))
if __name__=='__main__':
app=wx.PySimpleApp()
frame=justin(parent=None, id=-1)
frame.Show()
app.MainLoop()
什麼,我試圖做的是從兩個文本框獲取文本,並將其添加然後打印以GUI格式。當程序到達靜態文本部分時,它說面板不存在。 我想任何幫助,如果發現任何其他錯誤,請讓我知道,因爲我真的需要它。
所以現在我沒有得到這個錯誤了,但我得到類型錯誤調用
wx.StaticText
:在方法「new_StaticText」,期望的參數類型2「詮釋」我從來沒有見過這個錯誤,不知道它想要我做什麼 – user1108980 2011-12-22 13:47:14在編輯答案中解釋了一些更多的問題。這一次,你應該得到你正在尋找的結果。 – jcollado 2011-12-22 18:48:49
謝謝你們,我只看過jcollado的第一篇文章,並通過搞亂程序學習了其餘的內容 – user1108980 2011-12-30 02:12:15