What are the methods and properties of wxFrame

The tables in this section contain the most basic properties of wx.Frame, and its wx.Window parent class. Many of these properties and methods are covered in more detail elsewhere in the book. Table 8.4 contains some of the publicly readable and modifiable properties of wx.Frame.

Table 8.4 Public properties of wx.Frame



GetBackgroundColor() SetBackgroundColor(wx.Color)

The background color of a frame is the color chosen for any part of the frame not covered by a child widget. You can pass a wx.Color to the setter method or you can pass a string with the color name. Any string passed to a wxPython method expecting a color is interpreted as a call to the function wx.NamedColour().

GetId() SetId(int)

Returns or sets the wxPython identifier for the widget.

GetMenuBar() SetMenuBar(wx.MenuBar)

Gets or sets the menu bar object that is currently used by the frame, or None if there is no menu bar.




Returns the x, y position of the upper-left corner of the window, as a wx.Point or as a Python tuple. For top-level windows, the position is in terms of the display coordinates, for child windows, the position is in terms of the parent window.

Table 8.4 Public properties of wx.Frame (continued)




The C+ + versions of the getter and setter are overloaded. The default getter and setter use a wx.Size object. The method GetSizeTuple() returns the size as a Python tuple. Also see SetDimensions() for other ways of accessing this information.

GetTitleO SetTitle(String)

The title string associated with a frame is displayed in the title bar of the frame if it was created with the wx.caption style.

Table 8.5 displays some of the more useful nonproperty methods of wx.Frame. One to keep in mind is Refresh(), which you can use to manually trigger a redraw a frame.

Table 8.5 Methods of wx.Frame




Centers the frame (note that the non-American spelling Centre, is also defined). The argument can have the value wx.both in which case the frame is centered in both directions, or wx.horizontal or wx.vertical, in which case it centers in only one direction.


If the argument is True, the frame is enabled to receive user input. If the argument is False, user input is disabled in the frame. A related method is Disable().


For a wx.Frame, returns the minimum size for the frame that fits all of its subwindows.


If the argument is True, minimizes the frame to an icon (the exact behavior is, of course, system-dependent). If the argument is False, an iconized frame is restored to normal.


Returns True if the frame is currently enabled.


Returns True if the frame is being displayed in full screen mode, False otherwise. See ShowFullScreen for details.


Returns True if the frame is currently iconized, False otherwise.


Returns True if currently in the maximized state, False otherwise.


Returns True if the frame is currently visible.


Always returns True for top-level widgets such as frames or dialogs, and False for other widget types.

Table 8.5 Methods of wx.Frame (continued)




If the argument is True, maximizes the frame to fill the screen (the exact behavior is, of course, system-dependent). This will do the same thing as the user clicking on the Maximize box of the frame, which normally will enlarge the frame such that it fills the desktop but leaves the taskbar and other system components still visible.

Refresh(eraseBackground=True, rect=None)

Triggers a repaint event for the frame. If rect is none, then the entire frame is repainted. If a rectangle is specified, only that rectangle is repainted. If eraseBackground is True, the background of the window will also be repainted, if False, the background will not be repainted.

SetDimensions(x, y, width, height, sizeFlags=wx.SIZE_AUTO)

Allows you to set the size and position of the window in one method call. The position goes into the x and y arguments, the size into the width and height arguments. A value of -1 passed to any of the first four parameters is interpreted based on the value of the sizeFlags argument. Table 8.6 contains the possible values for the sizeFlags argument


If passed a value of True, causes the frame to be displayed. If passed a value of False, causes the frame to be hidden. The call Show(False) is equivalent to Hide().

ShowFullScreen(show, style=wx.FULLSCREEN_ALL)

If the Boolean argument is True, the frame is displayed in full screen mode—meaning it is enlarged to fill the entire display including covering the taskbar or other system components on the desktop. If the argument is False, the frame is restored to normal size. The style argument is a bitmask. The default value, wx.fullscreen_all, directs wxPython to hide all style elements of the window when in full screen mode. The following other values can be composed using bitwise operations to suppress certain parts of the frame in full screen mode:


The SetDimensions() method described in table 8.5 uses a bitmask of size flags to define default behavior if the user specifies -1 as the value for a dimension. Table 8.6 describes those flags.

These methods do not cover the subject of locating specific children that are contained by a frame. This subject requires its own section to describe it fully.

Table 8.6 Size flags for the method SetDimensions


-1 interpreted as


a valid position or size


converted to a wxPython default


a valid width, or a wxPython default height


a valid height, or a wxPython default width


the current value should be carried forward

Was this article helpful?

0 0


  • Diana
    What would prevent a wx frame fron being displayed?
    8 years ago

Post a comment