wx.Frame
wx.Frame
A frame is a window whose size and position can (usually) be changed by the user.
It usually has thick borders and a title bar, and can optionally contain a menu bar, toolbar and status bar. A frame can contain any window that is not a frame or dialog.
A frame that has a status bar and toolbar, created via the CreateStatusBar and CreateToolBar functions, manages these windows and adjusts the value returned by GetClientSize to reflect the remaining size available to application windows.
Default event processing
wx.Frame processes the following events:
wxEVT_SIZE:if the frame has exactly one child window, not counting the status and toolbar, this child is resized to take the entire frame client area. If two or more windows are present, they should be laid out explicitly either by manually handlingwxEVT_SIZEor using sizers;wxEVT_MENU_HIGHLIGHT:the default implementation displays the help string associated with the selected item in the first pane of the status bar, if there is one.
Window Styles
This class supports the following styles:
wx.DEFAULT_FRAME_STYLE: Defined aswx.MINIMIZE_BOX|wx.MAXIMIZE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN.wx.ICONIZE: Display the frame iconized (minimized). Windows only.wx.CAPTION: Puts a caption on the frame. Notice that this flag is required bywx.MINIMIZE_BOX,wx.MAXIMIZE_BOXandwx.CLOSE_BOXon most systems as the corresponding buttons cannot be shown if the window has no title bar at all. I.e. ifwx.CAPTIONis not specified those styles would be simply ignored.wx.MINIMIZE: Identical towx.ICONIZE. Windows only.wx.MINIMIZE_BOX: Displays a minimize box on the frame.wx.MAXIMIZE: Displays the frame maximized. Windows and GTK+ only.wx.MAXIMIZE_BOX: Displays a maximize box on the frame. Notice that under wxGTKwx.RESIZE_BORDERmust be used as well or this style is ignored.wx.CLOSE_BOX: Displays a close box on the frame.wx.STAY_ON_TOP: Stay on top of all other windows, see alsowx.FRAME_FLOAT_ON_PARENT.wx.SYSTEM_MENU: Displays a system menu containing the list of various windows commands in the window title bar. Unlikewx.MINIMIZE_BOX,wx.MAXIMIZE_BOXandwx.CLOSE_BOXstyles this style can be used withoutwx.CAPTION, at least under Windows, and makes the system menu available without showing it on screen in this case. However it is recommended to only use it together withwx.CAPTIONfor consistent behaviour under all platforms.wx.RESIZE_BORDER: Displays a resizable border around the window.wx.FRAME_TOOL_WINDOW: Causes a frame with a small title bar to be created; the frame does not appear in the taskbar under Windows or GTK+.wx.FRAME_NO_TASKBAR: Creates an otherwise normal frame but it does not appear in the taskbar under Windows or GTK+ (note that it will minimize to the desktop window under Windows which may seem strange to the users and thus it might be better to use this style only withoutwx.MINIMIZE_BOXstyle). In wxGTK, the flag is respected only if the window manager supports_NET_WM_STATE_SKIP_TASKBARhint.wx.FRAME_FLOAT_ON_PARENT: The frame will always be on top of its parent (unlikewx.STAY_ON_TOP). A frame created with this style must have a notNoneparent.wx.FRAME_SHAPED: Windows with this style are allowed to have their shape changed with theSetShapemethod.
The default frame style is for normal, resizable frames. To create a frame which cannot be resized by user, you may use the following combination of styles:
style = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
Window Extra Styles
See also the Window Styles. This class supports the following extra styles:
wx.FRAME_EX_CONTEXTHELP: Under Windows, puts a query button on the caption. When pressed, Windows will go into a context-sensitive help mode and wxWidgets will send awxEVT_HELPevent if the user clicked on an application window. Note that this is an extended style and must be set by calling SetExtraStyle before Create is called (two-step construction). You cannot use this style together withwx.MAXIMIZE_BOXorwx.MINIMIZE_BOX, so you should usewx.DEFAULT_FRAME_STYLE~ (wx``wx.MINIMIZE_BOX`` |wx.MAXIMIZE_BOX) for the frames having this style (the dialogs don’t have a minimize or a maximize box by default)wx.FRAME_EX_METAL: On Mac OS X, frames with this style will be shown with a metallic look. This is an extra style.
Events Emitted by this Class
Event macros for events emitted by this class:
- EVT_CLOSE: Process a
wxEVT_CLOSE_WINDOWevent when the frame is being closed by the user or programmatically (seewx.Window.Close). The user may generate this event clicking the close button (typically the ‘X’ on the top-right of the title bar) if it’s present (see theCLOSE_BOXstyle). See wx.CloseEvent. - EVT_ICONIZE: Process a
wxEVT_ICONIZEevent. See wx.IconizeEvent. - EVT_MENU_OPEN: A menu is about to be opened. See wx.MenuEvent.
- EVT_MENU_CLOSE: A menu has been just closed. See wx.MenuEvent.
- EVT_MENU_HIGHLIGHT: The menu item with the specified id has been highlighted: used to show help prompts in the status bar by wx.Frame. See wx.MenuEvent.
- EVT_MENU_HIGHLIGHT_ALL: A menu item has been highlighted, i.e. the currently selected menu item has changed. See wx.MenuEvent.
Note
An application should normally define an wx.CloseEvent handler for the frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
See also
wx.MDIParentFrame, wx.MDIChildFrame, wx.MiniFrame, wx.Dialog
Class Hierarchy
Inheritance diagram for class Frame:
Control Appearance
wxMSW
wxMAC
wxGTK
Known Subclasses
wx.aui.AuiMDIParentFrame, DocChildFrame , DocParentFrame ,wx.html.HtmlHelpFrame, wx.MDIChildFrame, wx.MDIParentFrame, wx.MiniFrame,wx.PreviewFrame, wx.adv.SplashScreen
Methods Summary
__init__ |
Default constructor. |
Centre |
Centres the frame on the display. |
Create |
Used in two-step frame construction. |
CreateStatusBar |
Creates a status bar at the bottom of the frame. |
CreateToolBar |
Creates a toolbar at the top or left of the frame. |
GetClientAreaOrigin |
Returns the origin of the frame client area (in client coordinates). |
GetMenuBar |
Returns a pointer to the menubar currently associated with the frame (if any). |
GetStatusBar |
Returns a pointer to the status bar currently associated with the frame (if any). |
GetStatusBarPane |
Returns the status bar pane used to display menu and toolbar help. |
GetToolBar |
Returns a pointer to the toolbar currently associated with the frame (if any). |
OnCreateStatusBar |
Virtual function called when a status bar is requested by CreateStatusBar . |
OnCreateToolBar |
Virtual function called when a toolbar is requested by CreateToolBar . |
PopStatusText |
|
ProcessCommand |
Simulate a menu command. |
PushStatusText |
|
SetMenuBar |
Tells the frame to show the given menu bar. |
SetStatusBar |
Associates a status bar with the frame. |
SetStatusBarPane |
Set the status bar pane used to display menu and toolbar help. |
SetStatusText |
Sets the status bar text and redraws the status bar. |
SetStatusWidths |
Sets the widths of the fields in the status bar. |
SetToolBar |
Associates a toolbar with the frame. |
Properties Summary
MenuBar |
See GetMenuBar and SetMenuBar |
StatusBar |
See GetStatusBar and SetStatusBar |
StatusBarPane |
See GetStatusBarPane and SetStatusBarPane |
ToolBar |
See GetToolBar and SetToolBar |
Class API
- class
wx.Frame(TopLevelWindow) -
Possible constructors:
Frame() Frame(parent, id=ID_ANY, title="", pos=DefaultPosition,
size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr)A frame is a window whose size and position can (usually) be changed by the user.
Methods
__init__(self, *args, **kw)-
Overloaded Implementations:
__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, title=””, pos=DefaultPosition, size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr)
Constructor, creating the window.
Parameters: - parent (wx.Window) – The window parent. This may be, and often is,
None. If it is notNone, the frame will be minimized when its parent is minimized and restored when it is restored (although it will still be possible to minimize and restore just this frame itself). - id (wx.WindowID) – The window identifier. It may take a value of -1 to indicate a default value.
- title (string) – The caption to be displayed on the frame’s title bar.
- pos (wx.Point) – The window position. The value DefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform.
- size (wx.Size) – The window size. The value DefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform.
- style (long) – The window style. See wx.Frame class description.
- name (string) – The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.
Note
For Motif,
MWM(the Motif Window Manager) should be running for any window styles to work (otherwise all styles take effect).See also
- parent (wx.Window) – The window parent. This may be, and often is,
Centre(self, direction=BOTH)-
Centres the frame on the display.
Parameters: direction (int) – The parameter may be wx.HORIZONTAL,wx.VERTICALorwx.BOTH.
Create(self, parent, id=ID_ANY, title="", pos=DefaultPosition, size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr)-
Used in two-step frame construction.
See wx.Frame for further details.
Parameters: Return type: bool
CreateStatusBar(self, number=1, style=STB_DEFAULT_STYLE, id=0, name=StatusBarNameStr)-
Creates a status bar at the bottom of the frame.
Parameters: - number (int) – The number of fields to create. Specify a value greater than 1 to create a multi-field status bar.
- style (long) – The status bar style. See wx.StatusBar for a list of valid styles.
- id (wx.WindowID) – The status bar window identifier. If -1, an identifier will be chosen by wxWidgets.
- name (string) – The status bar window name.
Return type: Returns: A pointer to the status bar if it was created successfully,
Noneotherwise.Note
The width of the status bar is the whole width of the frame (adjusted automatically when resizing), and the height and text size are chosen by the host windowing system.
See also
CreateToolBar(self, style=TB_DEFAULT_STYLE, id=ID_ANY, name=ToolBarNameStr)-
Creates a toolbar at the top or left of the frame.
Parameters: - style (long) – The toolbar style. See wx.ToolBar for a list of valid styles.
- id (wx.WindowID) – The toolbar window identifier. If -1, an identifier will be chosen by wxWidgets.
- name (string) – The toolbar window name.
Return type: Returns: A pointer to the toolbar if it was created successfully,
Noneotherwise.Note
By default, the toolbar is an instance of wx.ToolBar. To use a different class, override
OnCreateToolBar. When a toolbar has been created with this function, or made known to the frame withwx.Frame.SetToolBar, the frame will manage the toolbar position and adjust the return value fromwx.Window.GetClientSizeto reflect the available space for application windows. Under PocketPC, you should always use this function for creating the toolbar to be managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, create a wx.ToolBar as usual.See also
GetClientAreaOrigin(self)-
Returns the origin of the frame client area (in client coordinates).
It may be different from (0, 0) if the frame has a toolbar.
Return type: wx.Point
GetMenuBar(self)-
Returns a pointer to the menubar currently associated with the frame (if any).
Return type: wx.MenuBar See also
GetStatusBar(self)-
Returns a pointer to the status bar currently associated with the frame (if any).
Return type: wx.StatusBar See also
GetStatusBarPane(self)-
Returns the status bar pane used to display menu and toolbar help.
Return type: int See also
GetToolBar(self)-
Returns a pointer to the toolbar currently associated with the frame (if any).
Return type: wx.ToolBar See also
OnCreateStatusBar(self, number, style, id, name)-
Virtual function called when a status bar is requested by
CreateStatusBar.Parameters: - number (int) – The number of fields to create.
- style (long) – The window style. See wx.StatusBar for a list of valid styles.
- id (wx.WindowID) – The window identifier. If -1, an identifier will be chosen by wxWidgets.
- name (string) – The window name.
Return type: Returns: A status bar object.
Note
An application can override this function to return a different kind of status bar. The default implementation returns an instance of wx.StatusBar.
See also
OnCreateToolBar(self, style, id, name)-
Virtual function called when a toolbar is requested by
CreateToolBar.Parameters: - style (long) – The toolbar style. See wx.ToolBar for a list of valid styles.
- id (wx.WindowID) – The toolbar window identifier. If -1, an identifier will be chosen by wxWidgets.
- name (string) – The toolbar window name.
Return type: Returns: A toolbar object.
Note
An application can override this function to return a different kind of toolbar. The default implementation returns an instance of wx.ToolBar.
See also
PopStatusText(self, number=0)-
Parameters: number (int) –
ProcessCommand(self, id)-
Simulate a menu command.
Parameters: id (int) – The identifier for a menu item. Return type: bool
PushStatusText(self, text, number=0)-
Parameters: - text (string) –
- number (int) –
SetMenuBar(self, menuBar)-
Tells the frame to show the given menu bar.
Parameters: menuBar (wx.MenuBar) – The menu bar to associate with the frame. Note
If the frame is destroyed, the menu bar and its menus will be destroyed also, so do not delete the menu bar explicitly (except by resetting the frame’s menu bar to another frame or
None). Under Windows, a size event is generated, so be sure to initialize data members properly before callingSetMenuBar. Note that on some platforms, it is not possible to call this function twice for the same frame object.See also
SetStatusBar(self, statusBar)-
Associates a status bar with the frame.
If statusBar is
None, then the status bar, if present, is detached from the frame, but not deleted.Parameters: statusBar (wx.StatusBar) – See also
SetStatusBarPane(self, n)-
Set the status bar pane used to display menu and toolbar help.
Using -1 disables help display.
Parameters: n (int) –
SetStatusText(self, text, number=0)-
Sets the status bar text and redraws the status bar.
Parameters: - text (string) – The text for the status field.
- number (int) – The status field (starting from zero).
Note
Use an empty string to clear the status bar.
See also
SetStatusWidths(self, widths)-
Sets the widths of the fields in the status bar.
Parameters: widths (list of integers) – Must contain an array of n integers, each of which is a status field width in pixels. A value of -1 indicates that the field is variable width; at least one field must be -1. You should delete this array after calling SetStatusWidths.
SetToolBar(self, toolBar)-
Associates a toolbar with the frame.
Parameters: toolBar (wx.ToolBar) –
Properties
MenuBar-
See
GetMenuBarandSetMenuBar
StatusBar-
See
GetStatusBarandSetStatusBar
StatusBarPane-
See
GetStatusBarPaneandSetStatusBarPane
ToolBar-
See
GetToolBarandSetToolBar
wx.Frame的更多相关文章
- wx.ListCtrl简单使用例子
效果图: 示例代码: #! /usr/bin/env python #coding=utf-8 import wx import sys packages = [('jessica alba', 'p ...
- wxPython安装错误问题:No module named wx
今天心血来潮安装wxPython,本机win7,且已经安装Python,版本为2.7.3,然后IDE使用的PyCharm,然后wxPython下载的版本为:wxPython2.8-win32-unic ...
- wxPython 基本框架与运行原理 -- App 与 Frame
<wxPython in Action> chapter 1.2 笔记 wxPython 是 wxWidgets 的 Python 实现,“w” for Microsoft Windows ...
- PIL Image 转成 wx.Image、wx.Bitmap
import wx from PIL import Image def ConvertToWxImage(): pilImage = Image.open('1.png') image = wx.Em ...
- wx
wx The classes in this module are the most commonly used classes for wxPython, which is why they hav ...
- wx.Dialog
wx.Dialog A dialog box is a window with a title bar and sometimes a system menu, which can be moved ...
- wx.ToolBar
wx.ToolBar A toolbar is a bar of buttons and/or other controls usually placed below the menu bar in ...
- wx模块小实例
功能介绍: 查询数据库表数据,提取数据并显示 main.py(执行文件) #coding:gbk __author__ = 'Hito' import querySmscode import wx c ...
- Python中wx.FlexGridSizer
FlexGridSizer是GridSizer的一个更灵活的版本.它与标准的GridSizer几乎相同,除了下面3点例外: 1.每行和每列可以有各自的尺寸.2.默认情况下,当尺寸调整时,它行和列整体改 ...
随机推荐
- Inno Setup 插件 CallbackCtrl V1.1 (回调函数插件)
原文 http://restools.hanzify.org/article.asp?id=101 VC 重现 InnoCallback 的功能. Version 1.1修正在某些 Windows 平 ...
- WIN_2003_SP2.iso VMware 不能进行网络访问的处理
1.打开IE发现不能上网的问题 ping命令 发现确实是网络不通: 2.关闭虚拟机设置网络适配器 3.ping命令验证是否设置成功 4.打开IE访问百度
- spring 定时任务(3)--配置多个定时任务
<!-- 定义调用对象和调用对象的方法 --> <!-- 定时任务 A start --> <bean id="jobtask" class=&quo ...
- 有关ios中images.xcassets的导入图片等命名问题
最近遇到一个问题,就是在设置启动图片的时候,把启动图片命名设置为了xxx@2x.png, 然后应用死活没有显示启动图片,调试了很久,才发现是因为文件命名的原因. 1. 如果在图片的下方有2x或3x的标 ...
- 数字温湿度传感器DHT11--操作源代码
//IO定义 #define P_DataIN_DHT11 PB0_IN #define P_DataOUT_DHT11 PB0_OUT //宏定义 #define BSET_DHT11 P_Data ...
- js 检验密码强度
html 代码如下: <!DOCTYPE HTML> <html lang="en"> <head> <meta charset=&quo ...
- 【概率论】【POJ 3682】【King Arthur's Birthday Celebration】
题意:进行翻硬币实验,若k次向上则结束,进行第n次实验需花费2*n-1的费用,询问期望结束次数及期望结束费用 设F[i]为第i次结束时的概率 F[i]= c(i-1,k-1)*p^k*(1-p)^( ...
- cql
创建keyspace :CREATE KEYSPACE keyspace1 WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': ...
- VS2010 添加资源文件后,出现 “LNK1123: 转换到 COFF 期间失败: 文件无效或损坏”错误
1>LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 解决方法: 一.1.点击“项目”-->“属性”-->“清单工具” 2.‘输入 ...
- LinkList的实现
public class MyLinkedList<AnyType> implements Iterable<AnyType> { @Override public Itera ...