English 中文(简体)
PyGTK - Window Class
  • 时间:2024-11-03

PyGTK - Window Class


Previous Page Next Page  

An object of the gtk.Window class provides a widget that users commonly think of as a Wwindow. This widget is a container hence, it can hold one child widget. It provides a displayable area decorated with title bar and resizing controls.

gtk.Window class has the following constructor −

gtk.Window(type)

Type paramter takes one of the following values −

gtk.WINDOW_TOPLEVEL (default) This window has no parent. The Toplevel windows are the main apppcation window and dialogs.
gtk.WINDOW_POPUP This window has no frame or decorations. A popup window is used for menus and tooltips.

Some of the important methods of the gtk.Window class are psted below −

S.NO Methods and Description
1

set_title(string)

This sets the "title" property of the gtk.window to the value specified by the title. The title of a window will be displayed in its title bar.

2

get_title()

This returns the title of a window if set.

3

set_position()

This sets the position of window. The predefined position constants are −

    gtk.WIN_POS_NONE

    gtk.WIN_POS_CENTER

    gtk.WIN_POS_MOUSE

    gtk.WIN_POS_CENTER_ALWAYS

    gtk.WIN_POS_CENTER_ON_PARENT

3

set_focus()

This sets the widget specified to be the focus widget for the window.

4

set_resizable()

This is true by default. set_resizable() helps the user to set the size of a window.

5

set_decorated()

This is true by default. If false, the title bar and the resizing controls of window will be disabled.

6

set_modal()

If true, window becomes modal and the interaction with other windows is prevented. This is used for the Dialog widgets.

7

set_default_size()

This sets the default size of the window to the specified width and height in pixels.

The gtk.Window widget emits the following signals −

activate-default This is emitted when the default child widget of window is activated usually by the user pressing the Return or Enter key.
activate-focus This is emitted when the child widget with the focus is activated usually by the user pressing the Space key.
move-focus This is emitted when the focus is changed within the window s child widgets when the user presses the Tab, the Shift+Tab or the Up, Down, Left or Right arrow keys.
set-focus This is emitted when the focus changes to widget in window.
Advertisements