博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
wx.Frame
阅读量:4953 次
发布时间:2019-06-12

本文共 14127 字,大约阅读时间需要 47 分钟。

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  and  functions, manages these windows and adjusts the value returned by GetClientSize to reflect the remaining size available to application windows.

 Default event processing

 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 handling wxEVT_SIZE or 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 as wx.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 by wx.MINIMIZE_BOXwx.MAXIMIZE_BOX and wx.CLOSE_BOX on most systems as the corresponding buttons cannot be shown if the window has no title bar at all. I.e. if wx.CAPTION is not specified those styles would be simply ignored.
  • wx.MINIMIZE: Identical to wx.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 wxGTK wx.RESIZE_BORDER must 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 also wx.FRAME_FLOAT_ON_PARENT.
  • wx.SYSTEM_MENU: Displays a system menu containing the list of various windows commands in the window title bar. Unlike wx.MINIMIZE_BOXwx.MAXIMIZE_BOX and wx.CLOSE_BOX styles 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 with wx.CAPTION for 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 without wx.MINIMIZE_BOX style). In wxGTK, the flag is respected only if the window manager supports _NET_WM_STATE_SKIP_TASKBAR hint.
  • wx.FRAME_FLOAT_ON_PARENT: The frame will always be on top of its parent (unlike wx.STAY_ON_TOP). A frame created with this style must have a not None parent.
  • wx.FRAME_SHAPED: Windows with this style are allowed to have their shape changed with the SetShape method.

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 . 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 a wxEVT_HELP event 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 with wx.MAXIMIZE_BOX orwx.MINIMIZE_BOX, so you should use wx.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_WINDOW event when the frame is being closed by the user or programmatically (see  ). 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 the CLOSE_BOX style). See .
  • EVT_ICONIZE: Process a wxEVT_ICONIZE event. See .
  • EVT_MENU_OPEN: A menu is about to be opened. See .
  • EVT_MENU_CLOSE: A menu has been just closed. See .
  • EVT_MENU_HIGHLIGHT: The menu item with the specified id has been highlighted: used to show help prompts in the status bar by . See .
  • EVT_MENU_HIGHLIGHT_ALL: A menu item has been highlighted, i.e. the currently selected menu item has changed. See .

Note

 

An application should normally define an  handler for the frame to respond to system close events, for example so that related data and subwindows can be cleaned up.

See also

 

, , , 

 

 Class Hierarchy

 Inheritance diagram for class 
Frame:

 

Inheritance diagram of Frame

 

 

 Control Appearance

 
wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK

 

 Known Subclasses

DocChildFrame , DocParentFrame ,, , , ,, 

 

 Methods Summary

Default constructor.
Centres the frame on the display.
Used in two-step frame construction.
Creates a status bar at the bottom of the frame.
Creates a toolbar at the top or left of the frame.
Returns the origin of the frame client area (in client coordinates).
Returns a pointer to the menubar currently associated with the frame (if any).
Returns a pointer to the status bar currently associated with the frame (if any).
Returns the status bar pane used to display menu and toolbar help.
Returns a pointer to the toolbar currently associated with the frame (if any).
Virtual function called when a status bar is requested by CreateStatusBar .
Virtual function called when a toolbar is requested by CreateToolBar .
 
Simulate a menu command.
 
Tells the frame to show the given menu bar.
Associates a status bar with the frame.
Set the status bar pane used to display menu and toolbar help.
Sets the status bar text and redraws the status bar.
Sets the widths of the fields in the status bar.
Associates a toolbar with the frame.
 

 Properties Summary

See  and 
See  and 
See  and 
See  and 
 

 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 () – The window parent. This may be, and often is, None. If it is not None, 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 () – The window position. The value DefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform.
  • 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  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

 

 


 


Centre
(selfdirection=BOTH)

Centres the frame on the display.

Parameters: direction (int) – The parameter may be wx.HORIZONTALwx.VERTICAL or wx.BOTH.

Create
(selfparentid=ID_ANYtitle=""pos=DefaultPositionsize=DefaultSizestyle=DEFAULT_FRAME_STYLEname=FrameNameStr)

Used in two-step frame construction.

See  for further details.

Parameters:
  • parent () –
  • id (wx.WindowID) –
  • title (string) –
  • pos () –
  • size () –
  • style (long) –
  • name (string) –
Return type:

bool


CreateStatusBar
(selfnumber=1style=STB_DEFAULT_STYLEid=0name=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  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, None otherwise.

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
(selfstyle=TB_DEFAULT_STYLEid=ID_ANYname=ToolBarNameStr)

Creates a toolbar at the top or left of the frame.

Parameters:
  • style (long) – The toolbar style. See  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, None otherwise.

Note

 

By default, the toolbar is an instance of . To use a different class, override  . When a toolbar has been created with this function, or made known to the frame with , the frame will manage the toolbar position and adjust the return value from  to reflect the available space for application windows. Under Pocket PC, 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  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:

GetMenuBar
(self)

Returns a pointer to the menubar currently associated with the frame (if any).

Return type:

See also

 

 , , 


GetStatusBar
(self)

Returns a pointer to the status bar currently associated with the frame (if any).

Return type:

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:

See also

 

 , , 


OnCreateStatusBar
(selfnumberstyleidname)

Virtual function called when a status bar is requested by  .

Parameters:
  • number (int) – The number of fields to create.
  • style (long) – The window style. See  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 .

See also

 

 , .


OnCreateToolBar
(selfstyleidname)

Virtual function called when a toolbar is requested by  .

Parameters:
  • style (long) – The toolbar style. See  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 .

See also

 

 , .


PopStatusText
(selfnumber=0)
Parameters: number (int) –

ProcessCommand
(selfid)

Simulate a menu command.

Parameters: id (int) – The identifier for a menu item.
Return type: bool

PushStatusText
(selftextnumber=0)
Parameters:
  • text (string) –
  • number (int) –

SetMenuBar
(selfmenuBar)

Tells the frame to show the given menu bar.

Parameters: 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 calling  . Note that on some platforms, it is not possible to call this function twice for the same frame object.

See also

 

 , , .


SetStatusBar
(selfstatusBar)

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 () –

See also

 

 , , 


SetStatusBarPane
(selfn)

Set the status bar pane used to display menu and toolbar help.

Using -1 disables help display.

Parameters: n (int) –

SetStatusText
(selftextnumber=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
(selfwidths)

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  .

SetToolBar
(selftoolBar)

Associates a toolbar with the frame.

Parameters: toolBar () –

Properties


MenuBar

See  and 


StatusBar

See  and 


StatusBarPane

See  and 


ToolBar

See  and 

转载于:https://www.cnblogs.com/wangjian8888/p/6103974.html

你可能感兴趣的文章
sigar
查看>>
iOS7自定义statusbar和navigationbar的若干问题
查看>>
c++ 网络编程(一)TCP/UDP windows/linux 下入门级socket通信 客户端与服务端交互代码...
查看>>
程序员如何提高影响力:手把手教你塑造个人品牌
查看>>
身份证校验原理和PHP实现
查看>>
[Locked] Wiggle Sort
查看>>
deque
查看>>
Ext JS学习第十三天 Ext基础之 Ext.Element
查看>>
python--迭代器与生成器
查看>>
SQL之case when then用法详解
查看>>
STL 排序函数
查看>>
Microsoft Dynamics CRM 2011 面向Internet部署 (IFD) ADFS虚拟机环境搭建的步骤(CRM与ADFS装在同一台服务器上) 摘自网络...
查看>>
Setting up a Passive FTP Server in Windows Azure VM(ReplyCode: 227, Entering Passive Mode )
查看>>
Atitit mtp ptp rndis midi协议的不同区别
查看>>
Ajax辅助方法
查看>>
Python模块调用
查看>>
委托的调用
查看>>
c#中从string数组转换到int数组
查看>>
Scrapy入门程序点评
查看>>
DotNetty网络通信框架学习之源码分析
查看>>