******** wx.Frame ******** Inheritance diagram for `wx.Frame`: | .. inheritance-diagram:: wx.Frame | Inheritance diagram for `wx.Frame`: | .. inheritance-diagram:: wx.Frame | Description =========== 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`/`CreateToolBar` functions manages these windows, and adjusts the value returned by `GetClientSize `_ to reflect the remaining size available to application windows. .. seealso:: `wx.MDIParentFrame `_, `wx.MDIChildFrame `_, `wx.MiniFrame `_, `wx.Dialog `_ Derived From ^^^^^^^^^^^^^ * `wx.TopLevelWindow `_ * `wx.Window `_ * `wx.EvtHandler `_ * `wx.Object `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.MDIChildFrame `_, `wx.MDIParentFrame `_, `wx.MiniFrame `_, `wx.PreviewFrame `_, `wx.PyPreviewFrame `_, `wx.SplashScreen `_ Window Styles ^^^^^^^^^^^^^ ================================================== ================================================== Window Style Description ================================================== ================================================== ``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. ``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 only. ``wx.MAXIMIZE_BOX`` Displays a maximize box on the frame. ``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. ``wx.RESIZE_BORDER`` Displays a resizeable border around the window. ``wx.FRAME_TOOL_WINDOW`` Causes a frame with a small titlebar 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 wx.GTK, the flag is respected only if GTK+ is at least version 2.2 and the window manager supports `_NET_WM_STATE_SKIP_TASKBAR` hint. Has no effect under other platforms. ``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_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 ``wx.EVT_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 <#Create>`_ is called (two-step construction). You cannot use this style together with ``wx.MAXIMIZE_BOX`` or ``wx.MINIMIZE_BOX``, so you should use ``wx.DEFAULT_FRAME_STYLE`` & ~ (``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_SHAPED`` Windows with this style are allowed to have their shape changed with the `SetShape `_ method. ``wx.FRAME_EX_METAL`` On Mac OS X, frames with this style will be shown with a metallic look. This is an *extra* style. ================================================== ================================================== Event Handling ^^^^^^^^^^^^^^ `wx.Frame` processes the following events: ================================================== ================================================== Event Name Description ================================================== ================================================== wx.EVT_SIZE(func) 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 ``wx.EVT_SIZE`` or using sizers. wx.EVT_MENU_HIGHLIGHT(func) The default implementation displays the help string associated with the selected item in the first pane of the status bar, if there is one. ================================================== ================================================== Remarks ^^^^^^^ An application should normally define an `wx.CloseEvent <../Events/wx.CloseEvent.html>`_ handler for the frame to respond to system close events, for example so that related data and subwindows can be cleaned up. For Motif, MWM (the Motif Window Manager) should be running for any window styles to work (otherwise all styles take effect). Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `CreateStatusBar <#CreateStatusBar>`_ * `CreateToolBar <#CreateToolBar>`_ * `DoGiveHelp <#DoGiveHelp>`_ * `DoMenuUpdates <#DoMenuUpdates>`_ * `GetMenuBar <#GetMenuBar>`_ * `GetStatusBar <#GetStatusBar>`_ * `GetStatusBarPane <#GetStatusBarPane>`_ * `GetToolBar <#GetToolBar>`_ * `PopStatusText <#PopStatusText>`_ * `ProcessCommand <#ProcessCommand>`_ * `PushStatusText <#PushStatusText>`_ * `SetMenuBar <#SetMenuBar>`_ * `SetStatusBar <#SetStatusBar>`_ * `SetStatusBarPane <#SetStatusBarPane>`_ * `SetStatusText <#SetStatusText>`_ * `SetStatusWidths <#SetStatusWidths>`_ * `SetToolBar <#SetToolBar>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `MenuBar <#MenuBar>`_ * `StatusBar <#StatusBar>`_ * `StatusBarPane <#StatusBarPane>`_ * `ToolBar <#ToolBar>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(parent, id=-1, title="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr) Constructor, creating the window. **Parameters:** * `parent` (`wx.Window `_) * `id` (int) * `title` (string) * `pos` (`wx.Point `_) * `size` (`wx.Size `_) * `style` (long) * `name` (string) | **Returns:** `wx.Frame `_ -------- .. method:: CreateStatusBar(number=1, style=wx.ST_SIZEGRIP|wx.FULL_REPAINT_ON_RESIZE, id=0, name="statusBar") 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` (int): The status bar window identifier. If -1, an identifier will be chosen by wxWidgets. * `name` (string): The status bar window name. | **Returns:** `wx.StatusBar `_ .. 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. By default, the status bar is an instance of `wx.StatusBar `_. To use a different class, override `OnCreateStatusBar`. .. note:: Note that you can put controls and other windows on the status bar if you wish. .. seealso:: `SetStatusText <#SetStatusText>`_, `GetStatusBar <#GetStatusBar>`_ -------- .. method:: CreateToolBar(style=wx.NO_BORDER|wx.TB_HORIZONTAL, id=-1, name="toolBar") 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` (int): The toolbar window identifier. If -1, an identifier will be chosen by wxWidgets. * `name` (string): The toolbar window name. | **Returns:** `wx.ToolBar `_ .. note:: By default, the toolbar is an instance of `wx.ToolBar `_ (which is defined to be a suitable toolbar class on each platform). To use a different class, override `OnCreateToolBar`. When a toolbar has been created with this function, or made known to the frame with `SetToolBar <#SetToolBar>`_, the frame will manage the toolbar position and adjust the return value from `wx.Window.GetClientSize `_ to reflect the available space for application windows. .. seealso:: `CreateStatusBar <#CreateStatusBar>`_, `SetToolBar <#SetToolBar>`_, `GetToolBar <#GetToolBar>`_ -------- .. method:: DoGiveHelp(text, show) | **Parameters:** * `text` (string) * `show` (bool) -------- .. method:: DoMenuUpdates(menu=None) | **Parameters:** * `menu` (`wx.Menu `_) -------- .. method:: GetMenuBar() Returns a pointer to the menubar currently associated with the frame (if any). | **Returns:** `wx.MenuBar `_ .. seealso:: `SetMenuBar <#SetMenuBar>`_, `wx.MenuBar `_, `wx.Menu `_ -------- .. method:: GetStatusBar() Returns a pointer to the status bar currently associated with the frame (if any). | **Returns:** `wx.StatusBar `_ .. seealso:: `CreateStatusBar <#CreateStatusBar>`_, `wx.StatusBar `_ -------- .. method:: GetStatusBarPane() Returns the status bar pane used to display menu and toolbar help. | **Returns:** `int` .. seealso:: `SetStatusBarPane <#SetStatusBarPane>`_ -------- .. method:: GetToolBar() Returns a pointer to the toolbar currently associated with the frame (if any). | **Returns:** `wx.ToolBar `_ .. seealso:: `CreateToolBar <#CreateToolBar>`_, `SetToolBar <#SetToolBar>`_, `wx.ToolBar `_ -------- .. method:: PopStatusText(number=0) | **Parameters:** * `number` (int) -------- .. method:: ProcessCommand(id) Simulate a menu command. **Parameters:** * `id` (int): The identifier for a menu item. -------- .. method:: PushStatusText(text, number=0) | **Parameters:** * `text` (string) * `number` (int) -------- .. method:: SetMenuBar(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 calling `SetMenuBar`. .. note:: Note that on some platforms, it is not possible to call this function twice for the same frame object. .. seealso:: `GetMenuBar <#GetMenuBar>`_, `wx.MenuBar `_, `wx.Menu `_ -------- .. method:: SetStatusBar(statusBar) Associates a status bar with the frame. **Parameters:** * `statusBar` (`wx.StatusBar `_) .. seealso:: `CreateStatusBar <#CreateStatusBar>`_, `GetStatusBar <#GetStatusBar>`_, `wx.StatusBar `_ -------- .. method:: SetStatusBarPane(n) Set the status bar pane used to display menu and toolbar help. Using -1 disables help display. **Parameters:** * `n` (int) -------- .. method:: SetStatusText(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. .. seealso:: `CreateStatusBar <#CreateStatusBar>`_, `wx.StatusBar `_ -------- .. method:: SetStatusWidths(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`. .. note:: The widths of the variable fields are calculated from the total width of all fields, minus the sum of widths of the non-variable fields, divided by the number of variable fields. -------- .. method:: SetToolBar(toolBar) Associates a toolbar with the frame. **Parameters:** * `toolBar` (`wx.ToolBar `_) -------- Properties ^^^^^^^^^^ .. attribute:: MenuBar See `GetMenuBar <#GetMenuBar>`_ and `SetMenuBar <#SetMenuBar>`_ .. attribute:: StatusBar See `GetStatusBar <#GetStatusBar>`_ and `SetStatusBar <#SetStatusBar>`_ .. attribute:: StatusBarPane See `GetStatusBarPane <#GetStatusBarPane>`_ and `SetStatusBarPane <#SetStatusBarPane>`_ .. attribute:: ToolBar See `GetToolBar <#GetToolBar>`_ and `SetToolBar <#SetToolBar>`_