wx.Window

Inheritance diagram for wx.Window:



Description

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.

Derived From

Known Subclasses

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

Window Styles

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.

Extra Window Styles

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.

Methods Summary

Class API

Methods

__init__(parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name=wx.PanelNameStr)

Construct and show a generic wx.Window.

Parameters:


Returns:

wx.Window


AcceptsFocus()

Can this window have focus?


Returns:

bool


AcceptsFocusFromKeyboard()

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


AddChild(child)

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.


AdjustForLayoutDirection(x, width, widthTotal)

Mirror coordinates for RTL layout if this window uses it and if the mirroring is not done automatically like Win32.

Parameters:

  • x (int)
  • width (int)
  • widthTotal (int)

Returns:

int


AssociateHandle(handle)

Associate the window with a new native handle.


Parameters:

  • handle (long)

CacheBestSize(size)

Sets the cached best size value.

Parameters:


CanSetTransparent()

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.


CaptureMouse()
Directs all mouse input to this window. Call ReleaseMouse to release the capture.

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.


Center(direction)

A synonym for Centre.

Parameters:

  • direction (int)

CenterOnParent(direction)

A synonym for CentreOnParent.

Parameters:

  • direction (int)

Centre(direction=wx.BOTH)

Centres the window.

Parameters:

  • direction (int): Specifies the direction for the centering. May be wx.HORIZONTAL, wx.VERTICAL or wx.BOTH. It may also include wx.CENTRE_ON_SCREEN flag if you want to center the window on the entire screen and not on its parent window.

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

Center


CentreOnParent(direction=wx.BOTH)

Centres the window on its parent. This is a more readable synonym for Centre.

Parameters:

  • direction (int): Specifies the direction for the centering. May be wx.HORIZONTAL, wx.VERTICAL or wx.BOTH.

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

CentreOnScreen


ClearBackground()
Clears the window by filling it with the current background colour. Does not cause an erase background event to be generated.

ClientToScreen(pt)

Converts to screen coordinates from coordinates relative to this window.

Parameters:


Returns:

wx.Point


ClientToScreenXY(x, y)

Converts to screen coordinates from coordinates relative to this window.

Parameters:

  • x (int)
  • y (int)

Returns:

(x, y)


ClientToWindowSize(size)

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:

wx.Size

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.


Close(force=False)

This function simply generates a wx.CloseEvent whose handler usually tries to close the window. It doesn’t close the window itself, however.

Parameters:

  • force (bool): False if the window’s close handler should be able to veto the destruction of this window, True if it cannot.

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.


ConvertDialogPointToPixels(pt)

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:

wx.Point


ConvertDialogSizeToPixels(sz)

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:

wx.Size


ConvertPixelPointToDialog(pt)

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:

wx.Point


ConvertPixelSizeToDialog(sz)

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:

wx.Size


Create(parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name=wx.PanelNameStr)

Create the GUI part of the Window for 2-phase creation mode.

Parameters:


Returns:

bool


DLG_PNT(pt)

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:

wx.Point


DLG_SZE(sz)

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:

wx.Size


Destroy()

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


DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.

Disable()

Disables the window, same as Enable (False).


Returns:

bool


DissociateHandle()
Dissociate the current native handle from the window

DragAcceptFiles(accept)

Enables or disables eligibility for drop file events (OnDropFiles).

Parameters:

  • accept (bool): If True, the window is eligible for drop file events. If False, the window will not accept drop file events.

Note

Windows only.


Enable(enable=True)

Enable or disable the window for user input.

Parameters:

  • enable (bool): If True, enables the window for input. If False, disables the window.

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.


FindFocus()

Finds the window or control which currently has the keyboard focus.


Returns:

wx.Window

Note

Note that this is a function, so it can be called without needing a wx.Window pointer.

See also

SetFocus


FindWindowById(id)

Find the first window with the given id.

Parameters:

  • id (long)

Returns:

wx.Window

See also

FindWindow


FindWindowByLabel(label)

Find a window by its label. Depending on the type of window, the label may be a window title or panel item label.

Parameters:

  • label (string)

Returns:

wx.Window

See also

FindWindow


FindWindowByName(name)

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:

  • name (string)

Returns:

wx.Window

See also

FindWindow


Fit()

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.


FitInside()

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.


Freeze()

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.


GetAcceleratorTable()

Gets the accelerator table for this window.


Returns:

wx.AcceleratorTable


GetAdjustedBestSize()

Use GetEffectiveMinSize instead.


Returns:

wx.Size

Warning

This method is deprecated.


GetAutoLayout()

Returns the current auto layout setting.

Returns:

bool


GetBackgroundColour()

Returns the background colour of the window.


Returns:

wx.Colour


GetBackgroundStyle()

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


GetBestSize()

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:

wx.Size


GetBestSizeTuple()

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)


GetBestVirtualSize()

Return the largest of ClientSize and BestSize (as determined by a sizer, interior children, or other means).


Returns:

wx.Size


GetBorder(flags)

Get border for the flags of this window

Parameters:

  • flags (long)

Returns:

int


GetCapture()

Returns the currently captured window.


Returns:

wx.Window


GetCaret()

Returns the caret associated with the window.


Returns:

wx.Caret


GetCharHeight()

Returns the character height for this window.


Returns:

int


GetCharWidth()

Returns the average character width for this window.


Returns:

int


GetChildren()

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


GetClassDefaultAttributes(variant=wx.WINDOW_VARIANT_NORMAL)

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:

  • variant (wx.WindowVariant)

Returns:

wx.VisualAttributes


GetClientAreaOrigin()

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:

wx.Point


GetClientRect()

Get the client area position and size as a wx.Rect object.


Returns:

wx.Rect


GetClientSize()

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:

wx.Size


GetClientSizeTuple()

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)


GetConstraints()

Returns a pointer to the window’s layout constraints, or None if there are none.


Returns:

wx.LayoutConstraints


GetContainingSizer()

Return the sizer that this window is a member of, if any, otherwise None.


Returns:

wx.Sizer


GetCursor()

Return the cursor associated with this window.


Returns:

wx.Cursor

See also

SetCursor


GetDefaultAttributes()

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


GetDropTarget()

Returns the associated drop target, which may be None.


Returns:

wx.DropTarget

See also

SetDropTarget


GetEffectiveMinSize()

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:

wx.Size


GetEventHandler()

Returns the event handler for this window.

By default, the window is its own event handler.


Returns:

wx.EvtHandler


GetExtraStyle()

Returns the extra style bits for the window.


Returns:

long


GetFont()

Returns the font for this window.


Returns:

wx.Font

See also

SetFont


GetForegroundColour()

Returns the foreground colour of the window.


Returns:

wx.Colour

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.


GetFullTextExtent(string, font=None)

Get the width, height, decent and leading of the text using the current or specified font.

Parameters:


Returns:

(width, height, descent, externalLeading)


GetGrandParent()

Returns the grandparent of a window, or None if there isn’t one.


Returns:

wx.Window


GetGtkWidget()

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


GetHandle()

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


GetHelpText()

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.


GetHelpTextAtPoint()

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


GetId()

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

SetId


GetLabel()

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.


GetLayoutDirection()

Get the layout direction (LTR or RTL) for this window.

Returns wx.Layout_Default if layout direction is not supported.


Returns:

int


GetMaxHeight()
No docstrings available for this method.

GetMaxSize()

Returns the maximum size of the window, an indication to the sizer layout mechanism that this is the maximum possible size.


Returns:

wx.Size


GetMaxWidth()
No docstrings available for this method.

GetMinHeight()
No docstrings available for this method.

GetMinSize()

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:

wx.Size


GetMinWidth()
No docstrings available for this method.

GetName()

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

SetName


GetParent()

Returns the parent of the window, or None if there is no parent.


Returns:

wx.Window


GetPosition()

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:

wx.Point


GetPositionTuple()

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)


GetRect()

Returns the size and position of the window as a wx.Rect object.


Returns:

wx.Rect

See also

GetScreenRect


GetScreenPosition()

Returns the window position in screen coordinates, whether the window is a child window or a top level one.


Returns:

wx.Point

See also

GetPosition


GetScreenPositionTuple()

Get the position of the window in screen coordinantes.


Returns:

(x,y)


GetScreenRect()

Returns the size and position of the window on the screen as a wx.Rect object.


Returns:

wx.Rect

See also

GetRect


GetScrollPos(orientation)

Returns the built-in scrollbar position.

Parameters:

  • orientation (int)

Returns:

int

See also

See SetScrollbar


GetScrollRange(orientation)

Returns the built-in scrollbar range.

Parameters:

  • orientation (int)

Returns:

int

See also

SetScrollbar


GetScrollThumb(orientation)

Returns the built-in scrollbar thumb size.

Parameters:

  • orientation (int)

Returns:

int

See also

SetScrollbar


GetSize()

This gets the size of the entire window in pixels, including title bar, border, scrollbars, etc...


Returns:

wx.Size


GetSizeTuple()

Get the window size.


Returns:

(width, height)


GetSizer()

Return the sizer associated with the window by a previous call to SetSizer or None.


Returns:

wx.Sizer


GetTextExtent(string)

Gets the dimensions of the string as it would be drawn on the window with the currently selected font.

Parameters:

  • string (string): String whose extent is to be measured.

Returns:

(width, height)


GetThemeEnabled()

Return the themeEnabled flag.


Returns:

bool


GetToolTip()

Get the associated tooltip or None if none.


Returns:

wx.ToolTip


GetTopLevelParent()

Returns the first frame or dialog in this window’s parental hierarchy.


Returns:

wx.Window


GetUpdateClientRect()

Get the update rectangle region bounding box in client coords.


Returns:

wx.Rect


GetUpdateRegion()

Returns the region specifying which parts of the window have been damaged.

Should only be called within an wx.PaintEvent handler.


Returns:

wx.Region


GetValidator()

Returns a pointer to the current validator for the window, or None if there is none.


Returns:

wx.Validator


GetVirtualSize()

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:

wx.Size


GetVirtualSizeTuple()

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)


GetWindowBorderSize()

Returns the size of the left/right and top/bottom borders of this window in x and y components of the result respectively.


Returns:

wx.Size


GetWindowStyleFlag()

Gets the window style that was passed to the constructor or Create method.

GetWindowStyle() is another name for the same function.


Returns:

long


GetWindowVariant()

Returns the value previously passed to SetWindowVariant.


Returns:

wx.WindowVariant


HasCapture()

Returns True if this window has the current mouse capture.


Returns:

bool


HasFlag(flag)

Returns True if the window has the given flag bit set.

Parameters:

  • flag (int)

Returns:

bool


HasMultiplePages()

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


HasScrollbar(orient)

Returns True if this window has a scroll bar for this orientation.

Parameters:

  • orient (int): Orientation to check, either wx.HORIZONTAL or wx.VERTICAL.

Returns:

bool


HasTransparentBackground()

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


Hide()

Equivalent to calling Show (False).


Returns:

bool


HitTest(pt)

Test where the given (in client coords) point lies

Parameters:


Returns:

int


HitTestXY(x, y)

Test where the given (in client coords) point lies

Parameters:

  • x (int)
  • y (int)

Returns:

int


InheritAttributes()

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.


InheritsBackgroundColour()
No docstrings available for this method.

InitDialog()
Sends an wx.EVT_INIT_DIALOG event, whose handler usually transfers data to the dialog via validators.

InvalidateBestSize()
Resets the cached best size value so it will be recalculated the next time it is needed.

IsBeingDeleted()

Is the window in the process of being deleted?


Returns:

bool


IsDoubleBuffered()

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

wx.BufferedDC


IsEnabled()

Returns True if the window is enabled for input, False otherwise.


Returns:

bool

See also

Enable


IsExposed(x, y, w=1, h=1)

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:

  • x (int)
  • y (int)
  • w (int)
  • h (int)

Returns:

bool


IsExposedPoint(pt)

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


IsExposedRect(rect)

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


IsFrozen()

Returns True if the window is currently frozen by a call to Freeze.


Returns:

bool

See also

Thaw


IsRetained()

Returns True if the window is retained, False otherwise.


Returns:

bool

Note

Retained windows are only available on X platforms.


IsShown()

Returns True if the window is shown, False if it has been hidden.


Returns:

bool

See also

IsShownOnScreen


IsShownOnScreen()

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

IsShown


IsTopLevel()

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


Layout()

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.


Lower()
Lowers the window to the bottom of the window hierarchy (z-order).

See also

Raise


MakeModal(modal)

Disables all other windows in the application so that the user can only interact with this window.

Parameters:

  • modal (bool): If True, this call disables all other windows in the application so that the user can only interact with this window. If False, the effect is reversed

Move(pt, flags=wx.SIZE_USE_EXISTING)

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

SetDimensions


MoveAfterInTabOrder(win)

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:

  • win (wx.Window): A sibling of this window which should precede it in tab order, must not be None

MoveBeforeInTabOrder(win)

Same as MoveAfterInTabOrder except that it inserts this window just before win instead of putting it right after it.

Parameters:


MoveXY(x, y, flags=wx.SIZE_USE_EXISTING)

Moves the window to the given position.

Parameters:

  • x (int)
  • y (int)
  • flags (int)

Does keyboard navigation from this window to another, by sending a wx.NavigationKeyEvent.

Parameters:

  • flags (int): A combination of wx.NavigationKeyEvent.IsForward and wx.NavigationKeyEvent.WinChange.

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.


NewControlId()

Generate a control id for the controls which were not given one.


Returns:

int


NextControlId(winid)

Get the id of the control following the one with the given (autogenerated) id.

Parameters:

  • winid (int)

Returns:

int


OnPaint(event)

Parameters:


PopEventHandler(deleteHandler=False)

Removes and returns the top-most event handler on the event handler stack.

Parameters:

  • deleteHandler (bool): If this is True, the handler will be deleted after it is removed. The default value is False.

Returns:

wx.EvtHandler


PopupMenu(menu, pos=wx.DefaultPosition)

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:

  • menu (wx.Menu): Menu to pop up.
  • pos (wx.Point): The position where the menu will appear.

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

wx.Menu


PopupMenuXY(menu, x=-1, y=-1)

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


PostCreate(pre)

Phase 3 of the 2-phase create <wink!>.

Call this method after precreating the window with the 2-phase create method.

Parameters:

  • pre

PrepareDC(dc)

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:


PrevControlId(winid)

Get the id of the control preceding the one with the given (autogenerated) id.

Parameters:

  • winid (int)

Returns:

int


PushEventHandler(handler)

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.


Raise()

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

Lower


Refresh(eraseBackground=True, rect=None)

Causes this window, and all of its children recursively (except under wxGTK1 where this is not implemented), to be repainted.

Parameters:

  • eraseBackground (bool): If True, the background will be erased.
  • rect (wx.Rect): If not None, only the given rectangle will be treated as damaged.

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

RefreshRect


RefreshRect(rect, eraseBackground=True)

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:

  • rect (wx.Rect)
  • eraseBackground (bool)

RegisterHotKey(hotkeyId, modifiers)

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:

  • hotkeyId (int): Numeric identifier of the hotkey. For applications this must be between 0 and 0xBFFF. If this function is called from a shared DLL, it must be a system wide unique identifier between 0xC000 and 0xFFFF. This is a MSW specific detail.
  • modifiers (int): A bitwise combination of wx.MOD_SHIFT, wx.MOD_CONTROL, wx.MOD_ALT or wx.MOD_WIN specifying the modifier keys that have to be pressed along with the key.

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

UnregisterHotKey


ReleaseMouse()
Releases mouse input captured with CaptureMouse.

RemoveChild(child)

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.


RemoveEventHandler(handler)

Find the given handler in the windows event handler chain and remove (but not delete) it from it.

Parameters:

  • handler (wx.EvtHandler): The event handler to remove, must be non- None and must be present in this windows event handlers chain

Returns:

bool


Reparent(newParent)

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


ScreenToClient(pt)

Converts from screen to client window coordinates.

Parameters:


Returns:

wx.Point


ScreenToClientXY(x, y)

Converts from screen to client window coordinates.

Parameters:

  • x (int)
  • y (int)

Returns:

(x, y)


ScrollLines(lines)

Scrolls the window by the given number of lines down (if lines is positive) or up.

Parameters:

  • lines (int)

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

ScrollPages


ScrollPages(pages)

Scrolls the window by the given number of pages down (if pages is positive) or up.

Parameters:

  • pages (int)

Returns:

bool

Note

This function is currently only implemented under MSW and wxGTK.

See also

ScrollLines


ScrollWindow(dx, dy, rect=None)

Physically scrolls the pixels in the window and move child windows accordingly.

Parameters:

  • dx (int): Amount to scroll horizontally.
  • dy (int): Amount to scroll vertically.
  • rect (wx.Rect): Rectangle to scroll, if it is None, the whole window is scrolled (this is always the case under wxGTK which doesn’t support this parameter)

Note

Note that you can often use wx.ScrolledWindow instead of using this function directly.


SendSizeEvent()
No docstrings available for this method.

SetAcceleratorTable(accel)

Sets the accelerator table for this window.

Parameters:


SetAutoLayout(autoLayout)

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:

  • autoLayout (bool): Set this to True if you wish the Layout function to be called automatically when the window is resized.

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

SetConstraints


SetBackgroundColour(colour)

Sets the background colour of the window.

Please see InheritAttributes for explanation of the difference between this method and SetOwnBackgroundColour.

Parameters:

  • colour (wx.Colour): The colour to be used as the background colour, pass wx.NullColour to reset to the default colour.

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.


SetBackgroundStyle(style)

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:

  • style (int)

SetCaret(caret)

Sets the caret associated with the window.

Parameters:


SetClientRect(rect)

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:


SetClientSize(size)

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:


SetClientSizeWH(width, height)

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:

  • width (int)
  • height (int)

SetConstraints(constraints)

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:

  • constraints (wx.LayoutConstraints): The constraints to set. Pass None to disassociate and delete the window’s constraints.

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.


SetContainingSizer(sizer)

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:


SetCursor(cursor)

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:

  • cursor (wx.Cursor): Specifies the cursor that the window should normally display.

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

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:

  • x (int)
  • y (int)
  • width (int)
  • height (int)
  • sizeFlags (int)

SetDoubleBuffered(on)

Put the native window into double buffered or composited mode.

Parameters:

  • on (bool)

SetDropTarget(target)

Associates a drop target with this window.

If the window already has a drop target, it is deleted.

Parameters:

See also

GetDropTarget


SetEventHandler(handler)

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.


SetExtraStyle(exStyle)

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:

  • exStyle (long)

SetFocus()
This sets the window to receive keyboard input.

SetFocusFromKbd()
This function is called by wxWidgets keyboard navigation code when the user gives the focus to this window from keyboard (e.g. using TAB key). By default this method simply calls SetFocus but can be overridden to do something in addition to this in the derived classes.

SetFont(font)

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:

  • font (wx.Font): Font to associate with this window, pass wx.NullFont to reset to the default font.

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.


SetForegroundColour(colour)

Sets the foreground colour of the window.

Please see InheritAttributes for explanation of the difference between this method and SetOwnForegroundColour.

Parameters:

  • colour (wx.Colour): The colour to be used as the foreground colour, pass wx.NullColour to reset to the default colour.

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.


SetHelpText(helpText)

Sets the help text to be used as context-sensitive help for this window.

Parameters:

  • helpText (string)

Note

Note that the text is actually stored by the current wx.HelpProvider implementation, and not in the window object itself.


SetHelpTextForId(text)

Associate this help text with all windows with the same id as this one.

Parameters:

  • text (string)

SetId(id)

Sets the identifier of the window.

Parameters:

  • id (int)

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

GetId


SetInitialSize(size=wx.DefaultSize)

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:


SetLabel(label)

Sets the window’s label.

Parameters:

  • label (string): The window label.

See also

GetLabel


SetLayoutDirection(dir)

Set the layout direction (LTR or RTL) for this window.

Parameters:

  • dir (int)

SetMaxSize(size)

Sets the maximum size of the window, to indicate to the sizer layout mechanism that this is the maximum possible size.

Parameters:


SetMinSize(size)

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:


SetName(name)

Sets the window’s name.

Parameters:

  • name (string): A name to set for the window.

See also

GetName


SetOwnBackgroundColour(colour)

Sets the background colour of the window but prevents it from being inherited by the children of this window.

Parameters:


SetOwnFont(font)

Sets the font of the window but prevents it from being inherited by the children of this window.

Parameters:


SetOwnForegroundColour(colour)

Sets the foreground colour of the window but prevents it from being inherited by the children of this window.

Parameters:


SetRect(rect, sizeFlags=wx.SIZE_AUTO)

Sets the position and size of the window in pixels using a wx.Rect object.

Parameters:


SetScrollPos(orientation, pos, refresh=True)

Sets the position of one of the built-in scrollbars.

Parameters:

  • orientation (int): Determines the scrollbar whose position is to be set. May be wx.HORIZONTAL or wx.VERTICAL.
  • pos (int): Position in scroll units.
  • refresh (bool): True to redraw the scrollbar, False otherwise.

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.


SetScrollbar(orientation, position, thumbSize, range, refresh=True)

Sets the scrollbar properties of a built-in scrollbar.

Parameters:

  • orientation (int): Determines the scrollbar whose page size is to be set. May be wx.HORIZONTAL or wx.VERTICAL.
  • position (int): The position of the scrollbar in scroll units.
  • thumbSize (int): The size of the thumb, or visible portion of the scrollbar, in scroll units.
  • range (int): The maximum position of the scrollbar.
  • refresh (bool): True to redraw the scrollbar, False otherwise.

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.


SetSize(size)

Sets the size of the window in pixels.

Parameters:

  • size (wx.Size): wx.Size object for setting the size.

See also

Move


SetSizeHints(minW, minH, maxW=-1, maxH=-1, incW=-1, incH=-1)

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:

  • minW (int): Minimum width.
  • minH (int): Minimum height.
  • maxW (int): Maximum width.
  • maxH (int): Maximum height.
  • incW (int): Specifies the increment for sizing the width (Motif/Xt only).
  • incH (int): Specifies the increment for sizing the height (Motif/Xt only).

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.


SetSizeHintsSz(minSize, maxSize=wx.DefaultSize, incSize=wx.DefaultSize)

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:


SetSizeWH(width, height)

Sets the size of the window in pixels.

Parameters:

  • width (int)
  • height (int)

SetSizer(sizer, deleteOld=True)

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:

  • sizer (wx.Sizer): The sizer to set. Pass None to disassociate and conditionally delete the window’s sizer. See below.
  • deleteOld (bool): If True (the default), this will delete any prexisting sizer. Pass False if you wish to handle deleting the old sizer yourself.

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.


SetSizerAndFit(sizer, deleteOld=True)

The same as SetSizer, except it also sets the size hints for the window based on the sizer’s minimum size.

Parameters:


SetThemeEnabled(enable)

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:

  • enable (bool)

SetToolTip(tip)

Attach a tooltip to the window.

Parameters:


SetToolTipString(tip)

Attach a tooltip to the window.

Parameters:

  • tip (string)

SetTransparent(alpha)

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:

  • alpha (int): Determines how opaque or transparent the window will be, if the platform supports the opreration. A value of 0 sets the window to be fully transparent, and a value of 255 sets the window to be fully opaque.

Returns:

bool


SetValidator(validator)

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:


SetVirtualSize(size)

Sets the virtual size of the window in pixels.

Parameters:


SetVirtualSizeHints(minW, minH, maxW=-1, maxH=-1)

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.


SetVirtualSizeHintsSz(minSize, maxSize=wx.DefaultSize)

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.


SetVirtualSizeWH(w, h)

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:

  • w (int)
  • h (int)

SetWindowStyle(style)

Identical to SetWindowStyleFlag.

Parameters:

  • style (long)

SetWindowStyleFlag(style)

Sets the style of the window.

Parameters:

  • style (long)

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.


SetWindowVariant(variant)

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:

  • variant (wx.WindowVariant)

ShouldInheritColours()

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


Show(show=True)

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:

  • show (bool)

Returns:

bool


Thaw()
Reenables window updating after a previous call to Freeze. To really thaw the control, it must be called exactly the same number of times as Freeze.

ToggleWindowStyle(flag)

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:

  • flag (int)

Returns:

bool

Note

Please notice that not all styles can be changed after the control creation.


TransferDataFromWindow()

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


TransferDataToWindow()

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


UnregisterHotKey(hotkeyId)

Unregisters a system wide hotkey.

Parameters:

  • hotkeyId (int): Numeric identifier of the hotkey. Must be the same id that was passed to RegisterHotKey.

Returns:

bool

Note

This function is currently only implemented under MSW.

See also

RegisterHotKey


Update()
Calling this method immediately repaints the invalidated area of the window and all of its children recursively while this would usually only happen when the flow of control returns to the event loop.

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.


UpdateWindowUI(flags=wx.UPDATE_UI_NONE)

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:

  • flags (long)

See also

wx.UpdateUIEvent


UseBgCol()
No docstrings available for this method.

Validate()

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


WarpPointer(x, y)

Moves the pointer to the given position on the window.

Parameters:

  • x (int): The new x position for the cursor.
  • y (int): The new y position for the cursor.

Note

This function is not supported under Mac because Apple Human Interface Guidelines forbid moving the mouse cursor programmatically.


WindowToClientSize(size)

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:

wx.Size

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.


Properties

AcceleratorTable
See GetAcceleratorTable and SetAcceleratorTable
AutoLayout
See GetAutoLayout and SetAutoLayout
BackgroundColour
See GetBackgroundColour and SetBackgroundColour
BackgroundStyle
See GetBackgroundStyle and SetBackgroundStyle
BestSize
See GetBestSize
BestVirtualSize
See GetBestVirtualSize
Border
See GetBorder
Caret
See GetCaret and SetCaret
CharHeight
See GetCharHeight
CharWidth
See GetCharWidth
Children
See GetChildren
ClientAreaOrigin
See GetClientAreaOrigin
ClientRect
See GetClientRect and SetClientRect
ClientSize
See GetClientSize and SetClientSize
Constraints
See GetConstraints and SetConstraints
ContainingSizer
See GetContainingSizer and SetContainingSizer
Cursor
See GetCursor and SetCursor
DefaultAttributes
See GetDefaultAttributes
DropTarget
See GetDropTarget and SetDropTarget
EffectiveMinSize
See GetEffectiveMinSize
Enabled
See IsEnabled and Enable
EventHandler
See GetEventHandler and SetEventHandler
ExtraStyle
See GetExtraStyle and SetExtraStyle
Font
See GetFont and SetFont
ForegroundColour
See GetForegroundColour and SetForegroundColour
GrandParent
See GetGrandParent
GtkWidget
On wxGTK returns a pointer to the GtkWidget for this window as a long integer. On the other platforms this method returns zero.
Handle
See GetHandle
HelpText
See GetHelpText and SetHelpText
Id
See GetId and SetId
Label
See GetLabel and SetLabel
LayoutDirection
See GetLayoutDirection and SetLayoutDirection
MaxHeight
See GetMaxHeight
MaxSize
See GetMaxSize and SetMaxSize
MaxWidth
See GetMaxWidth
MinHeight
See GetMinHeight
MinSize
See GetMinSize and SetMinSize
MinWidth
See GetMinWidth
Name
See GetName and SetName
Parent
See GetParent
Position
See GetPosition and SetPosition
Rect
See GetRect and SetRect
ScreenPosition
See GetScreenPosition
ScreenRect
See GetScreenRect
Shown
See IsShown and Show
Size
See GetSize and SetSize
Sizer
See GetSizer and SetSizer
ThemeEnabled
See GetThemeEnabled and SetThemeEnabled
ToolTip
See GetToolTip and SetToolTip
TopLevel
See IsTopLevel
TopLevelParent
See GetTopLevelParent
UpdateClientRect
See GetUpdateClientRect
UpdateRegion
See GetUpdateRegion
Validator
See GetValidator and SetValidator
VirtualSize
See GetVirtualSize and SetVirtualSize
WindowStyle
See GetWindowStyle and SetWindowStyle
WindowStyleFlag
See GetWindowStyleFlag and SetWindowStyleFlag
WindowVariant
See GetWindowVariant and SetWindowVariant