wxpython初学者(三)
来源:互联网 发布:一搜网络 编辑:程序博客网 时间:2024/06/07 08:33
这几天一直趴在wxpython中,发现还是很有意思的,不过有些对于目前的我感觉还是太陌生了,下午幸亏回眸那一下顿悟了,才没有去上网休息休息,坚持下去总会看到自己想要的,我应该还是多练习吧,我一直用sublime编写,这个编辑器还是不错的,有些是我乱加的,本来想截图的的,可是还要装什么scrot截图工具太麻烦了。对于下面的代码主要是gridbagsizer那里的,
<span style="font-size:18px;">#!/usr/bin python#coding:utf-8#wx.gridbagsizerimport wxclass Example(wx.Frame): def __init__(self,parent,title): super(Example,self).__init__(parent,title=title,size=(320,200)) self.InitUI() self.Centre() self.Show() def InitUI(self): panel = wx.Panel(self) sizer = wx.GridBagSizer(4,4) text = wx.StaticText(panel,label= "Rename to") sizer.Add(text,pos=(0,0),flag=wx.TOP | wx.LEFT | wx.BOTTOM ,border=5) tc = wx.TextCtrl(panel) sizer.Add(tc,pos=(0,1),span=(1,5),flag=wx.EXPAND | wx.LEFT | wx.RIGHT,border= 5) #sizer.Add(tc,pos=(1,0),span=(1,5),flag=wx.EXPAND | wx.LEFT | wx.RIGHT,border= 5) buttonOK = wx.Button(panel,label ="OK",size=(90,28)) self.Bind(wx.EVT_BUTTON,self.OnCloseMe1,buttonOK) buttonClose = wx.Button(panel,label="Close",size =(90,28)) self.Bind(wx.EVT_BUTTON,self.OnCloseMe2,buttonClose) sizer.Add(buttonOK,pos= (3,3)) sizer.Add(buttonClose,pos=(3,4),flag = wx.RIGHT | wx.BOTTOM ,border = 5) sizer.AddGrowableRow(2) sizer.AddGrowableCol(1) panel.SetSizerAndFit(sizer) def OnCloseMe1(self, event): dlg = wx.MessageDialog(None, u"消息对话框测试", u"标题信息", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.Close(True) dlg.Destroy() def OnCloseMe2(self,event): self.Close() if __name__ == '__main__': app = wx.App() Example(None,title="GridBagSizer") app.MainLoop()</span>
<span style="font-size:18px;">#!/usr/bin python#coding:utf-8#wxgridbagsizerimport wxclass Example(wx.Frame): def __init__(self,parent,title): super(Example,self).__init__(parent,title=title,size = (300,250)) self.InitUI() self.Centre() self.Show() def InitUI(self): sizer = wx.GridBagSizer(10,10) sizer.Add(wx.Button(self,-1,"Button1"),(0,0),wx.DefaultSpan,wx.ALL,35) sizer.Add(wx.Button(self,-1,"Button2"),(1,1),(1,7),wx.EXPAND) sizer.Add(wx.Button(self,-1,"Button3"),(6,6),(3,3),wx.EXPAND) sizer.Add(wx.Button(self,-1,"Button4"),(3,0),(1,1),wx.ALIGN_CENTER) sizer.Add(wx.Button(self,-1,"Button5"),(4,0),(1,1),wx.ALIGN_LEFT) sizer.Add(wx.Button(self,-1,"Button6"),(5,0),(1,1),wx.ALIGN_RIGHT) sizer.AddGrowableRow(6) sizer.AddGrowableCol(6) self.SetSizerAndFit(sizer)def main(): app = wx.App() Example(None,title="GridBagSizer") app.MainLoop()if __name__ == '__main__': main()</span>
下面的这个gridsizer仅仅只是做了向一个计算器的样子,并没有写事件驱动和后面的程序,等学的差不多在说吧
<span style="font-size:18px;">#!/usr/bin python#coding:utf-8#wx.GridSizerimport wxclass Example(wx.Frame): def __init__(self,parent,title): super(Example,self).__init__(parent,title=title,size=(300,250)) self.InitUI() self.Centre() self.Show() def InitUI(self): menubar = wx.MenuBar() fileMenu = wx.Menu() menubar.Append(fileMenu,"&file") self.SetMenuBar(menubar) vbox = wx.BoxSizer(wx.VERTICAL) self.display = wx.TextCtrl(self,style =wx.TE_RIGHT) vbox.Add(self.display,flag = wx.EXPAND | wx.TOP | wx.BOTTOM,border = 5) gs = wx.GridSizer(4,4,5,5) gs.AddMany([(wx.Button(self,label = 'Cls'),0,wx.EXPAND), (wx.Button(self,label = 'Bck'),0,wx.EXPAND), (wx.StaticText(self),wx.EXPAND), (wx.Button(self,label = 'Close'),0,wx.EXPAND), (wx.Button(self,label = '7'),0,wx.EXPAND), (wx.Button(self,label = '8'),0,wx.EXPAND), (wx.Button(self,label = '9'),0,wx.EXPAND), (wx.Button(self,label = '/'),0,wx.EXPAND), (wx.Button(self,label = '4'),0,wx.EXPAND), (wx.Button(self,label = '5'),0,wx.EXPAND), (wx.Button(self,label = '6'),0,wx.EXPAND), (wx.Button(self,label = '*'),0,wx.EXPAND), (wx.Button(self,label = '1'),0,wx.EXPAND), (wx.Button(self,label = '2'),0,wx.EXPAND), (wx.Button(self,label = '3'),0,wx.EXPAND), (wx.Button(self,label = '-'),0,wx.EXPAND), (wx.Button(self,label = '0'),0,wx.EXPAND), (wx.Button(self,label = '.'),0,wx.EXPAND), (wx.Button(self,label = '='),0,wx.EXPAND), (wx.Button(self,label = '+'),0,wx.EXPAND)]) vbox.Add(gs,proportion=1,flag=wx.EXPAND) self.SetSizer(vbox) if __name__ == '__main__': app = wx.App() Example(None,title="caculator") app.MainLoop()</span>
0 0
- wxpython初学者(三)
- wxpython初学者(一)
- wxpython初学者(二)
- wxpython初学者(三) 之flexgirdsizer,TextEntryDialog,SingleChoiceDialog
- wxpython初学者(五)之 Skip()
- wxpython初学者(四)之 事件驱动
- wxPython学习笔记(三)
- wxPython学习笔记三
- 初学者学数据结构(三)
- TIJ swot_JAVA的初学者(三)
- .NET初学者架构设计指南(三)
- Gradle用户指南之初学者教程(三)
- 初学者之php基础(三)
- java初学者(三)final 关键字
- python初学者快速入门(三)字符串
- 初学者眼中的的Angularjs(三)
- wxPython(一)
- wxPython学习(一)
- 在线考试系统——测试计划 详细测试报告——testlink
- java 第十天 面向对象
- NOIP2010解题报告
- JavaScript学习笔记7-附录(回掉函数)
- 对数组的操作
- wxpython初学者(三)
- hdu 1500 Chopsticks(动态规划)
- okio分析
- Java版本的一些问题
- 编写SQL查询,列出租住不止一套公寓的承租人
- 内省和BeanUtils框架3
- hdu 5183 Negative and Positive (NP)
- mantis 使用__基础——学籍管理系统
- vs2010+opencv3.0.0 环境配置 (以及配置技巧)