What are some different frame styles

The wx.Frame class has a multitude of possible style flags. Typically, the default style is what you want, but there are several useful variations. The first set of style flags that we'll discuss governs the general shape and size of the frame. Although not strictly enforced, these flags should be considered mutually exclusive—a given frame should only use one of them. Using a style flag from this group does not imply the existence of any decorators described in the other tables in this section; you'll need to compose the shape flag together with the other desired decorator flags. Table 8.1 describes the shape and size flags.

Figure 8.2 The simple frame as a subclass

Table 8.1 Style flags for the shape and size of a frame

Style Flag

Description

wx.FRAME_NO_TASKBAR

A perfectly normal frame, except for one thing: under Windows systems and others supporting this ability, it will not display in the taskbar. When minimized, the frame will iconize to the desktop rather than to the taskbar. (This is the way that frames behaved in pre-95 versions of Windows).

wx.FRAME_SHAPED

The frame is nonrectangular. The exact shape of the frame is set with the SetShape() method. Shaped windows will be discussed later in this chapter.

wx.FRAME_TOOL_WI NDOW

The frame has a smaller than normal title bar, typically used for auxiliary frames that contain a variety of tool buttons. Under Windows operating systems, a tool window will not display in the task bar.

wx.ICONIZE

The window will initially be shown minimized. This style only has an effect in Windows operating systems.

wx.MAXIMIZE

The window will initially be shown maximized (full-screen). This style only has an effect in Windows operating systems.

wx.MINIMIZE

The same as wx.iconize

Out of this group, the style most in need of a screen shot is wx.frame_tool_window. Figure 8.3 displays a small sample of the wx.frame_tool_window with wx.CAPTlON and wx.SYSTEM_MENU also declared. If you can't get the scale from the picture, let us assure you that the title bar of the tool frame is narrower than the other frame styles we've seen.

There are two mutually exclusive styles that control whether a frame stays on top of other frames, even when the other frames gain the focus. This can be useful for small dialogs that don't remain visible for long. Table 8.2 describes the styles.

Finally, there are several decorations you can place on your window. These are not placed automatically if you abandon the default style, so you must add them, otherwise it's easy to end up with a window that doesn't close or move. Table 8.3 gives the list of decoration styles.

A Frame Tool Window

A Frame Tool Window

Figure 8.3 An example of the tool window style

Figure 8.3 An example of the tool window style

Table 8.2 Styles for frame floating behavior

Style Flag

Description

wx.FRAME_FLOAT_ON_PARENT

The frame will float on top of its parent, and only its parent. (Obviously, to use this style the frame needs to have a parent). Other frames will overshadow this frame.

wx.STAY_ON_TOP

The frame will always be on top of any other frame in the system. (If you have more than one frame designated as stay on top, the frames will overlap normally relative to each other, but will still be on top of all the other frames in the system.)

The default style is wx.default_frame_style and is equivalent to wx.minimize_

BOX | wx.MAXIMIZE_BOX | wx.CLOSE_BOX | wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTlON. This style creates a typical window that you can resize, minimize, maximize, or close. It's a good idea when composing other styles to start with the

Table 8.3 Styles for decorating a window

Style Flag

Description

wx.CAPTION

Gives the window a title bar. You must include this style to have a place for the other elements that traditionally are placed here (the minimize and maximize box, the system menu, and context help).

wx.FRAME_EX_CONTEXTHELP

This is for Windows operating systems, and places the question mark Help icon in the right corner of the title bar. This style is mutually exclusive with wx.maximize_box and wx.minimize_box. This style is an extended style, and must be added with the two-step creation process described later.

wx.FRAME_EX_METAL

On Mac OS X, frames with this style will have a brushed metal look. This is an extra style which must be set with the SetExtraStyle method.

wx.MAXIMIZE_BOX

Puts a maximize box in the normal place on the title bar.

wx.MINIMIZE_BOX

Puts a minimize box in the normal place on the title bar.

wx.CLOSE_BOX

Puts a close box in the normal place on the title bar.

wx.RESIZE_BORDER

Gives the frame a normal border with handles for resizing.

wx.SIMPLE_BORDER

Gives the frame a minimal border with no resizing or decorators. This style is mutually exclusive with all the other decorator styles.

wx.SYSTEM_MENU

Puts a system menu on the title bar. The exact contents of the system menu are consistent with the other chosen decorator styles—you have a "minimize" option only if wx.minimize_box is declared, for example.

default style to ensure that you have the right set of decorators. For example, to create a tool frame, you might use style=wx.DEFAULT_FRAME_STYLE | wx.frame_tool_ window. Remember, you can use a * operator to remove the flag from a bitmask.

Was this article helpful?

+1 0

Responses

  • bonacata
    How to remove default task bar minimize maximise close button in wxpython?
    8 years ago

Post a comment