Inheritance diagram for wx.Window:
wx.Window is the base class for all windows and represents any visible object on screen. All controls, top level windows and so on are windows. Sizers and device contexts are not, however, as they don’t appear on screen themselves.
Note
Please note that all children of the window will be deleted automatically by the destructor before the window itself is deleted which means that you don’t have to worry about deleting them manually.
Note
Also note that in this, and many others, wxWidgets classes some GetXXX() methods may be overloaded (as, for example, GetSize or GetClientSize). In this case, the overloads are non-virtual because having multiple virtual functions with the same name results in a virtual function name hiding at the derived class level (in English, this means that the derived class has to override all overloaded variants if it overrides any of them). To allow overriding them in the derived class, wxWidgets uses a unique protected virtual DoGetXXX() method and all GetXXX() ones are forwarded to it, so overriding the former changes the behaviour of the latter.
wx.BitmapButton, wx.Button, wx.CheckBox, wx.CheckListBox, wx.Choice, wx.Choicebook, wx.CollapsiblePane, wx.ColourDialog, wx.ColourPickerCtrl, wx.ComboBox, wx.ContextHelpButton, wx.Control, wx.ControlWithItems, wx.DatePickerCtrl, wx.DatePickerCtrlBase, wx.Dialog, wx.DirDialog, wx.DirFilterListCtrl, wx.DirPickerCtrl, wx.FileDialog, wx.FilePickerCtrl, wx.FindReplaceDialog, wx.FontDialog, wx.FontPickerCtrl, wx.Frame, wx.Gauge, wx.GenericDatePickerCtrl, wx.GenericDirCtrl, wx.HtmlListBox, wx.HyperlinkCtrl, wx.ListBox, wx.ListCtrl, wx.ListView, wx.Listbook, wx.MDIChildFrame, wx.MDIClientWindow, wx.MDIParentFrame, wx.MenuBar, wx.MessageDialog, wx.MiniFrame, wx.MultiChoiceDialog, wx.Notebook, wx.NotebookPage, wx.NumberEntryDialog, wx.Panel, wx.PasswordEntryDialog, wx.PickerBase, wx.PopupTransientWindow, wx.PopupWindow, wx.PreviewCanvas, wx.PreviewControlBar, wx.PreviewFrame, wx.ProgressDialog, wx.PyAxBaseWindow, wx.PyControl, wx.PyPanel, wx.PyPreviewControlBar, wx.PyPreviewFrame, wx.PyScrolledWindow, wx.PyWindow, wx.RadioBox, wx.RadioButton, wx.SashLayoutWindow, wx.SashWindow, wx.ScrollBar, wx.ScrolledWindow, wx.SearchCtrl, wx.SimpleHtmlListBox, wx.SingleChoiceDialog, wx.Slider, wx.SpinButton, wx.SpinCtrl, wx.SplashScreen, wx.SplashScreenWindow, wx.SplitterWindow, wx.StaticBitmap, wx.StaticBox, wx.StaticLine, wx.StaticText, wx.StatusBar, wx.TextCtrl, wx.TextEntryDialog, wx.TipWindow, wx.ToggleButton, wx.ToolBar, wx.ToolBarBase, wx.Toolbook, wx.TopLevelWindow, wx.TreeCtrl, wx.Treebook, wx.VListBox, wx.VScrolledWindow
The following styles can apply to all windows, although they will not always make sense for a particular window class or on all platforms.
Window Style | Description |
---|---|
wx.BORDER_SIMPLE | Displays a thin border around the window. wx.SIMPLE_BORDER is the old name for this style. |
wx.BORDER_DOUBLE | Displays a double border. wx.DOUBLE_BORDER is the old name for this style. Windows and Mac only. |
wx.BORDER_SUNKEN | Displays a sunken border. wx.SUNKEN_BORDER is the old name for this style. |
wx.BORDER_RAISED | Displays a raised border. wx.RAISED_BORDER is the old name for this style. |
wx.BORDER_STATIC | Displays a border suitable for a static control. wx.STATIC_BORDER is the old name for this style. Windows only. |
wx.BORDER_THEME | Displays a themed border where possible. Currently this has an effect on Windows XP and above only. |
wx.BORDER_NONE | Displays no border, overriding the default border style for the window. wx.NO_BORDER is the old name for this style. |
wx.TRANSPARENT_WINDOW | The window is transparent, that is, it will not receive paint events. Windows only. |
wx.TAB_TRAVERSAL | Use this to enable tab traversal for non-dialog windows. |
wx.WANTS_CHARS | Use this to indicate that the window wants to get all char/key events for all keys - even for keys like TAB or ENTER which are usually used for dialog navigation and which wouldn’t be generated without this style. If you need to use this style in order to get the arrows or etc., but would still like to have normal keyboard navigation take place, you should create and send a wx.NavigationKeyEvent in response to the key events for Tab and Shift-Tab. |
wx.NO_FULL_REPAINT_ON_RESIZE | On Windows, this style used to disable repainting the window completely when its size is changed. Since this behaviour is now the default, the style is now obsolete and no longer has an effect. |
wx.VSCROLL | Use this style to enable a vertical scrollbar. |
wx.HSCROLL | Use this style to enable a horizontal scrollbar. |
wx.ALWAYS_SHOW_SB | If a window has scrollbars, disable them instead of hiding them when they are not needed (i.e. when the size of the window is big enough to not require the scrollbars to navigate it). This style is currently implemented for wxMSW, wxGTK and wxUniversal and does nothing on the other platforms. |
wx.CLIP_CHILDREN | Use this style to eliminate flicker caused by the background being repainted, then children being painted over them. Windows only. |
wx.FULL_REPAINT_ON_RESIZE | Use this style to force a complete redraw of the window whenever it is resized instead of redrawing just the part of the window affected by resizing. Note that this was the behaviour by default before 2.5.1 release and that if you experience redraw problems with code which previously used to work you may want to try this. Currently this style applies on GTK+ 2 and Windows only, and full repainting is always done on other platforms. |
The following are extra styles, set using SetExtraStyle.
Window Extra Style | Description |
---|---|
wx.WS_EX_VALIDATE_RECURSIVELY | By default, Validate / TransferDataToWindow / TransferDataFromWindow only work on direct children of the window (compatible behaviour). Set this flag to make them recursively descend into all subwindows. |
wx.WS_EX_BLOCK_EVENTS | wx.CommandEvents and the objects of the derived classes are forwarded to the parent window and so on recursively by default. Using this flag for the given window allows to block this propagation at this window, i.e. prevent the events from being propagated further upwards. Dialogs have this flag on by default. |
wx.WS_EX_TRANSIENT | Don’t use this window as an implicit parent for the other windows: this must be used with transient windows as otherwise there is the risk of creating a dialog/frame with this window as a parent which would lead to a crash if the parent is destroyed before the child. |
wx.WS_EX_PROCESS_IDLE | This window should always process idle events, even if the mode set by wx.IdleEvent.SetMode is wx.IDLE_PROCESS_SPECIFIED. |
wx.WS_EX_PROCESS_UI_UPDATES | This window should always process UI update events, even if the mode set by wx.UpdateUIEvent.SetMode is wx.UPDATE_UI_PROCESS_SPECIFIED. |
Construct and show a generic wx.Window.
Parameters:
Returns:
Can this window have focus?
Returns:
bool
Can this window be given focus by keyboard navigation? if not, the only way to give it focus (provided it accepts it at all) is to click it.
Returns:
bool
Adds a child window.
This is called automatically by window creation functions so should not be required by the application programmer.
Parameters:
Note
Notice that this function is mostly internal to wxWidgets and shouldn’t be called by the user code.
Mirror coordinates for RTL layout if this window uses it and if the mirroring is not done automatically like Win32.
Parameters:
Returns:
int
Associate the window with a new native handle.
Parameters:
Returns True if the platform supports setting the transparency for this window.
Returns:
bool
Note
Note that this method will err on the side of caution, so it is possible that this will return False when it is in fact possible to set the transparency.
Note
On X-windows systems the X server must have the composite extension loaded, and there must be a composite manager program (such as xcompmgr) running.
Note
Note that wxWidgets maintains the stack of windows having captured the mouse and when the mouse is released the capture returns to the window which had had captured it previously and it is only really released if there were no previous window. In particular, this means that you must release the mouse as many times as you capture it, unless the window receives the wx.MouseCaptureLostEvent event.
See also
A synonym for CentreOnParent.
Parameters:
Centres the window.
Parameters:
Note
If the window is a top level one (i.e. doesn’t have a parent), it will be centered relative to the screen anyhow.
See also
Centres the window on its parent. This is a more readable synonym for Centre.
Parameters:
Note
This methods provides for a way to center top level windows over their parents instead of the entire screen. If there is no parent or if the window is not a top level window, then behaviour is the same as Centre.
See also
Converts to screen coordinates from coordinates relative to this window.
Parameters:
Returns:
Converts to screen coordinates from coordinates relative to this window.
Parameters:
Returns:
(x, y)
Converts client area size size to corresponding window size. In other words, the returned value is what would GetSize return if this window had client area of given size. Components with wx.DefaultCoord value are left unchanged.
This function is new since wxWidgets version 2.8.8
Parameters:
Returns:
Note
Note that the conversion is not always exact, it assumes that non-client area doesn’t change and so doesn’t take into account things like menu bar (un)wrapping or (dis)appearance of the scrollbars.
See also
This function simply generates a wx.CloseEvent whose handler usually tries to close the window. It doesn’t close the window itself, however.
Parameters:
Returns:
bool
Note
Close calls the close handler for the window, providing an opportunity for the window to choose whether to destroy the window. Usually it is only used with the top level windows (wx.Frame and wx.Dialog classes) as the others are not supposed to have any special OnClose() logic. The close handler should check whether the window is being deleted forcibly, using wx.CloseEvent.CanVeto, in which case it should destroy the window using Destroy.
Note
Calling Close does not guarantee that the window will be destroyed; but it provides a way to simulate a manual close of a window, which may or may not be implemented by destroying the window. To guarantee that the window will be destroyed, call Destroy instead.
See also
Converts a point or size from dialog units to pixels. Dialog units are used for maintaining a dialog’s proportions even if the font changes.
For the x dimension, the dialog units are multiplied by the average character width and then divided by 4. For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.
Parameters:
Returns:
Converts a point or size from dialog units to pixels. Dialog units are used for maintaining a dialog’s proportions even if the font changes.
For the x dimension, the dialog units are multiplied by the average character width and then divided by 4. For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.
Parameters:
Returns:
Converts a point from pixels to dialog units.
For the x dimension, the pixels are multiplied by 4 and then divided by the average character width. For the y dimension, the pixels are multiplied by 8 and then divided by the average character height
Parameters:
Returns:
Converts a size from pixels to dialog units.
For the x dimension, the pixels are multiplied by 4 and then divided by the average character width. For the y dimension, the pixels are multiplied by 8 and then divided by the average character height
Parameters:
Returns:
Create the GUI part of the Window for 2-phase creation mode.
Parameters:
Returns:
bool
Converts a point or size from dialog units to pixels. Dialog units are used for maintaining a dialog’s proportions even if the font changes.
For the x dimension, the dialog units are multiplied by the average character width and then divided by 4. For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.
Parameters:
Returns:
Converts a point or size from dialog units to pixels. Dialog units are used for maintaining a dialog’s proportions even if the font changes.
For the x dimension, the dialog units are multiplied by the average character width and then divided by 4. For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.
Parameters:
Returns:
Destroys the window safely.
Frames and dialogs are not destroyed immediately when this function is called – they are added to a list of windows to be deleted on idle time, when all the window’s events have been processed. This prevents problems with events being sent to non-existent windows.
Returns True if the window has either been successfully deleted, or it has been added to the list of windows pending real deletion.
Returns:
bool
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters:
Note
Windows only.
Enable or disable the window for user input.
Parameters:
Returns:
bool
Note
Note that when a parent window is disabled, all of its children are disabled as well and they are reenabled again when the parent is.
See also
Note
Note that this is a function, so it can be called without needing a wx.Window pointer.
See also
Find the first window with the given id.
Parameters:
Returns:
See also
Find a window by its label. Depending on the type of window, the label may be a window title or panel item label.
Parameters:
Returns:
See also
Find a window by its name (as given in a window constructor or Create function call).
If no window with such name is found, FindWindowByLabel is called.
Parameters:
Returns:
See also
Sizes the window so that it fits around its subwindows.
This function won’t do anything if there are no subwindows and will only really work correctly if the sizers are used for the subwindows layout. Also, if the window has exactly one subwindow it is better (faster and the result is more precise as Fit adds some margin to account for fuzziness of its calculations) to call:
window.SetClientSize(child.GetSize())
instead of calling Fit.
Similar to Fit, but sizes the interior (virtual) size of a window. Mainly useful with scrolled windows to reset scrollbars after sizing changes that do not trigger a size event, and/or scrolled windows without an interior sizer.
This function similarly won’t do anything if there are no subwindows.
Freezes the window or, in other words, prevents any updates from taking place on screen, the window is not redrawn at all.
Thaw must be called to reenable window redrawing. Calls to these two functions may be nested.
This method is useful for visual appearance optimization (for example, it is a good idea to use it before doing many large text insertions in a row into a wx.TextCtrl under wxGTK) but is not implemented on all platforms nor for all controls so it is mostly just a hint to wxWidgets and not a mandatory directive.
Gets the accelerator table for this window.
Returns:
See also
Use GetEffectiveMinSize instead.
Returns:
Warning
This method is deprecated.
Returns the current auto layout setting.
Returns:
bool
Returns the background style of the window.
The background style indicates whether background colour should be determined by the system (wx.BG_STYLE_SYSTEM), be set to a specific colour (wx.BG_STYLE_COLOUR), or should be left to the application to implement (wx.BG_STYLE_CUSTOM).
On GTK+, use of wx.BG_STYLE_CUSTOM allows the flicker-free drawing of a custom background, such as a tiled bitmap. Currently the style has no effect on other platforms.
Returns:
int
This functions returns the best acceptable minimal size for the window. For example, for a static control, it will be the minimal size such that the control label is not truncated.
For windows containing subwindows (typically wx.Panel), the size returned by this function will be the same as the size the window would have had after calling Fit.
Returns:
This function returns the best acceptable minimal size for the window, if applicable. For example, for a static text control, it will be the minimal size such that the control label is not truncated.
For windows containing subwindows (typically wx.Panel), the size returned by this function will be the same as the size the window would have had after calling Fit.
Returns:
(width, height)
Return the largest of ClientSize and BestSize (as determined by a sizer, interior children, or other means).
Returns:
Get border for the flags of this window
Parameters:
Returns:
int
See also
HasCapture, CaptureMouse, ReleaseMouse, wx.MouseCaptureLostEvent, wx.MouseCaptureChangedEvent
Returns the character height for this window.
Returns:
int
Returns the average character width for this window.
Returns:
int
Returns a reference to the list of the window’s children. wx.WindowList is a type-safe list-like class whose elements are of type wx.Window.
Returns:
wx.WindowList
Returns the default font and colours which are used by the control.
This is useful if you want to use the same font or colour in your own control as in a standard control – which is a much better idea than hard coding specific colours or fonts which might look completely out of place on the users system, especially if it uses themes.
The variant parameter is only relevant under Mac currently and is ignore under other platforms. Under Mac, it will change the size of the returned font. See SetWindowVariant for more about this.
This static method is “overridden” in many derived classes and so calling, for example, wx.Button.GetClassDefaultAttributes() will typically return the values appropriate for a button which will be normally different from those returned by, say, wx.ListCtrl.GetClassDefaultAttributes().
The wx.VisualAttributes structure has at least the fields font, colFg and colBg. All of them may be invalid if it was not possible to determine the default control appearance or, especially for the background colour, if the field doesn’t make sense as is the case for colBg for the controls with themed background.
Parameters:
Returns:
wx.VisualAttributes
See also
Get the origin of the client area of the window relative to the window’s top left corner (the client area may be shifted because of the borders, scrollbars, other decorations...)
Returns:
This gets the size of the window ‘client area’ in pixels. The client area is the area which may be drawn on by the programmer, excluding title bar, border, scrollbars, etc...
Returns:
See also
This gets the size of the window’s ‘client area’ in pixels. The client area is the area which may be drawn on by the programmer, excluding title bar, border, scrollbars, etc...
Returns:
(width, height)
Returns a pointer to the window’s layout constraints, or None if there are none.
Returns:
Return the sizer that this window is a member of, if any, otherwise None.
Returns:
See also
Currently this is the same as calling GetClassDefaultAttributes (GetWindowVariant ()).
One advantage of using this function compared to the static version is that the call is automatically dispatched to the correct class (as usual with virtual functions) and you don’t have to specify the class name explicitly.
The other one is that in the future this function could return different results, for example it might return a different font for an Ok button than for a generic button if the users GUI is configured to show such buttons in bold font. Of course, the down side is that it is impossible to call this function without actually having an object to apply it to whereas the static version can be used without having to create an object first.
Returns:
wx.VisualAttributes
Returns the associated drop target, which may be None.
Returns:
See also
Merges the window’s best size into the min size and returns the result.
This is the value used by sizers to determine the appropriate ammount of space to allocate for the widget.
Returns:
See also
Returns the event handler for this window.
By default, the window is its own event handler.
Returns:
See also
SetEventHandler, PushEventHandler, PopEventHandler, wx.EvtHandler.ProcessEvent, wx.EvtHandler
Returns the extra style bits for the window.
Returns:
long
See also
Note
The interpretation of foreground colour is open to interpretation according to the window class; it may be the text colour or other colour, or it may not be used at all.
Get the width, height, decent and leading of the text using the current or specified font.
Parameters:
Returns:
(width, height, descent, externalLeading)
Returns the grandparent of a window, or None if there isn’t one.
Returns:
On wxGTK returns a pointer to the GtkWidget for this window as a long integer. On the other platforms this method returns zero.
Returns:
long
Returns the platform-specific handle of the physical window. Cast it to an appropriate handle, such as HWND for Windows, Widget for Motif, GtkWidget for GTK or WinHandle for PalmOS.
Returns:
int
Gets the help text to be used as context-sensitive help for this window.
Returns:
string
Note
Note that the text is actually stored by the current wx.HelpProvider implementation, and not in the window object itself.
See also
Gets the help text to be used as context-sensitive help for this window.
This method should be overridden if the help message depends on the position inside the window, otherwise GetHelpText can be used.
Returns:
string
Returns the identifier of the window.
Returns:
int
Note
Each window has an integer identifier. If the application has not provided one (or the default wx.ID_ANY) an unique identifier with a negative value will be generated.
See also
Generic way of getting a label from any window, for identification purposes.
Returns:
string
Note
The interpretation of this function differs from class to class. For frames and dialogs, the value returned is the title. For buttons or text controls, it is the button text. This function can be useful for meta-programs (such as testing tools or special-needs access programs) which need to identify windows by name.
Get the layout direction (LTR or RTL) for this window.
Returns wx.Layout_Default if layout direction is not supported.
Returns:
int
Returns the maximum size of the window, an indication to the sizer layout mechanism that this is the maximum possible size.
Returns:
Returns the minimum size of the window, an indication to the sizer layout mechanism that this is the minimum required size. It normally just returns the value set by SetMinSize, but it can be overridden to do the calculation on demand.
Returns:
Returns the window’s name.
Returns:
string
Note
This name is not guaranteed to be unique; it is up to the programmer to supply an appropriate name in the window constructor or via SetName.
See also
This gets the position of the window in pixels, relative to the parent window for the child windows or relative to the display origin for the top level windows.
Returns:
See also
Get the window’s position. Notice that the position is in client coordinates for child windows and screen coordinates for the top level ones, use GetScreenPosition if you need screen coordinates for all kinds of windows.
Returns:
(x, y)
See also
Returns the window position in screen coordinates, whether the window is a child window or a top level one.
Returns:
See also
Get the position of the window in screen coordinantes.
Returns:
(x,y)
Returns the size and position of the window on the screen as a wx.Rect object.
Returns:
See also
Returns the built-in scrollbar position.
Parameters:
Returns:
int
See also
See SetScrollbar
Returns the built-in scrollbar range.
Parameters:
Returns:
int
See also
Returns the built-in scrollbar thumb size.
Parameters:
Returns:
int
See also
This gets the size of the entire window in pixels, including title bar, border, scrollbars, etc...
Returns:
See also
Get the window size.
Returns:
(width, height)
Return the sizer associated with the window by a previous call to SetSizer or None.
Returns:
Gets the dimensions of the string as it would be drawn on the window with the currently selected font.
Parameters:
Returns:
(width, height)
Return the themeEnabled flag.
Returns:
bool
Get the associated tooltip or None if none.
Returns:
Returns the first frame or dialog in this window’s parental hierarchy.
Returns:
Get the update rectangle region bounding box in client coords.
Returns:
Returns the region specifying which parts of the window have been damaged.
Should only be called within an wx.PaintEvent handler.
Returns:
See also
Returns a pointer to the current validator for the window, or None if there is none.
Returns:
This gets the virtual size of the window in pixels.
By default it returns the client size of the window, but after a call to SetVirtualSize it will return that size.
Returns:
Get the the virtual size of the window in pixels. For most windows this is just the client area of the window, but for some like scrolled windows it is more or less independent of the screen window size.
Returns:
(width, height)
Returns the size of the left/right and top/bottom borders of this window in x and y components of the result respectively.
Returns:
Gets the window style that was passed to the constructor or Create method.
GetWindowStyle() is another name for the same function.
Returns:
long
Returns the value previously passed to SetWindowVariant.
Returns:
wx.WindowVariant
Returns True if this window has the current mouse capture.
Returns:
bool
Returns True if the window has the given flag bit set.
Parameters:
Returns:
bool
This method should be overridden to return True if this window has multiple pages.
All standard class with multiple pages such as wx.Notebook, wx.Listbook and wx.Treebook already override it to return True and user-defined classes with similar behaviour should do it as well to allow the library to handle such windows appropriately.
Returns:
bool
Returns True if this window has a scroll bar for this orientation.
Parameters:
Returns:
bool
Returns True if this window background is transparent (as, for example, for wx.StaticText) and should show the parent window background.
This method is mostly used internally by the library itself and you normally shouldn’t have to call it. You may, however, have to override it in your wx.Window -derived class to ensure that background is painted correctly.
Returns:
bool
Test where the given (in client coords) point lies
Parameters:
Returns:
int
Test where the given (in client coords) point lies
Parameters:
Returns:
int
This function is (or should be, in case of custom controls) called during window creation to intelligently set up the window visual attributes, that is the font and the foreground and background colours.
By “intelligently” the following is meant: by default, all windows use their own default attributes. However if some of the parents attributes are explicitly (that is, using SetFont and not SetOwnFont) changed and if the corresponding attribute hadn’t been explicitly set for this window itself, then this window takes the same value as used by the parent. In addition, if the window overrides ShouldInheritColours to return False, the colours will not be changed no matter what and only the font might.
This rather complicated logic is necessary in order to accommodate the different usage scenarios. The most common one is when all default attributes are used and in this case, nothing should be inherited as in modern GUIs different controls use different fonts (and colours) than their siblings so they can’t inherit the same value from the parent. However it was also deemed desirable to allow to simply change the attributes of all children at once by just changing the font or colour of their common parent, hence in this case we do inherit the parents attributes.
Is the window in the process of being deleted?
Returns:
bool
Returns True if the window contents is double-buffered by the system, i.e. if any drawing done on the window is really done on a temporary backing surface and transferred to the screen all at once later.
Returns:
bool
See also
Returns True if the window is enabled for input, False otherwise.
Returns:
bool
See also
Returns True if the given rectangle area has been exposed since the last repaint.
Call this in an paint event handler to optimize redrawing by only redrawing those areas, which have been exposed.
Parameters:
Returns:
bool
Returns True if the given point area has been exposed since the last repaint.
Call this in an paint event handler to optimize redrawing by only redrawing those areas, which have been exposed.
Parameters:
Returns:
bool
Returns True if the given rectangle area has been exposed since the last repaint.
Call this in an paint event handler to optimize redrawing by only redrawing those areas, which have been exposed.
Parameters:
Returns:
bool
See also
Returns True if the window is retained, False otherwise.
Returns:
bool
Note
Retained windows are only available on X platforms.
Returns True if the window is shown, False if it has been hidden.
Returns:
bool
See also
Returns True if the window is physically visible on the screen, i.e. it is shown and all its parents up to the toplevel window are shown as well.
Returns:
bool
See also
Returns True if the given window is a top-level one.
Currently all frames and dialogs are considered to be top-level windows (even if they have a parent window).
Returns:
bool
Invokes the constraint-based layout algorithm or the sizer-based algorithm for this window.
See SetAutoLayout: when auto layout is on, this function gets called automatically when the window is resized.
See also
Disables all other windows in the application so that the user can only interact with this window.
Parameters:
Moves the window to the given position.
Parameters:
Note
Implementations of SetDimensions can also implicitly implement the Move function, which is defined in the base wx.Window class as the call:
self.SetDimensions(x, y, wx.DefaultCoord, wx.DefaultCoord, wx.SIZE_USE_EXISTING)
See also
Moves this window in the tab navigation order after the specified win. This means that when the user presses TAB key on that other window, the focus switches to this window.
Default tab order is the same as creation order, this function and MoveBeforeInTabOrder allow to change it after creating all the windows.
Parameters:
Same as MoveAfterInTabOrder except that it inserts this window just before win instead of putting it right after it.
Parameters:
Moves the window to the given position.
Parameters:
Does keyboard navigation from this window to another, by sending a wx.NavigationKeyEvent.
Parameters:
Returns:
bool
Note
You may wish to call this from a text control custom keypress handler to do the default navigation behaviour for the tab key, since the standard default behaviour for a multiline text control with the wx.TE_PROCESS_TAB style is to insert a tab and not navigate to the next control.
Generate a control id for the controls which were not given one.
Returns:
int
Get the id of the control following the one with the given (autogenerated) id.
Parameters:
Returns:
int
Parameters:
Removes and returns the top-most event handler on the event handler stack.
Parameters:
Returns:
See also
SetEventHandler, GetEventHandler, PushEventHandler, wx.EvtHandler.ProcessEvent, wx.EvtHandler
Pops up the given menu at the specified coordinates, relative to this window, and returns control when the user has dismissed the menu. If a menu item is selected, the corresponding menu event is generated and will be processed as usually. If the coordinates are not specified, the current mouse cursor position is used.
Parameters:
Returns:
bool
Note
Just before the menu is popped up, wx.Menu.UpdateUI is called to ensure that the menu items are in the correct state. The menu does not get deleted by the window. It is recommended to not explicitly specify coordinates when calling PopupMenu in response to mouse click, because some of the ports (namely, wxGTK) can do a better job of positioning the menu in that case.
See also
Pops up the given menu at the specified coordinates, relative to this window, and returns control when the user has dismissed the menu. If a menu item is selected, the corresponding menu event is generated and will be processed as usual. If the default position is given then the current position of the mouse cursor will be used.
Parameters:
Returns:
bool
Phase 3 of the 2-phase create <wink!>.
Call this method after precreating the window with the 2-phase create method.
Parameters:
Call this function to prepare the device context for drawing a scrolled image. It sets the device origin according to the current scroll position.
Parameters:
Get the id of the control preceding the one with the given (autogenerated) id.
Parameters:
Returns:
int
Pushes this event handler onto the event stack for the window.
Parameters:
Note
An event handler is an object that is capable of processing the events sent to a window. By default, the window is its own event handler, but an application may wish to substitute another, for example to allow central implementation of event-handling for a variety of different window classes. PushEventHandler allows an application to set up a chain of event handlers, where an event not handled by one event handler is handed to the next one in the chain. Use PopEventHandler to remove the event handler.
See also
SetEventHandler, GetEventHandler, PopEventHandler, wx.EvtHandler.ProcessEvent, wx.EvtHandler
Raises the window to the top of the window hierarchy (z-order).
In current version of wxWidgets this works both for managed and child windows.
See also
Causes this window, and all of its children recursively (except under wxGTK1 where this is not implemented), to be repainted.
Parameters:
Note
Note that repainting doesn’t happen immediately but only during the next event loop iteration, if you need to update the window immediately you should use Update instead.
See also
Redraws the contents of the given rectangle: only the area inside it will be repainted.
This is the same as Refresh but has a nicer syntax as it can be called with a temporary wx.Rect object as argument like this:
self.RefreshRect(wx.Rect(x, y, width, height))
Parameters:
Registers a system wide hotkey. Every time the user presses the hotkey registered here, this window will receive a hotkey event. It will receive the event even if the application is in the background and does not have the input focus because the user is working with some other application.
Parameters:
Returns:
bool
Note
You can use:
self.Bind(wx.EVT_HOTKEY, fnc, id=hotkeyId)
in the event table to capture the event.
Note
This function is currently only implemented under Windows. It is used in the Windows CE port for detecting hardware button presses.
See also
See also
CaptureMouse, HasCapture, ReleaseMouse, wx.MouseCaptureLostEvent, wx.MouseCaptureChangedEvent
Removes a child window. This is called automatically by window deletion functions so should not be required by the application programmer.
Parameters:
Note
Notice that this function is mostly internal to wxWidgets and shouldn’t be called by the user code.
Find the given handler in the windows event handler chain and remove (but not delete) it from it.
Parameters:
Returns:
bool
See also
Reparents the window, i.e the window will be removed from its current parent window (e.g. a non-standard toolbar in a wx.Frame) and then re-inserted into another.
Parameters:
Returns:
bool
Converts from screen to client window coordinates.
Parameters:
Returns:
Converts from screen to client window coordinates.
Parameters:
Returns:
(x, y)
Scrolls the window by the given number of lines down (if lines is positive) or up.
Parameters:
Returns:
bool
Note
This function is currently only implemented under MSW and wx.TextCtrl under wxGTK (it also works for wx.ScrolledWindow derived classes under all platforms).
See also
Scrolls the window by the given number of pages down (if pages is positive) or up.
Parameters:
Returns:
bool
Note
This function is currently only implemented under MSW and wxGTK.
See also
Physically scrolls the pixels in the window and move child windows accordingly.
Parameters:
Note
Note that you can often use wx.ScrolledWindow instead of using this function directly.
Sets the accelerator table for this window.
Parameters:
See also
Determines whether the Layout function will be called automatically when the window is resized.
This method is called implicitly by SetSizer but if you use SetConstraints you should call it manually or otherwise the window layout won’t be correctly updated when its size changes.
Parameters:
Note
Please note that this only happens for the windows usually used to contain children, namely wx.Panel and wx.TopLevelWindow (and the classes deriving from them).
See also
Sets the background colour of the window.
Please see InheritAttributes for explanation of the difference between this method and SetOwnBackgroundColour.
Parameters:
Returns:
bool
Note
The background colour is usually painted by the default wx.EraseEvent event handler function under Windows and automatically under GTK.
Note
Note that setting the background colour does not cause an immediate refresh, so you may wish to call ClearBackground or Refresh after calling this function. Using this function will disable attempts to use themes for this window, if the system supports them. Use with care since usually the themes represent the appearance chosen by the user to be used for all applications on the system.
See also
GetBackgroundColour, SetForegroundColour, GetForegroundColour, ClearBackground, Refresh, wx.EraseEvent
Sets the background style of the window. The background style indicates whether background colour should be determined by the system (wx.BG_STYLE_SYSTEM), be set to a specific colour (wx.BG_STYLE_COLOUR), or should be left to the application to implement (wx.BG_STYLE_CUSTOM).
On GTK+, use of wx.BG_STYLE_CUSTOM allows the flicker-free drawing of a custom background, such as a tiled bitmap. Currently the style has no effect on other platforms.
Parameters:
This sets the size of the window client area in pixels. Using this function to size a window tends to be more device-independent than SetSize, since the application need not worry about what dimensions the border or title bar have when trying to fit the window around panel items, for example.
Parameters:
This sets the size of the window client area in pixels. Using this function to size a window tends to be more device-independent than SetSize, since the application need not worry about what dimensions the border or title bar have when trying to fit the window around panel items, for example.
Parameters:
This sets the size of the window client area in pixels. Using this function to size a window tends to be more device-independent than SetSize, since the application need not worry about what dimensions the border or title bar have when trying to fit the window around panel items, for example.
Parameters:
Sets the window to have the given layout constraints. The window will then own the object, and will take care of its deletion. If an existing layout constraints object is already owned by the window, it will be deleted.
Parameters:
Note
You must call SetAutoLayout to tell a window to use the constraints automatically in OnSize; otherwise, you must override OnSize and call Layout() explicitly. When setting both a wx.LayoutConstraints and a wx.Sizer, only the sizer will have effect.
This normally does not need to be called by user code. It is called when a window is added to a sizer, and is used so the window can remove itself from the sizer when it is destroyed.
Parameters:
Sets the window’s cursor. Notice that the window cursor also sets it for the children of the window implicitly.
The cursor may be wx.NullCursor in which case the window cursor will be reset back to default.
Parameters:
See also
Sets the position and size of the window in pixels. The sizeFlags parameter indicates the interpretation of the other params if they are equal to -1.
sizeFlags may have one of this bit set:
Size Flags | Description |
---|---|
wx.SIZE_AUTO | A -1 indicates that a class-specific default should be used. |
wx.SIZE_AUTO_WIDTH | A -1 indicates that a class-specific default should be used for the width. |
wx.SIZE_AUTO_HEIGHT | A -1 indicates that a class-specific default should be used for the height. |
wx.SIZE_USE_EXISTING | Existing dimensions should be used if -1 values are supplied. |
wx.SIZE_ALLOW_MINUS_ONE | Allow dimensions of -1 and less to be interpreted as real dimensions, not default values. |
wx.SIZE_FORCE | Normally, if the position and the size of the window are already the same as the parameters of this function, nothing is done. but with this flag a window resize may be forced even in this case (supported in wx 2.6.2 and later and only implemented for MSW and ignored elsewhere currently) |
Parameters:
Put the native window into double buffered or composited mode.
Parameters:
Associates a drop target with this window.
If the window already has a drop target, it is deleted.
Parameters:
See also
Sets the event handler for this window.
Parameters:
Note
An event handler is an object that is capable of processing the events sent to a window. By default, the window is its own event handler, but an application may wish to substitute another, for example to allow central implementation of event-handling for a variety of different window classes. It is usually better to use PushEventHandler since this sets up a chain of event handlers, where an event not handled by one event handler is handed to the next one in the chain.
See also
GetEventHandler, PushEventHandler, PopEventHandler, wx.EvtHandler.ProcessEvent, wx.EvtHandler
Sets the extra style bits for the window. The currently defined extra style bits are:
Window Extra Style | Description |
---|---|
wx.WS_EX_VALIDATE_RECURSIVELY | By default, Validate / TransferDataToWindow / TransferDataFromWindow only work on direct children of the window (compatible behaviour). Set this flag to make them recursively descend into all subwindows. |
wx.WS_EX_BLOCK_EVENTS | wx.CommandEvents and the objects of the derived classes are forwarded to the parent window and so on recursively by default. Using this flag for the given window allows to block this propagation at this window, i.e. prevent the events from being propagated further upwards. Dialogs have this flag on by default. |
wx.WS_EX_TRANSIENT | Don’t use this window as an implicit parent for the other windows: this must be used with transient windows as otherwise there is the risk of creating a dialog/frame with this window as a parent which would lead to a crash if the parent is destroyed before the child. |
wx.WS_EX_PROCESS_IDLE | This window should always process idle events, even if the mode set by wx.IdleEvent.SetMode is wx.IDLE_PROCESS_SPECIFIED. |
wx.WS_EX_PROCESS_UI_UPDATES | This window should always process UI update events, even if the mode set by wx.UpdateUIEvent.SetMode is wx.UPDATE_UI_PROCESS_SPECIFIED. |
Parameters:
Sets the font for this window.
This function should not be called for the parent window if you don’t want its font to be inherited by its children, use SetOwnFont instead in this case and see InheritAttributes for more explanations.
Parameters:
Note
Please notice that the given font is not automatically used for wx.PaintDC objects associated with this window, you need to call wx.DC.SetFont too. However this font is used by any standard controls for drawing their text as well as by GetTextExtent.
See also
Sets the foreground colour of the window.
Please see InheritAttributes for explanation of the difference between this method and SetOwnForegroundColour.
Parameters:
Note
The interpretation of foreground colour is open to interpretation according to the window class; it may be the text colour or other colour, or it may not be used at all.
Sets the help text to be used as context-sensitive help for this window.
Parameters:
Note
Note that the text is actually stored by the current wx.HelpProvider implementation, and not in the window object itself.
See also
Associate this help text with all windows with the same id as this one.
Parameters:
Sets the identifier of the window.
Parameters:
Note
Each window has an integer identifier. If the application has not provided one, an identifier will be generated. Normally, the identifier should be provided on creation and should not be modified subsequently.
See also
A smart SetSize that will fill in default size components with the window’s best size values. Also sets the window’s minsize to the value passed in for use with sizers.
This means that if a full or partial size is passed to this function then the sizers will use that size instead of the results of GetBestSize to determine the minimum needs of the window for layout.
Most controls will use this to set their initial size, and their min size to the passed in value (if any.)
Parameters:
See also
Sets the window’s label.
Parameters:
See also
Set the layout direction (LTR or RTL) for this window.
Parameters:
Sets the maximum size of the window, to indicate to the sizer layout mechanism that this is the maximum possible size.
Parameters:
Sets the minimum size of the window, to indicate to the sizer layout mechanism that this is the minimum required size.
You may need to call this if you change the window size after construction and before adding to its parent sizer.
Parameters:
Sets the window’s name.
Parameters:
See also
Sets the background colour of the window but prevents it from being inherited by the children of this window.
Parameters:
See also
Sets the font of the window but prevents it from being inherited by the children of this window.
Parameters:
See also
Sets the foreground colour of the window but prevents it from being inherited by the children of this window.
Parameters:
See also
Sets the position and size of the window in pixels using a wx.Rect object.
Parameters:
Sets the position of one of the built-in scrollbars.
Parameters:
Note
This function does not directly affect the contents of the window: it is up to the application to take note of scrollbar attributes and redraw contents accordingly.
See also
SetScrollbar, GetScrollPos, GetScrollThumb, wx.ScrollBar, wx.ScrolledWindow
Sets the scrollbar properties of a built-in scrollbar.
Parameters:
Note
Let’s say you wish to display 50 lines of text, using the same font. The window is sized so that you can only see 16 lines at a time. You would use:
self.SetScrollbar(wx.VERTICAL, 0, 16, 50)
Note that with the window at this size, the thumb position can never go above 50 minus 16, or 34.
Note
You can determine how many lines are currently visible by dividing the current view size by the string character height in pixels. When defining your own scrollbar behaviour, you will always need to recalculate the scrollbar settings when the window size changes. You could therefore put your scrollbar calculations and SetScrollbar call into a function named AdjustScrollbars, which can be called initially and also from your wx.SizeEvent handler function.
See also
Sets the size of the window in pixels.
Parameters:
See also
Allows specification of minimum and maximum window sizes, and window size increments. If a pair of values is not set (or set to -1), the default values will be used.
Sizers will also inspect the minimum window size and will use that value if set when calculating layout.
The resizing increments are only significant under Motif or Xt.
Parameters:
Note
Use of this function for windows which are not toplevel windows (such as wx.Dialog or wx.Frame) is discouraged. Please use SetMinSize and SetMaxSize instead.
See also
Allows specification of minimum and maximum window sizes, and window size increments. If a pair of values is not set (or set to -1), the default values will be used.
Sizers will also inspect the minimum window size and will use that value if set when calculating layout.
The resizing increments are only significant under Motif or Xt.
Parameters:
Sets the size of the window in pixels.
Parameters:
Sets the window to have the given layout sizer. The window will then own the object, and will take care of its deletion.
If an existing layout constraints object is already owned by the window, it will be deleted if the deleteOld parameter is True.
Parameters:
Note
Note that this function will also call SetAutoLayout implicitly with True parameter if the sizer is not None and False otherwise.
Note
SetSizer now enables and disables layout automatically.
The same as SetSizer, except it also sets the size hints for the window based on the sizer’s minimum size.
Parameters:
This function tells a window if it should use the system’s “theme” code to draw the windows’ background instead if its own background drawing code. This does not always have any effect since the underlying platform obviously needs to support the notion of themes in user defined windows.
One such platform is GTK+ where windows can have (very colourful) backgrounds defined by a user’s selected theme.
Dialogs, notebook pages and the status bar have this flag set to True by default so that the default look and feel is simulated best.
Parameters:
Attach a tooltip to the window.
Parameters:
See also
Attach a tooltip to the window.
Parameters:
Attempt to set the transparency of this window to the alpha value, returns True on success.
The alpha value is an integer in the range of 0 to 255, where 0 is fully transparent and 255 is fully opaque.
Parameters:
Returns:
bool
Deletes the current validator (if any) and sets the window validator, having called wx.Validator.Clone to create a new validator of this type.
Parameters:
Allows specification of minimum and maximum virtual window sizes. If a pair of values is not set (or set to -1), the default values will be used.
Parameters:
- minW (int): Minimum width.
- minH (int): Minimum height.
- maxW (int): Maximum width.
- maxH (int): Maximum height.
Note
If this function is called, the user will not be able to size the area of the window outside the given bounds.
Allows specification of minimum and maximum virtual window sizes. If a pair of values is not set (or set to -1), the default values will be used.
Parameters:
Note
If this function is called, the user will not be able to size the area of the window outside the given bounds.
Set the the virtual size of a window in pixels. For most windows this is just the client area of the window, but for some like scrolled windows it is more or less independent of the screen window size.
Parameters:
Identical to SetWindowStyleFlag.
Parameters:
Sets the style of the window.
Parameters:
Note
Please note that some styles cannot be changed after the window creation and that Refresh might need to be be called after changing the others for the change to take place immediately.
See also
This function can be called under all platforms but only does anything under Mac OS X 10.3+ currently. Under this system, each of the standard control can exist in several sizes which correspond to the elements of wx.WindowVariant enum:
wx.WindowVariant | Description |
---|---|
wx.WINDOW_VARIANT_NORMAL | Normal size |
wx.WINDOW_VARIANT_SMALL | Smaller size (about 25 % smaller than normal) |
wx.WINDOW_VARIANT_MINI | Mini size (about 33 % smaller than normal) |
wx.WINDOW_VARIANT_LARGE | Large size (about 25 % larger than normal) |
By default the controls use the normal size, of course, but this function can be used to change this.
Parameters:
Return True from here to allow the colours of this window to be changed by InheritAttributes, returning False forbids inheriting them from the parent window.
The base class version returns False, but this method is overridden in wx.Control where it returns True.
Returns:
bool
Shows or hides the window.
You may need to call Raise for a top level window if you want to bring it to top, although this is not needed if Show() is called immediately after the frame creation.
Parameters:
Returns:
bool
See also
Turns the given flag on if it’s currently turned off and vice versa.
This function cannot be used if the value of the flag is 0 (which is often the case for default flags).
Parameters:
Returns:
bool
Note
Please notice that not all styles can be changed after the control creation.
See also
Transfers values from child controls to data areas specified by their validators. Returns False if a transfer failed.
If the window has wx.WS_EX_VALIDATE_RECURSIVELY extra style flag set, the method will also call TransferDataFromWindow() of all child windows.
Returns:
bool
See also
Transfers values to child controls from data areas specified by their validators.
If the window has wx.WS_EX_VALIDATE_RECURSIVELY extra style flag set, the method will also call TransferDataToWindow() of all child windows.
Returns:
bool
See also
Unregisters a system wide hotkey.
Parameters:
Returns:
bool
Note
This function is currently only implemented under MSW.
See also
Note
Notice that this function doesn’t invalidate any area of the window so nothing happens if nothing has been invalidated (i.e. marked as requiring a redraw). Use Refresh first if you want to immediately redraw the window unconditionally.
This function sends wx.UpdateUIEvents to the window.
The particular implementation depends on the window; for example a wx.ToolBar will send an update UI event for each toolbar button, and a wx.Frame will send an update UI event for each menubar menu item. You can call this function from your application to ensure that your UI is up-to-date at this point (as far as your wx.UpdateUIEvent handlers are concerned). This may be necessary if you have called wx.UpdateUIEvent.SetMode or wx.UpdateUIEvent.SetUpdateInterval to limit the overhead that wxWidgets incurs by sending update UI events in idle time.
flags should be a bitlist of one or more of the following values:
Update Flags | Description |
---|---|
wx.UPDATE_UI_NONE | = 0x0000, No particular value |
wx.UPDATE_UI_RECURSE | = 0x0001, Call the function for descendants |
wx.UPDATE_UI_FROMIDLE | = 0x0002, Invoked from On(Internal)Idle |
If you are calling this function from an OnInternalIdle or OnIdle function, make sure you pass the wx.UPDATE_UI_FROMIDLE flag, since this tells the window to only update the UI elements that need to be updated in idle time. Some windows update their elements only when necessary, for example when a menu is about to be shown.
Parameters:
See also
Validates the current values of the child controls using their validators.
If the window has wx.WS_EX_VALIDATE_RECURSIVELY extra style flag set, the method will also call Validate() of all child windows.
Returns:
bool
Moves the pointer to the given position on the window.
Parameters:
Note
This function is not supported under Mac because Apple Human Interface Guidelines forbid moving the mouse cursor programmatically.
Converts window size size to corresponding client area size. In other words, the returned value is what would GetClientSize return if this window had given window size. Components with wx.DefaultCoord value are left unchanged.
This function is new since wxWidgets version 2.8.8
Parameters:
Returns:
Note
Note that the conversion is not always exact, it assumes that non-client area doesn’t change and so doesn’t take into account things like menu bar (un)wrapping or (dis)appearance of the scrollbars.