.. include:: headings.inc .. _TopLevelWindow: ========================================================================================================================================== |phoenix_title| **TopLevelWindow** ========================================================================================================================================== :ref:`TopLevelWindow` is a common base class for :ref:`Dialog` and :ref:`Frame`. It is an abstract base class meaning that you never work with objects of this class directly, but all of its methods are also applicable for the two classes above. Note that the instances of :ref:`TopLevelWindow` are managed by wxWidgets in the internal top level window list. .. _TopLevelWindow-events: |events| Events Emitted by this Class ===================================== Event macros for events emitted by this class: - EVT_MAXIMIZE: Process a ``wxEVT_MAXIMIZE`` event. See :ref:`MaximizeEvent`. - EVT_MOVE: Process a ``wxEVT_MOVE`` event, which is generated when a window is moved. See :ref:`MoveEvent`. - EVT_MOVE_START: Process a ``wxEVT_MOVE_START`` event, which is generated when the user starts to move or size a window. wxMSW only. See :ref:`MoveEvent`. - EVT_MOVE_END: Process a ``wxEVT_MOVE_END`` event, which is generated when the user stops moving or sizing a window. wxMSW only. See :ref:`MoveEvent`. - EVT_SHOW: Process a ``wxEVT_SHOW`` event. See :ref:`ShowEvent`. .. seealso:: :ref:`Dialog`, :ref:`Frame` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **TopLevelWindow** .. raw:: html

Inheritance diagram of TopLevelWindow

| |sub_classes| Known Subclasses ============================== :ref:`Dialog`, :ref:`Frame` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~TopLevelWindow.__init__` Default constructor. :meth:`~TopLevelWindow.CanSetTransparent` Returns ``True`` if the platform supports making the window translucent. :meth:`~TopLevelWindow.CenterOnScreen` A synonym for :meth:`CentreOnScreen` . :meth:`~TopLevelWindow.CentreOnScreen` Centres the window on screen. :meth:`~TopLevelWindow.Create` Creates the top level window. :meth:`~TopLevelWindow.EnableCloseButton` Enables or disables the Close button (most often in the right upper corner of a dialog) and the Close entry of the system menu (most often in the left upper corner of the dialog). :meth:`~TopLevelWindow.GetDefaultItem` Returns a pointer to the button which is the default for this window, or :meth:`~TopLevelWindow.GetDefaultSize` Get the default size for a new top level window. :meth:`~TopLevelWindow.GetIcon` Returns the standard icon of the window. :meth:`~TopLevelWindow.GetIcons` Returns all icons associated with the window, there will be none of them if neither :meth:`SetIcon` nor :meth:`SetIcons` had been called before. :meth:`~TopLevelWindow.GetTitle` Gets a string containing the window title. :meth:`~TopLevelWindow.GetTmpDefaultItem` :meth:`~TopLevelWindow.Iconize` Iconizes or restores the window. :meth:`~TopLevelWindow.IsActive` Returns ``True`` if this window is currently active, i.e. :meth:`~TopLevelWindow.IsAlwaysMaximized` Returns ``True`` if this window is expected to be always maximized, either due to platform policy or due to local policy regarding particular class. :meth:`~TopLevelWindow.IsFullScreen` Returns ``True`` if the window is in fullscreen mode. :meth:`~TopLevelWindow.IsIconized` Returns ``True`` if the window is iconized. :meth:`~TopLevelWindow.IsMaximized` Returns ``True`` if the window is maximized. :meth:`~TopLevelWindow.Layout` See :meth:`Window.SetAutoLayout` : when auto layout is on, this function gets called automatically when the window is resized. :meth:`~TopLevelWindow.MacGetMetalAppearance` :meth:`~TopLevelWindow.MacGetTopLevelWindowRef` :meth:`~TopLevelWindow.MacGetUnifiedAppearance` :meth:`~TopLevelWindow.MacSetMetalAppearance` :meth:`~TopLevelWindow.Maximize` Maximizes or restores the window. :meth:`~TopLevelWindow.OSXIsModified` Returns the current modified state of the :ref:`TopLevelWindow` on OS X. :meth:`~TopLevelWindow.OSXSetModified` This function sets the TopLevelWindow's modified state on OS X, which currently draws a black dot in the TopLevelWindow's close button. :meth:`~TopLevelWindow.RequestUserAttention` Use a system-dependent way to attract users attention to the window when it is in background. :meth:`~TopLevelWindow.SetDefaultItem` Changes the default item for the panel, usually `win` is a button. :meth:`~TopLevelWindow.SetIcon` Sets the icon for this window. :meth:`~TopLevelWindow.SetIcons` Sets several icons of different sizes for this window: this allows to use different icons for different situations (e.g. :meth:`~TopLevelWindow.SetMaxSize` A simpler interface for setting the size hints than :meth:`SetSizeHints` . :meth:`~TopLevelWindow.SetMinSize` A simpler interface for setting the size hints than :meth:`SetSizeHints` . :meth:`~TopLevelWindow.SetRepresentedFilename` Sets the file name represented by this :ref:`TopLevelWindow`. :meth:`~TopLevelWindow.SetSizeHints` Allows specification of minimum and maximum window sizes, and window size increments. :meth:`~TopLevelWindow.SetTitle` Sets the window title. :meth:`~TopLevelWindow.SetTmpDefaultItem` :meth:`~TopLevelWindow.SetTransparent` If the platform supports it will set the window to be translucent. :meth:`~TopLevelWindow.ShouldPreventAppExit` This virtual function is not meant to be called directly but can be overridden to return ``False`` (it returns ``True`` by default) to allow the application to close even if this, presumably not very important, window is still opened. :meth:`~TopLevelWindow.ShowFullScreen` Depending on the value of `show` parameter the window is either shown full screen or restored to its normal state. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~TopLevelWindow.DefaultItem` See :meth:`~TopLevelWindow.GetDefaultItem` and :meth:`~TopLevelWindow.SetDefaultItem` :attr:`~TopLevelWindow.Icon` See :meth:`~TopLevelWindow.GetIcon` and :meth:`~TopLevelWindow.SetIcon` :attr:`~TopLevelWindow.MacMetalAppearance` See :meth:`~TopLevelWindow.MacGetMetalAppearance` and :meth:`~TopLevelWindow.MacSetMetalAppearance` :attr:`~TopLevelWindow.OSXModified` See :meth:`~TopLevelWindow.OSXIsModified` and :meth:`~TopLevelWindow.OSXSetModified` :attr:`~TopLevelWindow.Title` See :meth:`~TopLevelWindow.GetTitle` and :meth:`~TopLevelWindow.SetTitle` :attr:`~TopLevelWindow.TmpDefaultItem` See :meth:`~TopLevelWindow.GetTmpDefaultItem` and :meth:`~TopLevelWindow.SetTmpDefaultItem` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: TopLevelWindow(NonOwnedWindow) TopLevelWindow is a common base class for Dialog and Frame. **Possible constructors**:: TopLevelWindow() TopLevelWindow(parent, id=ID_ANY, title='', pos=DefaultPosition, size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr) .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self)` Default constructor. **~~~** **__init__** `(self, parent, id=ID_ANY, title='', pos=DefaultPosition, size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr)` Constructor creating the top level window. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `title`: :type `title`: string :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `name`: :type `name`: string **~~~** .. method:: CanSetTransparent(self) Returns ``True`` if the platform supports making the window translucent. :rtype: `bool` .. seealso:: :meth:`SetTransparent` .. method:: CenterOnScreen(self, direction) A synonym for :meth:`CentreOnScreen` . :param `direction`: :type `direction`: int .. method:: CentreOnScreen(self, direction=BOTH) Centres the window on screen. :param `direction`: Specifies the direction for the centering. May be ``HORIZONTAL`` , ``VERTICAL`` or ``BOTH`` . :type `direction`: int .. seealso:: :meth:`Window.CentreOnParent` .. method:: Create(self, parent, id=ID_ANY, title='', pos=DefaultPosition, size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr) Creates the top level window. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `title`: :type `title`: string :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `name`: :type `name`: string :rtype: `bool` .. method:: EnableCloseButton(self, enable=True) Enables or disables the Close button (most often in the right upper corner of a dialog) and the Close entry of the system menu (most often in the left upper corner of the dialog). Currently only implemented for wxMSW and wxGTK. Returns ``True`` if operation was successful. This may be wrong on X11 (including GTK+) where the window manager may not support this operation and there is no way to find out. :param `enable`: :type `enable`: bool :rtype: `bool` .. method:: GetDefaultItem(self) Returns a pointer to the button which is the default for this window, or The default button is the one activated by pressing the Enter key. :rtype: :ref:`Window` .. staticmethod:: GetDefaultSize() Get the default size for a new top level window. This is used internally by wxWidgets on some platforms to determine the default size for a window created using ``DefaultSize`` so it is not necessary to use it when creating a :ref:`TopLevelWindow`, however it may be useful if a rough estimation of the window size is needed for some other reason. :rtype: :ref:`Size` .. versionadded:: 2.9.2 .. method:: GetIcon(self) Returns the standard icon of the window. The icon will be invalid if it hadn't been previously set by :meth:`SetIcon` . :rtype: :ref:`Icon` .. seealso:: :meth:`GetIcons` .. method:: GetIcons(self) Returns all icons associated with the window, there will be none of them if neither :meth:`SetIcon` nor :meth:`SetIcons` had been called before. Use :meth:`GetIcon` to get the main icon of the window. :rtype: :ref:`IconBundle` .. seealso:: :ref:`IconBundle` .. method:: GetTitle(self) Gets a string containing the window title. :rtype: `string` .. seealso:: :meth:`SetTitle` .. method:: GetTmpDefaultItem(self) :rtype: :ref:`Window` .. method:: Iconize(self, iconize=True) Iconizes or restores the window. :param `iconize`: If ``True``, iconizes the window; if ``False``, shows and restores it. :type `iconize`: bool .. seealso:: :meth:`IsIconized` , :meth:`Maximize` , :ref:`IconizeEvent`. .. method:: IsActive(self) Returns ``True`` if this window is currently active, i.e. if the user is currently working with it. :rtype: `bool` .. method:: IsAlwaysMaximized(self) Returns ``True`` if this window is expected to be always maximized, either due to platform policy or due to local policy regarding particular class. :rtype: `bool` .. method:: IsFullScreen(self) Returns ``True`` if the window is in fullscreen mode. :rtype: `bool` .. seealso:: :meth:`ShowFullScreen` .. method:: IsIconized(self) Returns ``True`` if the window is iconized. :rtype: `bool` .. method:: IsMaximized(self) Returns ``True`` if the window is maximized. :rtype: `bool` .. method:: Layout(self) See :meth:`Window.SetAutoLayout` : when auto layout is on, this function gets called automatically when the window is resized. :rtype: `bool` .. method:: MacGetMetalAppearance(self) :rtype: `bool` .. method:: MacGetTopLevelWindowRef(self) .. method:: MacGetUnifiedAppearance(self) :rtype: `bool` .. method:: MacSetMetalAppearance(self, on) .. method:: Maximize(self, maximize=True) Maximizes or restores the window. :param `maximize`: If ``True``, maximizes the window, otherwise it restores it. :type `maximize`: bool .. seealso:: :meth:`Iconize` .. method:: OSXIsModified(self) Returns the current modified state of the :ref:`TopLevelWindow` on OS X. On other platforms, this method does nothing. :rtype: `bool` .. seealso:: :meth:`OSXSetModified` .. method:: OSXSetModified(self, modified) This function sets the TopLevelWindow's modified state on OS X, which currently draws a black dot in the TopLevelWindow's close button. On other platforms, this method does nothing. :param `modified`: :type `modified`: bool .. seealso:: :meth:`OSXIsModified` .. method:: RequestUserAttention(self, flags=USER_ATTENTION_INFO) Use a system-dependent way to attract users attention to the window when it is in background. `flags` may have the value of either ``USER_ATTENTION_INFO`` (default) or ``USER_ATTENTION_ERROR`` which results in a more drastic action. When in doubt, use the default value. This function is currently implemented for Win32 where it flashes the window icon in the taskbar, and for wxGTK with task bars supporting it. :param `flags`: :type `flags`: int .. note:: This function should normally be only used when the application is not already in foreground. .. method:: SetDefaultItem(self, win) Changes the default item for the panel, usually `win` is a button. :param `win`: :type `win`: Window :rtype: :ref:`Window` .. seealso:: :meth:`GetDefaultItem` .. method:: SetIcon(self, icon) Sets the icon for this window. :param `icon`: The :ref:`Icon` to associate with this window. :type `icon`: Icon .. note:: The window takes a 'copy' of `icon`, but since it uses reference counting, the copy is very quick. It is safe to delete `icon` after calling this function. .. note:: In wxMSW, `icon` must be either 16x16 or 32x32 icon. .. seealso:: :ref:`Icon`, :meth:`SetIcons` .. method:: SetIcons(self, icons) Sets several icons of different sizes for this window: this allows to use different icons for different situations (e.g. task switching bar, taskbar, window title bar) instead of scaling, with possibly bad looking results, the only icon set by :meth:`SetIcon` . :param `icons`: The icons to associate with this window. :type `icons`: IconBundle .. note:: In wxMSW, `icons` must contain a 16x16 or 32x32 icon, preferably both. .. seealso:: :ref:`IconBundle` .. method:: SetMaxSize(self, size) A simpler interface for setting the size hints than :meth:`SetSizeHints` . :param `size`: :type `size`: Size .. method:: SetMinSize(self, size) A simpler interface for setting the size hints than :meth:`SetSizeHints` . :param `size`: :type `size`: Size .. method:: SetRepresentedFilename(self, filename) Sets the file name represented by this :ref:`TopLevelWindow`. Under OS X, this file name is used to set the "proxy icon", which appears in the window title bar near its title, corresponding to this file name. Under other platforms it currently doesn't do anything but it is harmless to call it now and it might be implemented to do something useful in the future so you're encouraged to use it for any window representing a file-based document. :param `filename`: :type `filename`: string .. versionadded:: 2.9.4 .. method:: SetSizeHints(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **SetSizeHints** `(self, 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), no constraints will be used. :param `minW`: The minimum width. :type `minW`: int :param `minH`: The minimum height. :type `minH`: int :param `maxW`: The maximum width. :type `maxW`: int :param `maxH`: The maximum height. :type `maxH`: int :param `incW`: Specifies the increment for sizing the width (GTK/Motif/Xt only). :type `incW`: int :param `incH`: Specifies the increment for sizing the height (GTK/Motif/Xt only). :type `incH`: int .. note:: Notice that this function not only prevents the user from resizing the window outside the given bounds but it also prevents the program itself from doing it using :meth:`Window.SetSize` . **~~~** **SetSizeHints** `(self, minSize, maxSize=DefaultSize, incSize=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), no constraints will be used. :param `minSize`: The minimum size of the window. :type `minSize`: Size :param `maxSize`: The maximum size of the window. :type `maxSize`: Size :param `incSize`: Increment size (only taken into account under X11-based ports such as GTK/wxMotif/wxX11). :type `incSize`: Size .. note:: Notice that this function not only prevents the user from resizing the window outside the given bounds but it also prevents the program itself from doing it using :meth:`Window.SetSize` . **~~~** .. method:: SetTitle(self, title) Sets the window title. :param `title`: The window title. :type `title`: string .. seealso:: :meth:`GetTitle` .. method:: SetTmpDefaultItem(self, win) :param `win`: :type `win`: Window :rtype: :ref:`Window` .. method:: SetTransparent(self, alpha) If the platform supports it will set the window to be translucent. :param `alpha`: Determines how opaque or transparent the window will be, if the platform supports the operation. A value of 0 sets the window to be fully transparent, and a value of 255 sets the window to be fully opaque. :type `alpha`: int :rtype: `bool` .. method:: ShouldPreventAppExit(self) This virtual function is not meant to be called directly but can be overridden to return ``False`` (it returns ``True`` by default) to allow the application to close even if this, presumably not very important, window is still opened. By default, the application stays alive as long as there are any open top level windows. :rtype: `bool` .. method:: ShowFullScreen(self, show, style=FULLSCREEN_ALL) Depending on the value of `show` parameter the window is either shown full screen or restored to its normal state. `style` is a bit list containing some or all of the following values, which indicate what elements of the window to hide in full-screen mode: - ``FULLSCREEN_NOMENUBAR`` - ``FULLSCREEN_NOTOOLBAR`` - ``FULLSCREEN_NOSTATUSBAR`` - ``FULLSCREEN_NOBORDER`` - ``FULLSCREEN_NOCAPTION`` - ``FULLSCREEN_ALL`` (all of the above) This function has not been tested with MDI frames. :param `show`: :type `show`: bool :param `style`: :type `style`: long :rtype: `bool` .. note:: Showing a window full screen also actually :meth:`Show` s the window if it isn't shown. .. seealso:: :meth:`IsFullScreen` .. attribute:: DefaultItem See :meth:`~TopLevelWindow.GetDefaultItem` and :meth:`~TopLevelWindow.SetDefaultItem` .. attribute:: Icon See :meth:`~TopLevelWindow.GetIcon` and :meth:`~TopLevelWindow.SetIcon` .. attribute:: MacMetalAppearance See :meth:`~TopLevelWindow.MacGetMetalAppearance` and :meth:`~TopLevelWindow.MacSetMetalAppearance` .. attribute:: OSXModified See :meth:`~TopLevelWindow.OSXIsModified` and :meth:`~TopLevelWindow.OSXSetModified` .. attribute:: Title See :meth:`~TopLevelWindow.GetTitle` and :meth:`~TopLevelWindow.SetTitle` .. attribute:: TmpDefaultItem See :meth:`~TopLevelWindow.GetTmpDefaultItem` and :meth:`~TopLevelWindow.SetTmpDefaultItem`