def bu_mul(self, event): # wxGlade: MyFrame.<event_handler>
self.num1=self.text_ctrl_1.GetValue()
self.op="x"
self.text_ctrl_1.Clear()
event.Skip()
def bu_clear(self, event): # wxGlade: MyFrame.<event_handler>
self.text_ctrl_1.Clear()
event.Skip()
def bu0(self, event): # wxGlade: MyFrame.<event_handler>
self.text_ctrl_1.AppendText("0")
event.Skip()
def bu_chu(self, event): # wxGlade: MyFrame.<event_handler>
self.num1=self.text_ctrl_1.GetValue()
self.op="/"
self.text_ctrl_1.Clear()
event.Skip()
def bu_result(self, event): # wxGlade: MyFrame.<event_handler>
self.num2=self.text_ctrl_1.GetValue()
num1=int(self.num1)
num2=int(self.num2)
if self.op=="+":
self.text_ctrl_1.SetValue(str(num1+num2))
elif self.op=="-":
self.text_ctrl_1.SetValue(str(num1-num2))
elif self.op=="x":
self.text_ctrl_1.SetValue(str(num1*num2))
elif self.op=="/":
self.text_ctrl_1.SetValue(str(num1/num2))
event.Skip()
# end of class MyFrame
if __name__ == "__main__":
app=wx.App(False)
myframe=MyFrame(None)
app.MainLoop()
按钮的ID,名称什么的我基本都是用wxGlade自动生成的,懒的改了。。。
没有做什么美化,只是为了练练手,给张图:
《Python核心编程 第二版》.(Wesley J. Chun ).[高清PDF中文版]
《Python开发技术详解》.( 周伟,宗杰).[高清PDF扫描版+随书视频+代码]
在Ubuntu下用Python搭建桌面算法交易研究环境