- GtkContainer
- 继承关系
- Methods
-
-
- add widget
- check_resize
- child_get child prop_names
- child_get_property child property_name valueNone
- child_notify child child_property
- child_notify_by_pspec child pspec
- child_set child kwargs
- child_set_property child property_name value
- child_type
- forall callback callback_data
- foreach callback callback_data
- get_border_width
- get_children
- get_focus_chain
- get_focus_child
- get_focus_hadjustment
- get_focus_vadjustment
- get_path_for_child child
- get_resize_mode
- propagate_draw child cr
- remove widget
- resize_children
- set_border_width border_width
- set_focus_chain focusable_widgets
- set_focus_child child
- set_focus_hadjustment adjustment
- set_focus_vadjustment adjustment
- set_reallocate_redraws needs_redraws
- set_resize_mode resize_mode
- unset_focus_chain
-
-
- Virtual Methods
- Properties
- Signals
- GtkBin
- 附录
Gtk+排列小部件是通过容器的。它们对终端用户是不可见的。这里有两种风格的容器:单孩子的容器,是Gtk.Bin的后代。多孩子的容器,是Gtk.Container的后代。
最常用的是垂直或水平框(Gtk.Box)和网格(Gtk.Grid)。
Gtk.Window 是单孩子容器,只能添加一个直接子部件,如果直接在其中添加多个子部件,只会显示一个,并且会提示
Attempting to add a widget with type GtkButton to a main+MyWindow, but as a GtkBin subclass a main+MyWindow can only contain one widget at a time; it already contains a widget of type GtkButton
Gtk.Window要包含多个子部件的话,需要先在其中添加一个多孩子容器,然后在容器中再添加子部件
Gtk.Container
继承关系
Methods
add (widget)
添加部件到容器中
check_resize ()
child_get (child, *prop_names)
获取给定列表中所有属性的值,prop_names为list
child_get_property (child, property_name, value=None)
获取某一个属性的属性值
child_notify (child, child_property)
发送Gtk.Widget ::child-notify信号在child部件上
child_notify_by_pspec (child, pspec)
child_set (child, **kwargs)
设置child部件的属性,kwargs为字典键值对
child_set_property (child, property_name, value)
设置child部件的某一个属性的值
child_type ()
Return type: GObject.GType
返回容器可以添加的孩子部件的类型
注意:有可能返回GObject.TYPE_NONE,表示容器已经不可以在添加孩子了。例如Gtk.Paned已经有两个孩子了,这时候child_type()就返回GObject.TYPE_NONE
forall (callback, *callback_data)
对容器的每一个直接孩子调用callback方法最好用Gtk.Container.foreach(),方法
foreach (callback, *callback_data)
get_border_width ()
获取内边距宽度
get_children ()
Return type: [Gtk.Widget]
返回容器的非 “internal ”孩子列表
get_focus_chain ()
get_focus_child ()
Return type: Gtk.Widget
返回容器当前将要获得焦点的孩子,如果这个容器获得焦点,那么这个孩子就获得焦点
get_focus_hadjustment ()
Return type: Gtk.Adjustment or None
获取焦点的水平范围(容器在哪个范围内才可以获取到焦点)
见 Gtk.Container.set_focus_hadjustment ()
get_focus_vadjustment ()
Return type: Gtk.Adjustment or None
获取焦点的垂直范围(容器在哪个范围内才可以获取到焦点)
get_path_for_child (child)
Return type: Gtk.WidgetPath
返回部件的深度
get_resize_mode ()
Return type: Gtk.ResizeMode
获取容器调整大小模式
propagate_draw (child, cr)
绘制孩子
remove (widget)
移除某个部件
resize_children ()
Deprecated.
set_border_width (border_width)
设置容器内边距宽度
set_focus_chain (focusable_widgets)
set_focus_child (child)
设置获得焦点的孩子
set_focus_hadjustment (adjustment)
Parameters: adjustment (Gtk.Adjustment)
设置焦点的水平范围
set_focus_vadjustment (adjustment)
Parameters: adjustment (Gtk.Adjustment)
设置焦点的垂直范围
set_reallocate_redraws (needs_redraws)
当孩子大小变化时,容器是否自动重绘。
Deprecated.改用在调整大小事件处理方法中调用Gtk.Widget.queue_draw() 方法
set_resize_mode (resize_mode)
设置调整大小模式
Deprecated.
unset_focus_chain ()
移除焦点链
Virtual Methods
do_add (widget) |
do_check_resize () |
do_child_type () |
do_composite_name (child) |
do_forall (include_internals, callback, callback_data) |
do_get_child_property (child, property_id, value, pspec) |
do_get_path_for_child (child) |
do_remove (widget) |
do_set_child_property (child, property_id, value, pspec) |
do_set_focus_child (child) |
Properties
Name | Type | Flags | Short Description |
---|---|---|---|
border-width | int | r/w/en | 孩子到容器边框的距离 |
child | Gtk.Widget | w | 孩子,可用用来添加一个新的孩子到容器中 |
resize-mode | Gtk.ResizeMode | d/r/w/en | 调整大小的方式 deprecated |
Signals
Name | Short Description |
---|---|
add | 添加孩子 |
check-resize | |
remove | 移除孩子 |
set-focus-child |
Gtk.Bin
继承关系
Methods
方法修饰词 | 方法名及参数 |
---|---|
get_child () |
get_child
获取孩子部件
附录
Gtk.ResizeMode
class Gtk.ResizeMode
Bases: GObject.GEnum
PARENT = 0
将resize 事件传递给父容器
QUEUE = 1
将resize事件压入widget的请求队列中
IMMEDIATE = 2
立即resize. Deprecated.
再接下来的文章中将逐一介绍这些布局容器~