Pygtk-window-class

提供:Dev Guides
移動先:案内検索

PyGTK-ウィンドウクラス

gtk.Windowクラスのオブジェクトは、ユーザーが一般にWwindowと考えるウィジェットを提供します。 このウィジェットはコンテナなので、1つの子ウィジェットを保持できます。 タイトルバーとサイズ変更コントロールで飾られた表示可能な領域を提供します。

gtk.Windowクラスには、次のコンストラクタがあります-

gtk.Window(type)

型パラメータは、次の値のいずれかを取ります-

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

gtk.Windowクラスの重要なメソッドのいくつかを以下に示します-

S.NO Methods and Description
1

set_title(string)

これにより、gtk.windowの「title」プロパティが title で指定された値に設定されます。 ウィンドウのタイトルは、タイトルバーに表示されます。

2

get_title()

設定されている場合、これはウィンドウのタイトルを返します。

3

set_position()

これにより、ウィンドウの位置が設定されます。 事前定義された位置定数は-

  • 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()*

これにより、指定されたウィジェットがウィンドウのフォーカスウィジェットに設定されます。

4

set_resizable()

これはデフォルトで当てはまります。 set_resizable()は、ユーザーがウィンドウのサイズを設定するのに役立ちます。

5

set_decorated()

これはデフォルトで当てはまります。 falseの場合、タイトルバーとウィンドウのサイズ変更コントロールは無効になります。

6

set_modal()

trueの場合、ウィンドウはモーダルになり、他のウィンドウとの相互作用が防止されます。 これは、Dialogウィジェットに使用されます。

7

set_default_size()

これにより、ウィンドウのデフォルトサイズが、ピクセル単位で指定された幅と高さに設定されます。

gtk.Windowウィジェットは、次の信号を発します-

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*.