- 浏览: 543032 次
- 性别:
- 来自: 北京-郑州
文章分类
最新评论
-
痛苦不忧伤:
非常简单清晰
java向上转型 -
fusionyu:
IndexWriter没有正常关闭,导致索引循环能修复不?怎么 ...
关于搜索开发过程中的总结 -
yong7356:
学习一下。。。。。。。
eclipse打jar包 -
Zengchen2:
讲得很实用
内部类使用场景二:实现回调函数 -
sun19890214:
mark下,一些能看懂,一些看不懂
关于搜索开发过程中的总结
To implement a menubar in wxPython we need to have three things. A wx.MenuBar, a wx.Menu and a wx.MenuItem.
1、创建一个MenuBar对象
menubar = wx.MenuBar()
2、创建一个菜单
file = wx.Menu()
file.Append(-1, 'Quit', 'Quit application')
The first parameter is the id of the menu item.
The second parameter is the name of the menu item.
The last parameter defines the short helpstring that is displayed on the statusbar
menubar.Append(file, '&File')
self.SetMenuBar(menubar)
3、添加MenuItem元素:
注意:
MenuItem Append(self, id, text, help, kind)
MenuItem AppendCheckItem(self, id, text, help)
MenuItem AppendItem(self, item)
MenuItem AppendMenu(self, id, text, submenu, help)
MenuItem AppendRadioItem(self, id, text, help)
MenuItem AppendSeparator(self)
Menu的append方法返回的都是MenuItem类型的,这就说明Menu是一个菜单列表,声明一个MenuItem,作为Menu的一个元素。
Append方法只是添加了一个普通的MenuItem元素,而AppendItem则是这样的:
menubar = wx.MenuBar()
file = wx.Menu()
#为菜单设置小图标
quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q')
quit.SetBitmap(wx.Bitmap('icons/exit.png'))
file.AppendItem(quit)
下面这段话是对AppendItem的一个说明:
If we want to add shortcuts and icons to our menus, we have to manually create a wx.MenuItem. So far we have created menuitems indirectly. The & character specifies an accelerator key. The following character is underlined. The actual shortcut is defined by the combination of characters. We have specified Ctrl + Q characters. So if we press Ctrl + Q, we close the application. We put a tab character between the & character and the shortcut. This way, we manage to put some space between them. To provide an icon for a menuitem, we call a SetBitmap() method. A manually created menuitem is appended to the menu by calling the AppendItem() method.
可以这样理解:
一个MenuBar可以放置多个Menu,一个Menu可以放置多个MenuItem作为其元素。
self.Bind(wx.EVT_MENU, self.OnQuit, Source)
第三个参数Source就是指定一个MenuItem本身,当然也可以通过id来制定一个元素。
4、子菜单:
file.AppendSeparator()
A menu separator is appended with the AppendSeparator() method.
imp = wx.Menu() imp.Append(-1, 'Import newsfeed list...') imp.Append(-1, 'Import bookmarks...') imp.Append(-1, 'Import mail...') file.AppendMenu(-1, 'I&mport', imp)
Creating a submenu is trivial.
First, we create a menu.
Then we append menu items.
A submenu is created by calling the AppenMenu() on the menu object.
5、其他样式的MenuItem
normal item
check item
radio item
6、Context menu------单击鼠标右键而产生的环境菜单
2>工具栏:
1、创建工具栏:
ToolBar一般利用wx.Frame的CreateToolBar方法来创建
toolbar = self.CreateToolBar()
toolbar.AddLabelTool(wx.ID_EXIT, '', wx.Bitmap('../icons/exit.png'))
toolbar.Realize()
After we have put our items to the toolbar, we call the Realize() method. Calling this method is not obligatory on Linux. On windows it is.
2、If we want to create more than one toolbars, we must do it differently.
vbox = wx.BoxSizer(wx.VERTICAL) toolbar1 = wx.ToolBar(self, -1) toolbar1.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/new.png')) toolbar1.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/open.png')) toolbar1.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/save.png')) toolbar1.Realize() toolbar2 = wx.ToolBar(self, -1) toolbar2.AddLabelTool(wx.ID_EXIT, '', wx.Bitmap('../icons/exit.png')) toolbar2.Realize() vbox.Add(toolbar1, 0, wx.EXPAND) vbox.Add(toolbar2, 0, wx.EXPAND) self.Bind(wx.EVT_TOOL, self.OnExit, id=wx.ID_EXIT) self.SetSizer(vbox)
3、Sometimes we need to create a vertical toolbar. Vertical toolbars are often seen in graphics applications like Inkscape or Xara Xtreme.
toolbar = self.CreateToolBar(wx.TB_VERTICAL) toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/select.gif')) toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/freehand.gif')) ...
4、In the following example, we will show, how we can enable and disable toolbar buttons. We will also see a separator line.
In our example, we have three toolbar buttons. One button is for exiting the application. The other two buttons are undo and redo buttons. They simulate undo/redo functionality in an application. (for a real example, see tips and tricks) We have 4 changes. The undo and redo butons are disabled accordingly.
self.toolbar.EnableTool(wx.ID_REDO, False) self.toolbar.AddSeparator()
In the beginning, the redo button is disabled. We do it by calling the EnableTool() method. We can create some logical groups within a toolbar. We can separate various groups of buttons by a small vertical line. To do this, we call the AddSeparator() method.
def OnUndo(self, event): if self.count > 1 and self.count <= 5: self.count = self.count - 1 if self.count == 1: self.toolbar.EnableTool(wx.ID_UNDO, False) if self.count == 4: self.toolbar.EnableTool(wx.ID_REDO, True)
We simulate undo and redo functionality. We have 4 changes. If there is nothing left to undo, the undo button is disabled. After undoing the first change, we enable the redo button. Same logic applies for the OnRedo() method.
发表评论
-
python下innodb的数据提交问题
2010-07-12 18:00 1946mysql数据库存储引擎从isam转移到了innodb 今天 ... -
Python解释执行原理
2010-04-21 11:00 7469谈到了Python语句的两种 ... -
python基础补习
2010-04-21 10:55 1567Python是一种解释性的 ... -
dbutils安装笔记以及mysql数据库操作问题
2010-04-02 11:05 4739dbutils安装笔记; tar -zxvf DBUt ... -
twisted单线程多任务
2010-04-02 10:10 2921关于单线程多任务刚 ... -
python 多线程 gil
2010-03-16 19:01 3199python里的多线程是单cpu ... -
dbutils,sqlobject,SQLAlchemy
2009-08-22 18:26 3473Python DBUtils 提供了稳固的、持久的到数据库的连 ... -
os.open当中的读写选项
2009-07-22 15:40 19861、读文件 读文本文件 input = open('dat ... -
JE API 闲聊实现
2009-06-12 18:29 1579注意:用到json-python进行json字符串的解析,需要 ... -
httplib,urllib和urllib2的了解学习
2009-06-12 15:30 9659httplib — HTTP protocol client: ... -
struct的pack和unpack方法
2009-06-03 23:55 18653这两天做TCP协议,数据 ... -
针对twisted--Defered的单线程多任务的理解
2009-06-03 23:13 2740从网上找了不少关于twis ... -
reactor.ConnectTCP的源码分析
2009-06-03 15:05 5298reactor.ConnectTCP(host,port,xx ... -
twisted异步机制--Deferred
2009-06-03 14:44 9153Deferred:提供了让程序查 ... -
Twisted基本模型
2009-06-03 14:27 5459一、Twisted基本模型Twisted 网络编程框架是一种基 ... -
并发编程的概念知识以及twisted的引出
2009-06-03 10:27 1674并发编程介绍:要完成某些计算任务经常需要不少时间,其原因有两点 ... -
使用wxPython实现mail的简单客户端
2009-05-22 15:22 2198本程序的目的是:结合当前所学习的wxPython的理论知识,同 ... -
wxPython的Core组件--其他sizer
2009-05-14 22:42 14501、WX.GridSizer: wx.GridSizer(i ... -
wxPython的Core组件--BoxSizer
2009-05-13 12:32 4723wx.BoxSizer: box = wx.BoxSiz ... -
wxPython的windows构件的具体学习
2009-05-10 16:50 1957按照前面的总结思路 ...
相关推荐
用户可以通过运行这些文件来安装对应的wxPython版本,它们会将必要的库文件和组件添加到系统中,使得Python项目能够导入并使用wxPython。 **使用wxPython** 使用wxPython开发应用程序时,首先需要在Python环境中...
wxPython2.8-win32-unicode-2.8.11.0-py27.exe
【标题】"wxPython2.8-win64-unicode-2.8.12.1-py27" 指的是一个特定版本的wxPython库的安装程序,适用于64位Windows操作系统,并且支持Unicode编码。这个版本是2.8.12.1,针对Python 2.7解释器设计。 【描述】中的...
super().__init__(None, -1, 'My First wxPython App', size=(300, 200)) self.Show() if __name__ == '__main__': app = wx.App() frame = MyFrame() app.MainLoop() ``` 这段代码会创建一个基本的窗口,...
通过 wxPython,Python 开发者可以创建原生、高性能的桌面应用程序,无需学习不同平台的原生编程接口。 **wxPython 版本信息** 题目中的“wxPython3.0-win64-3.0.2.0-py27”表示这是一个适用于 Python 2.7 的 ...
This file includes two exe file for wxpython which are file for installation and documents for reference. IT'S REQUIRED thatPYTHON IS INSTALLED IN your computer.
在描述中提到的"robotframework环境搭建所需相关组件",可能指的是使用wxPython作为Robot Framework的GUI测试库,如`RIDE (Robot Framework Integrated Development Environment)`,它是一个用wxPython编写的测试...
wxPython2.8-win32-docs-demos-2.8.12.1 wxPython2.8-win32-docs-demos-2.8.12.1 wxPython2.8-win32-docs-demos-2.8.12.1 wxPython2.8-win32-docs-demos-2.8.12.1 wxPython2.8-win32-docs-demos-2.8.12.1 wxPython...
wxPython 就是将 wxWidgets 的功能包装成 Python 可用的形式,使得 Python 开发者可以利用这一强大的 GUI 工具,而无需深入学习 C++。 2. **Unicode 支持** "unicode" 在文件名中表示该版本的 wxPython 支持 ...
This document will help explain some of the major changes in wxPython 2.6 since the 2.4 series and let you know what you need to do to adapt your programs to those changes. Be sure to also check in ...
wxPython3.0-win64-3.0.0.0-py27 方便大家下载不成功的时候
通过阅读文档,开发者可以学习如何有效地组织窗口,如何响应用户交互,以及如何利用wxPython提供的各种组件构建复杂的用户界面。 示例程序部分则是实际应用wxPython库的实例,通常包括各种功能和组件的演示。这些...
python, 安装包, 来下载试试把, wxPython2.8-win32-unicode-2.8.4.0-py25.exe wxPython2.8-win32-unicode-2.8.4.0-py25.exe
1. **主要特点**:wxPython具有丰富的控件集,包括对话框、菜单、工具栏、滚动条等,支持事件处理和布局管理。它的API设计友好,易于学习,同时也支持面向对象的编程方式。 2. **Unicode支持**:"unicode"标识表示...