Gtk.Window


Gtk.Window — Toplevel which can contain other widgets

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Bin
                    ╰── Gtk.Window
                        ├── Gtk.Dialog
                        ├── Gtk.ApplicationWindow
                        ├── Gtk.Assistant
                        ├── Gtk.OffscreenWindow
                        ╰── Gtk.Plug

Functions:


Signals:

  • “activate-default” (window, user_data)
  • “activate-focus” (window, user_data)
  • “enable-debugging” (window, toggle, user_data)
  • “keys-changed” (window, user_data)
  • “set-focus” (window, user_data)

Description:

A Gtk.Window is a toplevel window which can contain other widgets.

Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it,...).

Gtk.Window as Gtk.Buildable:

The Gtk.Window implementation of the Gtk.Buildable interface supports a custom \ element, which supports any number of \ elements representing the GtkAccelGroup objects you want to add to your window (synonymous with Gtk.Window::add_accel_group().

It also supports the \ element, whose name property names the widget to receive the focus when the window is mapped.

An example of a UI definition fragment with accel groups:

<object class="GtkWindow">
  <accel-groups>
    <group name="accelgroup1"/>
  </accel-groups>
  <initial-focus name="thunderclap"/>
</object>

...


<object class="GtkAccelGroup" id="accelgroup1"/>

The GtkWindow implementation of the Gtk.Buildable interface supports setting a child as the titlebar by specifying titlebar as the type attribute of a \ element.


Function Details:

new()

new (type:Gtk.WindowType) -> Gtk.Widget

Creates a new Gtk.Window, which is a toplevel window that cancontain other widgets. Nearly always, the type of the window shouldbe GTK_WINDOW_TOPLEVEL. If you’re implementing something like apopup menu from scratch (which is a bad idea, just use Gtk.Menu),you might use GTK_WINDOW_POPUP. GTK_WINDOW_POPUP is not fordialogs, though in some other toolkits dialogs are called “popups”.In GTK+, GTK_WINDOW_POPUP means a pop-up menu or pop-up tooltip.On X11, popup windows are not controlled by thewindow manager. If you simply want an undecorated window (no window borders), useGtk.Window:set_decorated(), don’t use GTK_WINDOW_POPUP. All top-level windows created by Gtk.Window:new() are stored inan internal top-level window list. This list can be obtained fromGtk.Window:list_toplevels(). Due to Gtk.+ keeping a reference tothe window internally, Gtk.Window:new() does not return a referenceto the caller. To delete a Gtk.Window, call `Gtk.Widget:destroy()`.

  • Returns: a new Gtk.Window.

set_title()

set_title (self, title:str)

Sets the title of the Gtk.Window. The title of a window will bedisplayed in its title bar; on the X Window System, the title baris rendered by the window manager,so exactly how the title appears to users may varyaccording to a user’s exact configuration. The title should help auser distinguish this window from other windows they may haveopen. A good title might include the application name and currentdocument filename, for example.


set_wmclass()

set_wmclass (self, wmclass_name:str, wmclass_class:str)

Don’t use this function. It sets the X Window System “class” and“name” hints for a window. According to the ICCCM, you shouldalways set these to the same value for all windows in anapplication, and GTK+ sets them to that value by default, so callingthis function is sort of pointless. However, you may want to callGtk.Window:set_role() on each window in your application, for thebenefit of the session manager. Setting the role allows the windowmanager to restore window positions when loading a saved session.


set_resizable()

set_resizable (self, resizable:bool)

Sets whether the user can resize a window. Windows are user resizableby default.


get_resizable()

get_resizable (self) -> bool

Gets the value set by Gtk.Window:set_resizable().

  • Returns: True if the user can resize the window

add_accel_group()

add_accel_group (self, accel_group:Gtk.AccelGroup)

Associate accel_group with window, such that calling`Gtk.AccelGroups:activate()onwindowwill activate acceleratorsinaccel_group`.


remove_accel_group()

remove_accel_group (self, accel_group:Gtk.AccelGroup)

Reverses the effects of Gtk.Window:add_accel_group().


activate_focus()

activate_focus (self) -> bool

Activates the current focused widget within the window.

  • Returns: True if a widget got activated.

activate_default()

activate_default (self) -> bool

Activates the default widget for the window, unless the current focused widget has been configured to receive the default action (see `Gtk.Widget:set_receives_default()`), in which case thefocused widget is activated.

  • Returns: True if a widget got activated.

set_modal()

set_modal (self, modal:bool)

Sets a window modal or non-modal. Modal windows prevent interactionwith other windows in the same application. To keep modal dialogson top of main application windows, useGtk.Window:set_transient_for() to make the dialog transient for theparent; most window managerswill then disallow lowering the dialog below the parent.


set_default_size()

set_default_size (self, width:int, height:int)

Sets the default size of a window. If the window’s “natural” size(its size request) is larger than the default, the default will beignored. More generally, if the default size does not obey thegeometry hints for the window (Gtk.Window:set_geometry_hints() canbe used to set these explicitly), the default size will be clampedto the nearest permitted size. Unlike `Gtk.Widget:set_size_request(), which sets a size request fora widget and thus would keep users from shrinking the window, thisfunction only sets the initial size, just as if the user hadresized the window themselves. Users can still shrink the windowagain as they normally would. Setting a default size of -1 means touse the “natural” default size (the size request of the window). For more control over a window’s initial size and how resizing works,investigateGtk.Window:set_geometry_hints(). For some uses,Gtk.Window:resize()is a more appropriate function.Gtk.Window:resize()changes the current size of the window, ratherthan the size to be used on initial display.Gtk.Window:resize()alwaysaffects the window itself, not the geometry widget. The default size of a window only affects the first time a window isshown; if a window is hidden and re-shown, it will remember the sizeit had prior to hiding, rather than using the default size. Windows can’t actually be 0x0 in size, they must be at least 1x1, butpassing 0 forwidthandheight` is OK, resulting in a 1x1 default size.


set_default_geometry()

set_default_geometry (self, width:int, height:int)

Like Gtk.Window:set_default_size(), but width and height are interpretedin terms of the base size and increment set withGtk.Window:set_geometry_hints.

  • Since: 3.0

set_geometry_hints()

set_geometry_hints (self, geometry_widget:Gtk.Widget=None, geometry:Gdk.Geometry=None, geom_mask:Gdk.WindowHints)

This function sets up hints about how a window can be resized bythe user. You can set a minimum and maximum size; allowed resizeincrements (e.g. for xterm, you can only resize by the size of acharacter); aspect ratios; and more. See the GdkGeometry struct.


set_gravity()

set_gravity (self, gravity:Gdk.Gravity)

Window gravity defines the meaning of coordinates passed toGtk.Window:move(). See Gtk.Window:move() and GdkGravity formore details. The default window gravity is GDK_GRAVITY_NORTH_WEST which willtypically “do what you mean.”


get_gravity()

get_gravity (self) -> Gdk.Gravity

Gets the value set by Gtk.Window:set_gravity().

  • Returns: window gravity.

set_position()

set_position (self, position:Gtk.WindowPosition)

Sets a position constraint for this window. If the old or newconstraint is GTK_WIN_POS_CENTER_ALWAYS, this will also causethe window to be repositioned to satisfy the new constraint.


set_transient_for()

set_transient_for (self, parent:Gtk.Window=None)

Dialog windows should be set transient for the main applicationwindow they were spawned from. This allowswindow managers to e.g. keep thedialog on top of the main window, or center the dialog over themain window. `Gtk.Dialog:new_with_buttons()and other conveniencefunctions in GTK+ will sometimes callGtk.Window:set_transient_for()on your behalf. PassingNoneforparent` unsets the current transient window. On Windows, this function puts the child window on top of the parent,much as the window manager would have done on X.


set_attached_to()

set_attached_to (self, attach_widget:Gtk.Widget=None)

Marks window as attached to attach_widget. This creates a logical bindingbetween the window and the widget it belongs to, which is used by GTK+ topropagate information such as styling or accessibility to window as if itwas a children of attach_widget. Examples of places where specifying this relation is useful are for instancea Gtk.Menu created by a Gtk.ComboBox, a completion popup windowcreated by Gtk.Entry or a typeahead search entry created by Gtk.TreeView. Note that this function should not be confused withGtk.Window:set_transient_for(), which specifies a window manager relationbetween two toplevels instead. Passing None for attach_widget detaches the window.

  • Since: 3.4

set_destroy_with_parent()

set_destroy_with_parent (self, setting:bool)

If setting is True, then destroying the transient parent of windowwill also destroy window itself. This is useful for dialogs thatshouldn’t persist beyond the lifetime of the main window they'reassociated with, for example.


set_hide_titlebar_when_maximized()

set_hide_titlebar_when_maximized (self, setting:bool)

If setting is True, then window will request that it’s titlebarshould be hidden when maximized.This is useful for windows that don’t convey any information otherthan the application name in the titlebar, to put the availablescreen space to better use. If the underlying window system does notsupport the request, the setting will not have any effect. Note that custom titlebars set with Gtk.Window:set_titlebar() arenot affected by this. The application is in full control of theircontent and visibility anyway.

  • Since: 3.4

set_screen()

set_screen (self, screen:Gdk.Screen)

Sets the GdkScreen where the window is displayed; ifthe window is already mapped, it will be unmapped, andthen remapped on the new screen.

  • Since: 2.2

get_screen()

get_screen (self) -> Gdk.Screen

Returns the GdkScreen associated with window.

  • Returns: a GdkScreen.

  • Since: 2.2


is_active()

is_active (self) -> bool

Returns whether the window is part of the current active toplevel.(That is, the toplevel window receiving keystrokes.)The return value is True if the window is active toplevelitself, but also if it is, say, a Gtk.Plug embedded in the active toplevel.You might use this function if you wanted to draw a widgetdifferently in an active window from a widget in an inactive window.See Gtk.Window:has_toplevel_focus()

  • Returns: True if the window part of the current active window.

  • Since: 2.4


is_maximized()

is_maximized (self) -> bool

Retrieves the current maximized state of window. Note that since maximization is ultimately handled by the windowmanager and happens asynchronously to an application request, youshouldn’t assume the return value of this function changingimmediately (or at all), as an effect of callingGtk.Window:maximize() or Gtk.Window:unmaximize().

  • Returns: whether the window has a maximized state.

  • Since: 3.12


has_toplevel_focus()

has_toplevel_focus (self) -> bool

Returns whether the input focus is within this Gtk.Window.For real toplevel windows, this is identical to Gtk.Window:is_active(),but for embedded windows, like Gtk.Plug, the results will differ.

  • Returns: True if the input focus is within this Gtk.Window

  • Since: 2.4


list_toplevels()

list_toplevels () -> list

Returns a list of all existing toplevel windows. The widgetsin the list are not individually referenced. If you wantto iterate through the list and perform actions involvingcallbacks that might destroy the widgets, you must callg_list_foreach (result, (GFunc)g_object_ref, None) first, andthen unref all the widgets afterwards.

  • Returns: list of toplevel widgets.

add_mnemonic()

add_mnemonic (self, keyval:int, target:Gtk.Widget)

Adds a mnemonic to this window.


remove_mnemonic()

remove_mnemonic (self, keyval:int, target:Gtk.Widget)

Removes a mnemonic from this window.


mnemonic_activate()

mnemonic_activate (self, keyval:int, modifier:Gdk.ModifierType) -> bool

Activates the targets associated with the mnemonic.

  • Returns: True if the activation is done.

activate_key()

activate_key (self, event:Gdk.EventKey) -> bool

Activates mnemonics and accelerators for this Gtk.Window. This is normallycalled by the default ::key_press_event handler for toplevel windows,however in some cases it may be useful to call this directly whenoverriding the standard key handling for a toplevel window.

  • Returns: True if a mnemonic or accelerator was found and activated.

  • Since: 2.4


propagate_key_event()

propagate_key_event (self, event:Gdk.EventKey) -> bool

Propagate a key press or release event to the focus widget andup the focus container chain until a widget handles event.This is normally called by the default ::key_press_event and::key_release_event handlers for toplevel windows,however in some cases it may be useful to call this directly whenoverriding the standard key handling for a toplevel window.

  • Returns: True if a widget in the focus chain handled the event.

  • Since: 2.4


get_focus()

get_focus (self) -> Gtk.Widget

Retrieves the current focused widget within the window.Note that this is the widget that would have the focusif the toplevel window focused; if the toplevel windowis not focused then `Gtk.Widget:has_focus (widget)willnot beTrue` for the widget.

  • Returns: the currently focused widget, or None if there is none.

set_focus()

set_focus (self, focus:Gtk.Widget=None)

If focus is not the current focus widget, and is focusable, setsit as the focus widget for the window. If focus is None, unsetsthe focus widget for this window. To set the focus to a particularwidget in the toplevel, it is usually more convenient to use`Gtk.Widget:grab_focus()` instead of this function.


get_default_widget()

get_default_widget (self) -> Gtk.Widget

Returns the default widget for window. See Gtk.Window:set_default()for more details.

  • Returns: the default widget, or None if there is none.

  • Since: 2.14


set_default()

set_default (self, default_widget:Gtk.Widget=None)

The default widget is the widget that’s activated when the userpresses Enter in a dialog (for example). This function sets orunsets the default widget for a Gtk.Window. When setting (ratherthan unsetting) the default widget it’s generally easier to callGtk.Widget:grab_default`()` on the widget. Before making a widgetthe default widget, you must callGtk.Widget:set_can_default() onthe widget you’d like to make the default.


present()

present (self)

Presents a window to the user. This may mean raising the windowin the stacking order, deiconifying it, moving it to the currentdesktop, and/or giving it the keyboard focus, possibly dependenton the user’s platform, window manager, and preferences. If window is hidden, this function calls `Gtk.Widget:show()as well. This function should be used when the user tries to open a windowthat’s already open. Say for example the preferences dialog iscurrently open, and the user chooses Preferences from the menua second time; useGtk.Window:present()to move the already-open dialogwhere the user can see it. If you are calling this function in response to a user interaction,it is preferable to useGtk.Window:present_with_time()`.


present_with_time()

present_with_time (self, timestamp:int)

Presents a window to the user in response to a user interaction.If you need to present a window without a timestamp, use Gtk.Window:present(). See Gtk.Window:present() for details.

  • Since: 2.8

close()

close (self)

Requests that the window is closed, similar to what happenswhen a window manager close button is clicked. This function can be used with close buttons in customtitlebars.

  • Since: 3.10

iconify()

iconify (self)

Asks to iconify (i.e. minimize) the specified window. Note thatyou shouldn’t assume the window is definitely iconified afterward,because other entities (e.g. the user orwindow manager) could deiconify itagain, or there may not be a window manager in which caseiconification isn’t possible, etc. But normally the window will endup iconified. Just don’t write code that crashes if not. It’s permitted to call this function before showing a window,in which case the window will be iconified before it ever appearsonscreen. You can track iconification via the “window-state-event” signalon Gtk.Widget.


deiconify()

deiconify (self)

Asks to deiconify (i.e. unminimize) the specified window. Notethat you shouldn’t assume the window is definitely deiconifiedafterward, because other entities (e.g. the user orwindow manager)) could iconify itagain before your code which assumes deiconification gets to run. You can track iconification via the “window-state-event” signalon Gtk.Widget.


stick()

stick (self)

Asks to stick window, which means that it will appear on all userdesktops. Note that you shouldn’t assume the window is definitelystuck afterward, because other entities (e.g. the user orwindow manager could unstick itagain, and some window managers do not support stickingwindows. But normally the window will end up stuck. Just don'twrite code that crashes if not. It’s permitted to call this function before showing a window. You can track stickiness via the “window-state-event” signalon Gtk.Widget.


unstick()

unstick (self)

Asks to unstick window, which means that it will appear on onlyone of the user’s desktops. Note that you shouldn’t assume thewindow is definitely unstuck afterward, because other entities(e.g. the user or window manager) couldstick it again. But normally the window willend up stuck. Just don’t write code that crashes if not. You can track stickiness via the “window-state-event” signalon Gtk.Widget.


maximize()

maximize (self)

Asks to maximize window, so that it becomes full-screen. Note thatyou shouldn’t assume the window is definitely maximized afterward,because other entities (e.g. the user orwindow manager) could unmaximize itagain, and not all window managers support maximization. Butnormally the window will end up maximized. Just don’t write codethat crashes if not. It’s permitted to call this function before showing a window,in which case the window will be maximized when it appears onscreeninitially. You can track maximization via the “window-state-event” signalon Gtk.Widget, or by listening to notifications on the“is-maximized” property.


unmaximize()

unmaximize (self)

Asks to unmaximize window. Note that you shouldn’t assume thewindow is definitely unmaximized afterward, because other entities(e.g. the user or window manager)could maximize it again, and not all windowmanagers honor requests to unmaximize. But normally the window willend up unmaximized. Just don’t write code that crashes if not. You can track maximization via the “window-state-event” signalon Gtk.Widget.


fullscreen()

fullscreen (self)

Asks to place window in the fullscreen state. Note that youshouldn’t assume the window is definitely full screen afterward,because other entities (e.g. the user orwindow manager) could unfullscreen itagain, and not all window managers honor requests to fullscreenwindows. But normally the window will end up fullscreen. Justdon’t write code that crashes if not. You can track the fullscreen state via the “window-state-event” signalon Gtk.Widget.

  • Since: 2.2

fullscreen_on_monitor()

fullscreen_on_monitor (self, screen:Gdk.Screen, monitor:int)

Asks to place window in the fullscreen state. Note that you shouldn't assumethe window is definitely full screen afterward. You can track the fullscreen state via the "window-state-event" signalon Gtk.Widget.

  • Since: 3.18

unfullscreen()

unfullscreen (self)

Asks to toggle off the fullscreen state for window. Note that youshouldn’t assume the window is definitely not full screenafterward, because other entities (e.g. the user orwindow manager) could fullscreen itagain, and not all window managers honor requests to unfullscreenwindows. But normally the window will end up restored to its normalstate. Just don’t write code that crashes if not. You can track the fullscreen state via the “window-state-event” signalon Gtk.Widget.

  • Since: 2.2

set_keep_above()

set_keep_above (self, setting:bool)

Asks to keep window above, so that it stays on top. Note thatyou shouldn’t assume the window is definitely above afterward,because other entities (e.g. the user orwindow manager) could not keep it above,and not all window managers support keeping windows above. Butnormally the window will end kept above. Just don’t write codethat crashes if not. It’s permitted to call this function before showing a window,in which case the window will be kept above when it appears onscreeninitially. You can track the above state via the “window-state-event” signalon Gtk.Widget. Note that, according to theExtended Window Manager Hints Specification,the above state is mainly meant for user preferences and should notbe used by applications e.g. for drawing attention to theirdialogs.

  • Since: 2.4

set_keep_below()

set_keep_below (self, setting:bool)

Asks to keep window below, so that it stays in bottom. Note thatyou shouldn’t assume the window is definitely below afterward,because other entities (e.g. the user orwindow manager) could not keep it below,and not all window managers support putting windows below. Butnormally the window will be kept below. Just don’t write codethat crashes if not. It’s permitted to call this function before showing a window,in which case the window will be kept below when it appears onscreeninitially. You can track the below state via the “window-state-event” signalon Gtk.Widget. Note that, according to theExtended Window Manager Hints Specification,the above state is mainly meant for user preferences and should notbe used by applications e.g. for drawing attention to theirdialogs.

  • Since: 2.4

begin_resize_drag()

begin_resize_drag (self, edge:Gdk.WindowEdge, button:int, root_x:int, root_y:int, timestamp:int)

Starts resizing a window. This function is used if an applicationhas window resizing controls. When GDK can support it, the resizewill be done using the standard mechanism for thewindow manager or windowingsystem. Otherwise, GDK will try to emulate window resizing,potentially not all that well, depending on the windowing system.


begin_move_drag()

begin_move_drag (self, button:int, root_x:int, root_y:int, timestamp:int)

Starts moving a window. This function is used if an application haswindow movement grips. When GDK can support it, the window movementwill be done using the standard mechanism for thewindow manager or windowingsystem. Otherwise, GDK will try to emulate window movement,potentially not all that well, depending on the windowing system.


set_decorated()

set_decorated (self, setting:bool)

By default, windows are decorated with a title bar, resizecontrols, etc. Some window managersallow GTK+ to disable these decorations, creating aborderless window. If you set the decorated property to FALSEusing this function, GTK+ will do its best to convince the windowmanager not to decorate the window. Depending on the system, thisfunction may not have any effect when called on a window that isalready visible, so you should call it before calling `Gtk.Widget:show()`. On Windows, this function always works, since there’s no window managerpolicy involved.


set_deletable()

set_deletable (self, setting:bool)

By default, windows have a close button in the window frame. Some window managers allow GTK+ to disable this button. If you set the deletable property to FALSEusing this function, GTK+ will do its best to convince the windowmanager not to show a close button. Depending on the system, thisfunction may not have any effect when called on a window that isalready visible, so you should call it before calling `Gtk.Widget:show()`. On Windows, this function always works, since there’s no window managerpolicy involved.

  • Since: 2.10

set_mnemonic_modifier()

set_mnemonic_modifier (self, modifier:Gdk.ModifierType)

Sets the mnemonic modifier for this window.


set_type_hint()

set_type_hint (self, hint:Gdk.WindowTypeHint)

By setting the type hint for the window, you allow the windowmanager to decorate and handle the window in a way which issuitable to the function of the window in your application. This function should be called before the window becomes visible. Gtk.Dialog:new_with_buttons() and other convenience functions in GTK+will sometimes call Gtk.Window:set_type_hint() on your behalf.


set_skip_taskbar_hint()

set_skip_taskbar_hint (self, setting:bool)

Windows may set a hint asking the desktop environment not to displaythe window in the task bar. This function sets this hint.

  • Since: 2.2

set_skip_pager_hint()

set_skip_pager_hint (self, setting:bool)

Windows may set a hint asking the desktop environment not to displaythe window in the pager. This function sets this hint.(A "pager" is any desktop navigation tool such as a workspaceswitcher that displays a thumbnail representation of the windowson the screen.)

  • Since: 2.2

set_urgency_hint()

set_urgency_hint (self, setting:bool)

Windows may set a hint asking the desktop environment to drawthe users attention to the window. This function sets this hint.

  • Since: 2.8

set_accept_focus()

set_accept_focus (self, setting:bool)

Windows may set a hint asking the desktop environment not to receivethe input focus. This function sets this hint.

  • Since: 2.4

set_focus_on_map()

set_focus_on_map (self, setting:bool)

Windows may set a hint asking the desktop environment not to receivethe input focus when the window is mapped. This function sets thishint.

  • Since: 2.6

set_startup_id()

set_startup_id (self, startup_id:str)

Startup notification identifiers are used by desktop environment to track application startup, to provide user feedback and other features. This function changes the corresponding property on theunderlying GdkWindow. Normally, startup identifier is managed automatically and you should only use this function in special caseslike transferring focus from other processes. You should use thisfunction before calling Gtk.Window:present() or any equivalentfunction generating a window map event. This function is only useful on X11, not with other GTK+ targets.

  • Since: 2.12

set_role()

set_role (self, role:str)

This function is only useful on X11, not with other GTK+ targets. In combination with the window title, the window role allows awindow manager to identify "thesame" window when an application is restarted. So for example youmight set the “toolbox” role on your app’s toolbox window, so thatwhen the user restarts their session, the window manager can putthe toolbox back in the same place. If a window already has a unique title, you don’t need to set therole, since the WM can use the title to identify the window whenrestoring the session.


get_decorated()

get_decorated (self) -> bool

Returns whether the window has been set to have decorationssuch as a title bar via Gtk.Window:set_decorated().

  • Returns: True if the window has been set to have decorations

get_deletable()

get_deletable (self) -> bool

Returns whether the window has been set to have a close buttonvia Gtk.Window:set_deletable().

  • Returns: True if the window has been set to have a close button

  • Since: 2.10


get_default_icon_list()

get_default_icon_list () -> list

Gets the value set by Gtk.Window:set_default_icon_list().The list is a copy and should be freed with g_list_free(),but the pixbufs in the list have not had their reference countincremented.

  • Returns: copy of default icon list.

get_default_icon_name()

get_default_icon_name () -> str

Returns the fallback icon name for windows that has been setwith Gtk.Window:set_default_icon_name(). The returnedstring is owned by GTK+ and should not be modified. Itis only valid until the next call toGtk.Window:set_default_icon_name().

  • Returns: the fallback icon name for windows

  • Since: 2.16


get_default_size()

get_default_size (self) -> width:int, height:int

Gets the default size of the window. A value of -1 for the width orheight indicates that a default size has not been explicitly setfor that dimension, so the “natural” size of the window will beused.


get_destroy_with_parent()

get_destroy_with_parent (self) -> bool

Returns whether the window will be destroyed with its transient parent. SeeGtk.Window:set_destroy_with_parent().

  • Returns: True if the window will be destroyed with its transient parent.

get_hide_titlebar_when_maximized()

get_hide_titlebar_when_maximized (self) -> bool

Returns whether the window has requested to have its titlebar hiddenwhen maximized. See Gtk.Window:set_hide_titlebar_when_maximized().

  • Returns: True if the window has requested to have its titlebarhidden when maximized

  • Since: 3.4


get_icon()

get_icon (self) -> GdkPixbuf.Pixbuf

Gets the value set by Gtk.Window:set_icon() (or if you'vecalled Gtk.Window:set_icon_list(), gets the first icon inthe icon list).

  • Returns: icon for window.

get_icon_list()

get_icon_list (self) -> list

Retrieves the list of icons set by Gtk.Window:set_icon_list().The list is copied, but the reference count on eachmember won’t be incremented.

  • Returns: copy of window’s icon list.

get_icon_name()

get_icon_name (self) -> str

Returns the name of the themed icon for the window,see Gtk.Window:set_icon_name().

  • Returns: the icon name or None if the window hasno themed icon

  • Since: 2.6


get_mnemonic_modifier()

get_mnemonic_modifier (self) -> Gdk.ModifierType

Returns the mnemonic modifier for this window. SeeGtk.Window:set_mnemonic_modifier().

  • Returns: the modifier mask used to activatemnemonics on this window.

get_modal()

get_modal (self) -> bool

Returns whether the window is modal. See Gtk.Window:set_modal().

  • Returns: True if the window is set to be modal andestablishes a grab when shown

get_position()

get_position (self) -> root_x:int, root_y:int

This function returns the position you need to pass toGtk.Window:move() to keep window in its current position.This means that the meaning of the returned value varies withwindow gravity. See Gtk.Window:move() for more details. If you haven’t changed the window gravity, its gravity will beGDK_GRAVITY_NORTH_WEST. This means that Gtk.Window:get_position()gets the position of the top-left corner of the window managerframe for the window. Gtk.Window:move() sets the position of thissame top-left corner. Gtk.Window:get_position() is not 100% reliable because the X Window Systemdoes not specify a way to obtain the geometry of thedecorations placed on a window by the window manager.Thus GTK+ is using a “best guess” that works with mostwindow managers. Moreover, nearly all window managers are historically broken withrespect to their handling of window gravity. So moving a window toits current position as returned by Gtk.Window:get_position() tendsto result in moving the window slightly. Window managers areslowly getting better over time. If a window has gravity GDK_GRAVITY_STATIC the window managerframe is not relevant, and thus Gtk.Window:get_position() willalways produce accurate results. However you can’t use staticgravity to do things like place a window in a corner of the screen,because static gravity ignores the window manager decorations. If you are saving and restoring your application’s windowpositions, you should know that it’s impossible for applications todo this without getting it somewhat wrong because applications donot have sufficient knowledge of window manager state. The CorrectMechanism is to support the session management protocol (see the“GnomeClient” object in the GNOME libraries for example) and allowthe window manager to save your window sizes and positions.


get_role()

get_role (self) -> str

Returns the role of the window. See Gtk.Window:set_role() forfurther explanation.

  • Returns: the role of the window if set, or None. Thereturned is owned by the widget and must not be modifiedor freed.

get_size()

get_size (self) -> width:int, height:int

Obtains the current size of window. If window is not onscreen,it returns the size GTK+ will suggest to thewindow managerfor the initial windowsize (but this is not reliably the same as the size the windowmanager will actually select). The size obtained byGtk.Window:get_size() is the last size received in aGdkEventConfigure, that is, GTK+ uses its locally-stored size,rather than querying the X server for the size. As a result, if youcall Gtk.Window:resize() then immediately callGtk.Window:get_size(), the size won’t have taken effect yet. Afterthe window manager processes the resize request, GTK+ receivesnotification that the size has changed via a configure event, andthe size of the window gets updated. Note 1: Nearly any use of this function creates a race condition,because the size of the window may change between the time that youget the size and the time that you perform some action assumingthat size is the current size. To avoid race conditions, connect to“configure-event” on the window and adjust your size-dependentstate to match the size delivered in the GdkEventConfigure. Note 2: The returned size does not include thesize of the window manager decorations (aka the window frame orborder). Those are not drawn by GTK+ and GTK+ has no reliablemethod of determining their size. Note 3: If you are getting a window size in order to positionthe window onscreen, there may be a better way. The preferredway is to simply set the window’s semantic type withGtk.Window:set_type_hint(), which allows the window manager toe.g. center dialogs. Also, if you set the transient parent ofdialogs with Gtk.Window:set_transient_for() window managerswill often center the dialog over its parent window. It'smuch preferred to let the window manager handle thesethings rather than doing it yourself, because all apps willbehave consistently and according to user prefs if the windowmanager handles it. Also, the window manager can take the sizeof the window decorations/border into account, while yourapplication cannot. In any case, if you insist on application-specified windowpositioning, there’s still a better way thandoing it yourself - Gtk.Window:set_position() will frequentlyhandle the details for you.


get_title()

get_title (self) -> str

Retrieves the title of the window. See Gtk.Window:set_title().

  • Returns: the title of the window, or None if none hasbeen set explicitly. The returned string is owned by the widgetand must not be modified or freed.

get_transient_for()

get_transient_for (self) -> Gtk.Window

Fetches the transient parent for this window. SeeGtk.Window:set_transient_for().

  • Returns: the transient parent for this window, or Noneif no transient parent has been set.

get_attached_to()

get_attached_to (self) -> Gtk.Widget

Fetches the attach widget for this window. SeeGtk.Window:set_attached_to().

  • Returns: the widget where the window is attached,or None if the window is not attached to any widget.

  • Since: 3.4


get_type_hint()

get_type_hint (self) -> Gdk.WindowTypeHint

Gets the type hint for this window. See Gtk.Window:set_type_hint().

  • Returns: the type hint for window.

get_skip_taskbar_hint()

get_skip_taskbar_hint (self) -> bool

Gets the value set by Gtk.Window:set_skip_taskbar_hint()

  • Returns: True if window shouldn’t be in taskbar

  • Since: 2.2


get_skip_pager_hint()

get_skip_pager_hint (self) -> bool

Gets the value set by Gtk.Window:set_skip_pager_hint().

  • Returns: True if window shouldn’t be in pager

  • Since: 2.2


get_urgency_hint()

get_urgency_hint (self) -> bool

Gets the value set by Gtk.Window:set_urgency_hint()

  • Returns: True if window is urgent

  • Since: 2.8


get_accept_focus()

get_accept_focus (self) -> bool

Gets the value set by Gtk.Window:set_accept_focus().

  • Returns: True if window should receive the input focus

  • Since: 2.4


get_focus_on_map()

get_focus_on_map (self) -> bool

Gets the value set by Gtk.Window:set_focus_on_map().

  • Returns: True if window should receive the input focus whenmapped.

  • Since: 2.6


get_group()

get_group (self) -> Gtk.WindowGroup

Returns the group for window or the default group, ifwindow is None or if window does not have an explicitwindow group.

  • Returns: the Gtk.WindowGroup for a window or the default group.

  • Since: 2.10


has_group()

has_group (self) -> bool

Returns whether window has an explicit window group.

  • Returns: True if windowhas an explicit window group.

get_window_type()

get_window_type (self) -> Gtk.WindowType

Gets the type of the window. See Gtk.WindowType.

  • Returns: the type of the window

  • Since: 2.20


move()

move (self, x:int, y:int)

Asks the window manager to movewindow to the given position. Window managers are free to ignorethis; most window managers ignore requests for initial windowpositions (instead using a user-defined placement algorithm) andhonor requests after the window has already been shown. Note: the position is the position of the gravity-determinedreference point for the window. The gravity determines two things:first, the location of the reference point in root windowcoordinates; and second, which point on the window is positioned atthe reference point. By default the gravity is GDK_GRAVITY_NORTH_WEST, so the referencepoint is simply the x, y supplied to Gtk.Window:move(). Thetop-left corner of the window decorations (aka window frame orborder) will be placed at x, y. Therefore, to position a windowat the top left of the screen, you want to use the default gravity(which is GDK_GRAVITY_NORTH_WEST) and move the window to 0,0. To position a window at the bottom right corner of the screen, youwould set GDK_GRAVITY_SOUTH_EAST, which means that the referencepoint is at x + the window width and y + the window height, andthe bottom-right corner of the window border will be placed at thatreference point. So, to place a window in the bottom right corneryou would first set gravity to south east, then write:Gtk.Window:move (window,gdk_screen_width()- window_width,gdk_screen_height()- window_height) (note that thisexample does not take multi-head scenarios into account). The Extended Window Manager Hints Specificationhas a nice table of gravities in the “implementation notes” section. The Gtk.Window:get_position() documentation may also be relevant.


parse_geometry()

parse_geometry (self, geometry:str) -> bool

Parses a standard X Window System geometry string - see themanual page for X (type “man X”) for details on this.Gtk.Window:parse_geometry() does work on all GTK+ portsincluding Win32 but is primarily intended for an X environment. If either a size or a position can be extracted from thegeometry string, Gtk.Window:parse_geometry() returns Trueand calls Gtk.Window:set_default_size() and/or Gtk.Window:move()to resize/move the window. If Gtk.Window:parse_geometry() returns True, it will alsoset the GDK_HINT_USER_POS and/or GDK_HINT_USER_SIZE hintsindicating to the window manager that the size/position ofthe window was user-specified. This causes most windowmanagers to honor the geometry. Note that for Gtk.Window:parse_geometry() to work as expected, it hasto be called when the window has its “final” size, i.e. after calling`Gtk.Widget:show_all()on the contents andGtk.Window:set_geometry_hints()`on the window.

include <gtk/gtk.h>static voidfill_with_content (Gtk.Widget vbox){ // fill with content...}intmain (int argc, char argv[]){ Gtk.Widget window, vbox; GdkGeometry size_hints = { 100, 50, 0, 0, 100, 50, 10, 10, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST }; Gtk.init (&argc, &argv); window = Gtk.Window:new (GTK_WINDOW_TOPLEVEL); vbox = Gtk.Box:new (GTK_ORIENTATION_VERTICAL, 0); Gtk.Container:add (GTK_CONTAINER (window), vbox); fill_with_content (vbox); Gtk.Widget:show_all (vbox); Gtk.Window:set_geometry_hints (GTK_WINDOW (window), window, &size_hints, GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC); if (argc > 1) { gboolean res; res = Gtk.Window:parse_geometry (GTK_WINDOW (window), argv[1]); if (! res) fprintf (stderr, "Failed to parse “%s”\n", argv[1]); } Gtk.Widget:show_all (window); Gtk.main (); return 0;}

  • Returns: True if string was parsed successfully

reshow_with_initial_size()

reshow_with_initial_size (self)

Gtk.Window:reshow_with_initial_size has been deprecated since version 3.10 and should not be used in newly-written code. GUI builders can call Gtk.Widget:hide`()`,Gtk.Widget:unrealize() and then `Gtk.Widget:show()onwindowthemselves, if they still need this functionality. Hideswindow`, then reshows it, resetting thedefault size and position of the window. Usedby GUI builders only.


resize()

resize (self, width:int, height:int)

Resizes the window as if the user had done so, obeying geometryconstraints. The default geometry constraint is that windows maynot be smaller than their size request; to override thisconstraint, call `Gtk.Widget:set_size_request()to set the window'srequest to a smaller value. IfGtk.Window:resize()is called before showing a window for thefirst time, it overrides any default size set withGtk.Window:set_default_size()`. Windows may not be resized smaller than 1 by 1 pixels.


resize_to_geometry()

resize_to_geometry (self, width:int, height:int)

Like Gtk.Window:resize(), but width and height are interpretedin terms of the base size and increment set withGtk.Window:set_geometry_hints.

  • Since: 3.0

set_default_icon_list()

set_default_icon_list (list:list)

Sets an icon list to be used as fallback for windows that haven'thad Gtk.Window:set_icon_list() called on them to set up awindow-specific icon list. This function allows you to set up theicon for all windows in your app at once. See Gtk.Window:set_icon_list() for more details.


set_default_icon()

set_default_icon (icon:GdkPixbuf.Pixbuf)

Sets an icon to be used as fallback for windows that haven'thad Gtk.Window:set_icon() called on them from a pixbuf.

  • Since: 2.4

set_default_icon_from_file()

set_default_icon_from_file (filename:str) -> bool

Sets an icon to be used as fallback for windows that haven'thad Gtk.Window:set_icon_list() called on them from a fileon disk. Warns on failure if err is None.

  • Returns: True if setting the icon succeeded.

  • Since: 2.2


set_default_icon_name()

set_default_icon_name (name:str)

Sets an icon to be used as fallback for windows that haven'thad Gtk.Window:set_icon_list() called on them from a namedthemed icon, see Gtk.Window:set_icon_name().

  • Since: 2.6

set_icon()

set_icon (self, icon:GdkPixbuf.Pixbuf=None)

Sets up the icon representing a Gtk.Window. This icon is used whenthe window is minimized (also known as iconified). Some windowmanagers or desktop environments may also place it in the windowframe, or display it in other contexts. The icon should be provided in whatever size it was naturallydrawn; that is, don’t scale the image before passing it toGTK+. Scaling is postponed until the last minute, when the desiredfinal size is known, to allow best quality. If you have your icon hand-drawn in multiple sizes, useGtk.Window:set_icon_list(). Then the best size will be used. This function is equivalent to calling Gtk.Window:set_icon_list()with a 1-element list. See also Gtk.Window:set_default_icon_list() to set the iconfor all windows in your application in one go.


set_icon_list()

set_icon_list (self, list:list)

Sets up the icon representing a Gtk.Window. The icon is used whenthe window is minimized (also known as iconified). Some windowmanagers or desktop environments may also place it in the windowframe, or display it in other contexts. Gtk.Window:set_icon_list() allows you to pass in the same icon inseveral hand-drawn sizes. The list should contain the natural sizesyour icon is available in; that is, don’t scale the image beforepassing it to GTK+. Scaling is postponed until the last minute,when the desired final size is known, to allow best quality. By passing several sizes, you may improve the final image qualityof the icon, by reducing or eliminating automatic image scaling. Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, andlarger images (64x64, 128x128) if you have them. See also Gtk.Window:set_default_icon_list() to set the iconfor all windows in your application in one go. Note that transient windows (those who have been set transient for anotherwindow using Gtk.Window:set_transient_for()) will inherit theiricon from their transient parent. So there’s no need to explicitlyset the icon on transient windows.


set_icon_from_file()

set_icon_from_file (self, filename:str) -> bool

Sets the icon for window. Warns on failure if err is None. This function is equivalent to calling Gtk.Window:set_icon()with a pixbuf created by loading the image from filename.

  • Returns: True if setting the icon succeeded.

  • Since: 2.2


set_icon_name()

set_icon_name (self, name:str=None)

Sets the icon for the window from a named themed icon. Seethe docs for Gtk.IconTheme for more details. Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.

  • Since: 2.6

set_auto_startup_notification()

set_auto_startup_notification (setting:bool)

By default, after showing the first Gtk.Window, GTK+ calls gdk_notify_startup_complete(). Call this function to disable the automatic startup notification. You might do this if your first window is a splash screen, and you want to delay notification until after your real main window has been shown, for example. In that example, you would disable startup notificationtemporarily, show your splash screen, then re-enable it so thatshowing the main window would automatically result in notification.

  • Since: 2.2

get_opacity()

get_opacity (self) -> float

Gtk.Window:get_opacity has been deprecated since version 3.8 and should not be used in newly-written code. Use Gtk.Widget:get_opacity instead. Fetches the requested opacity for this window. SeeGtk.Window:set_opacity().

  • Returns: the requested opacity for this window.

  • Since: 2.12


set_opacity()

set_opacity (self, opacity:float)

Gtk.Window:set_opacity has been deprecated since version 3.8 and should not be used in newly-written code. Use Gtk.Widget:set_opacity instead. Request the windowing system to make window partially transparent,with opacity 0 being fully transparent and 1 fully opaque. (Valuesof the opacity parameter are clamped to the [0,1] range.) On X11this has any effect only on X screens with a compositing managerrunning. See `Gtk.Widget:is_composited()`. On Windows it should workalways. Note that setting a window’s opacity after the window has beenshown causes it to flicker once on Windows.

  • Since: 2.12

get_mnemonics_visible()

get_mnemonics_visible (self) -> bool

Gets the value of the “mnemonics-visible” property.

  • Returns: True if mnemonics are supposed to be visiblein this window.

  • Since: 2.20


set_mnemonics_visible()

set_mnemonics_visible (self, setting:bool)

Sets the “mnemonics-visible” property.

  • Since: 2.20

get_focus_visible()

get_focus_visible (self) -> bool

Gets the value of the “focus-visible” property.

  • Returns: True if “focus rectangles” are supposed to be visiblein this window.

  • Since: 3.2


set_focus_visible()

set_focus_visible (self, setting:bool)

Sets the “focus-visible” property.

  • Since: 3.2

set_has_resize_grip()

set_has_resize_grip (self, value:bool)

Gtk.Window:set_has_resize_grip has been deprecated since version 3.14 and should not be used in newly-written code. Resize grips have been removed. Sets whether window has a corner resize grip. Note that the resize grip is only shown if the windowis actually resizable and not maximized. UseGtk.Window:resize_grip_is_visible() to find out if theresize grip is currently shown.

  • Since: 3.0

get_has_resize_grip()

get_has_resize_grip (self) -> bool

Gtk.Window:get_has_resize_grip has been deprecated since version 3.14 and should not be used in newly-written code. Resize grips have been removed. Determines whether the window may have a resize grip.

  • Returns: True if the window has a resize grip

  • Since: 3.0


resize_grip_is_visible()

resize_grip_is_visible (self) -> bool

Gtk.Window:resize_grip_is_visible has been deprecated since version 3.14 and should not be used in newly-written code. Resize grips have been removed. Determines whether a resize grip is visible for the specified window.

  • Returns: True if a resize grip exists and is visible

  • Since: 3.0


get_resize_grip_area()

get_resize_grip_area (self) -> bool, rect:Gdk.Rectangle

Gtk.Window:get_resize_grip_area has been deprecated since version 3.14 and should not be used in newly-written code. Resize grips have been removed. If a window has a resize grip, this will retrieve the gripposition, width and height into the specified GdkRectangle.

  • Returns: True if the resize grip’s area was retrieved

  • Since: 3.0


get_application()

get_application (self) -> Gtk.Application

Gets the Gtk.Application associated with the window (if any).

  • Returns: a Gtk.Application, or None.

  • Since: 3.0


set_application()

set_application (self, application:Gtk.Application=None)

Sets or unsets the Gtk.Application associated with the window. The application will be kept alive for at least as long as the windowis open.

  • Since: 3.0

set_has_user_ref_count()

set_has_user_ref_count (self, setting:bool)

Tells GTK+ whether to drop its extra reference to the windowwhen `Gtk.Widget:destroy()` is called. This function is only exported for the benefit of languagebindings which may need to keep the window alive until theirwrapper object is garbage collected. There is no justificationfor ever calling this function in an application.

  • Since: 3.0

set_titlebar()

set_titlebar (self, titlebar:Gtk.Widget=None)

Sets a custom titlebar for window. If you set a custom titlebar, GTK+ will do its best to convincethe window manager not to put its own titlebar on the window.Depending on the system, this function may not work for a windowthat is already visible, so you set the titlebar before calling`Gtk.Widget:show()`.

  • Since: 3.10

get_titlebar()

get_titlebar (self) -> Gtk.Widget

Returns the custom titlebar that has been set withGtk.Window:set_titlebar().

  • Returns: the custom titlebar, or None.

  • Since: 3.16


set_interactive_debugging()

set_interactive_debugging (enable:bool)

Opens or closes the interactive debugger,which offers access to the widget hierarchy of the applicationand to useful debugging tools.

  • Since: 3.14

Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class Window(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title("Window")
        self.connect("destroy", Gtk.main_quit)

window = Window()
window.show()

Gtk.main()

results matching ""

    No results matching ""