Recently, some windows have been written using the wx module of python. wx. Frame is the most important window framework, and some materials are searched online. Its common attributes are used as follows:
Wx. Frame (parent, id =-1, title = "", pos = wx. DefaultPosition, size = wx. DefaultSize, style = wx. DEFAULT_FRAME_STYLE, name = "frame ")
Frame shape and size labels
Wx. FRAME_NO_TASKBAR: a fully standard framework, except for one thing: in Windows and other systems that support this feature, it is not displayed in the taskbar. When minimized, the Framework icons are converted to the desktop rather than the taskbar.
Wx. FRAME_SHAPED: Non-rectangular frame. Use SetShape () to set the exact shape of the frame. The window shape will be discussed later in this chapter.
Wx. FRAME_TOOL_WINDOW: The title bar of the Framework is smaller than the standard one. It is usually used as an auxiliary framework that contains multiple tool buttons. In Windows, the tool window is not displayed in the taskbar.
Wx. ICONIZE: the window is initially minimized. This style only works in Windows.
Wx. MAXIMIZE: The window will be maximized at the beginning (full screen ). This style only works in Windows.
Wx. MINIMIZE: Same as wx. ICONIZE.
Floating window style
Wx. FRAME_FLOAT_ON_PARENT: The frame will float above its parent window (only its parent window. (Obviously, to use this style, the Framework requires a parent window ). Other frameworks can cover this framework.
Wx. STAY_ON_TOP: this framework will always be on top of other frameworks in the system. (If you have multiple frameworks that use this style, they will overlap each other, but for other frameworks in the system, they are still above .)
Decoration window style
Wx. CAPTION: A title bar for the window. If you want to place the maximize box, minimize box, system menu, and context help, you must include this style.
Wx. FRAME_EX_CONTEXTHELP: This is for Windows operating systems. It places the question mark help icon in the right corner of the title bar. This style is mutually exclusive with the wx. MAXIMIZE_BOX and WX. MINIMIZE_BOX styles. It is an extended style and must be created in two steps.
Wx. FRAME_EX_METAL: on Mac OS X, the frame with this style has a metallic appearance. This is an additional style and must be set using the SetExtraStyle method.
Wx. MAXIMIZE_BOX: place a maximized box in the standard position of the title bar.
Wx. MINIMIZE_BOX: place a minimal box in the standard position of the title bar.
Wx. CLOSE_BOX: place a close box in the standard position of the title bar.
Wx. RESIZE_BORDER: provides a standard frame that can be manually adjusted.
Wx. SIMPLE_BORDER: it is the simplest border for the frame. It cannot be adjusted, and there is no other decoration. This style is mutually exclusive with all other decorative styles.
Wx. SYSTEM_MENU: place a system menu on the title bar. The content of this System menu is related to the decoration style you use. For example, if you use wx. MINIMIZE_BOX, the system menu item has the "minimize" option.
Wx. Frame public attributes
GetBackgroundColor ()
SetBackgroundColor (wx. Color): the background Color is the Color of the parts in the frame that are not covered by its child widgets. You can pass a wx. Color or Color name to the setting method. Any string passed to the wxPython method that requires color is interpreted as a call to the wx. NamedColour () function.
GetId (), SetId (int): return or set the identifier of the widget.
GetMenuBar () and SetMenuBar (wx. MenuBar): obtain or set the menu bar object currently used by the Framework. If no menu bar exists, None is returned.
GetPosition (), GetPositionTuple (), and SetPosition (wx. Point): return the position of x and y in the upper left corner of the window in the form of a wx. Point or Python tuples. For top-level windows, this position is relative to the coordinates of the display area. For child windows, this position is relative to the coordinates of the parent window.
GetSize (), GetSizeTuple (), SetSize (wx. Size): The get * or set * method in C ++ is overwritten. The default get * or set * object uses a wx. Size object. The GetSizeTuple () method returns the size in the form of a Python tuples. For more information, see SetDimensions ().
GetTitle (), SetTitle (String): gets or sets the String of the frame title bar.
Wx. Frame Method
Center (direction = wx. BOTH): Center frame (note that the non-American spelling Centre is also defined ). The default value of the parameter is wx. BoTH. In this case, the box is centered in BoTH directions. If the parameter value is wx. HORIZONTAL or wx. VERTICAL, it indicates that it is centered horizontally or vertically.
Enable (enable = true): If the parameter is true, the framework can accept user input. If the parameter is False, you cannot enter it in the Framework. The corresponding method is Disable ().
GetBestSize (): For wx. Frame, it returns the minimum size of the Frame that can accommodate all subwindows.
Iconize (iconize): If the parameter is true, the framework is minimized as an icon (of course, the specific behavior is related to the system ). If the parameter is False, the icon-based framework returns to normal.
IsEnabled (): returns True if the framework is currently valid.
IsFullScreen (): If the frame is displayed in full screen mode, True is returned; otherwise, False is returned. For details, see ShowFullScreen.
IsIconized (): If the framework is currently minimized as an icon, True is returned; otherwise, False is returned.
IsMaximized (): returns True if the framework is in the maximum state currently; otherwise, False.
IsShown (): returns True if the framework is currently visible.
IsTopLevel (): True is always returned for top-level widgets, such as frame or dialog box, and False is returned for other widgets.
Maximize (maximize): If the parameter is True, Maximize the frame to fill the screen (the specific behavior is related to the system ). This is the same as what the maximize button of the frame is done. This usually zooms in the frame to fill the desktop, but the taskbar and other system components are still visible.
Refresh (eraseTrue, rect = None): triggers the repainting event of the framework. If the rect is none, the entire frame is repainted. If a rectangle area is specified, only the rectangle area is repainted. If eraseBackground is True, the northern shadows of the window will be re-painted. If it is False, the background will not be re-painted.
SetDimensions (x, y, width, height, sizeFlags = wx. SIZE_AUTO): enables you to set the size and position of the window in a method call. The position is determined by the x and y parameters, and the size is determined by the width and height parameters. If some of the first four parameters are-1, this-1 will be interpreted based on the value of sizeFlags. Table 8.6 contains the possible values of the sizeFlags parameter.
Show (show = True): If the parameter value is True, the frame is displayed. If the parameter value is False, the framework is hidden. Show (False) is equivalent to Hide ().
ShowFullScreen (show, style = wx. FULLSCREEN_ALL): If the Boolean parameter is True, the frame is displayed in full screen mode. This means that the frame is enlarged to fill the entire display area, including the taskbar on the desktop and other system components. If the parameter is False, the frame is restored to the normal size. The style parameter is a bitmask. The default wx. FULLSCREEN_ALL indicates that wxPython hides all style elements of all windows in full screen mode. The following values can be combined using the bitwise operator to cancel the partial Decoration of the frame in full screen mode: wx. FULLSCREEN_NOBORDER, wx. FULLSCREEN_NOCAPTION, wx. FULLSCREEN_NOMENUBAR, wx. FULLSCREEN_NOSTATUSBAR, wx. FULLSCREEN_NOTOOLBAR.
Dimensions of the SetDimensions Method
Wx. ALLOW_MINUS_ONE: a valid position or size.
Wx. SIZE_AUTO: convert to a wxPython default value.
Wx. SIZE_AUTO_HEIGHT: a valid height or a wxPython default height.
Wx. SIZE_AUTO_WIDTH: A Valid Width or a wxPython default width.
Wx. SIZE_USE_EXISTING: use the existing size.