PyGobject(六十一)Gtk.Widget
在前面的系列文章中基本介绍完了PyGobject中的布局容器,接下来的文章将重点介绍常用的一些部件。本文主要介绍Gtk.Widget这个抽象类Gtk.WidgetGtk.Widget是Gtk+中其它部件的父类,它负责管理部件的生命周期、状态和显示风格继承关系Methods方法修饰词方法名及参数staticget_default_direction ()static
·
在前面的系列文章中基本介绍完了PyGobject中的布局容器,接下来的文章将重点介绍常用的一些部件。
本文主要介绍Gtk.Widget这个抽象类
Gtk.Widget
Gtk.Widget是Gtk+中其它部件的父类,它负责管理部件的生命周期、状态和显示风格
继承关系
Methods
方法修饰词 | 方法名及参数 |
---|---|
static | get_default_direction () |
static | get_default_style () |
static | pop_composite_child () |
static | push_composite_child () |
static | set_default_direction (dir) |
activate () | |
add_accelerator (accel_signal, accel_group, accel_key, accel_mods, accel_flags) | |
add_device_events (device, events) | |
add_events (events) | |
add_mnemonic_label (label) | |
add_tick_callback (callback, *user_data) | |
can_activate_accel (signal_id) | |
child_focus (direction) | |
child_notify (child_property) | |
class_path () | |
compute_expand (orientation) | |
create_pango_context () | |
create_pango_layout (text) | |
destroy () | |
destroyed (widget_pointer) | |
device_is_shadowed (device) | |
drag_begin (targets, actions, button, event) | |
drag_begin_with_coordinates (targets, actions, button, event, x, y) | |
drag_check_threshold (start_x, start_y, current_x, current_y) | |
drag_dest_add_image_targets () | |
drag_dest_add_text_targets () | |
drag_dest_add_uri_targets () | |
drag_dest_find_target (context, target_list) | |
drag_dest_get_target_list () | |
drag_dest_get_track_motion () | |
drag_dest_set (flags, targets, actions) | |
drag_dest_set_proxy (proxy_window, protocol, use_coordinates) | |
drag_dest_set_target_list (target_list) | |
drag_dest_set_track_motion (track_motion) | |
drag_dest_unset () | |
drag_get_data (context, target, time_) | |
drag_highlight () | |
drag_source_add_image_targets () | |
drag_source_add_text_targets () | |
drag_source_add_uri_targets () | |
drag_source_get_target_list () | |
drag_source_set (start_button_mask, targets, actions) | |
drag_source_set_icon_gicon (icon) | |
drag_source_set_icon_name (icon_name) | |
drag_source_set_icon_pixbuf (pixbuf) | |
drag_source_set_icon_stock (stock_id) | |
drag_source_set_target_list (target_list) | |
drag_source_unset () | |
drag_unhighlight () | |
draw (cr) | |
ensure_style () | |
error_bell () | |
event (event) | |
freeze_child_notify () | |
get_accessible () | |
get_action_group (prefix) | |
get_allocated_baseline () | |
get_allocated_height () | |
get_allocated_size () | |
get_allocated_width () | |
get_allocation () | |
get_ancestor (widget_type) | |
get_app_paintable () | |
get_can_default () | |
get_can_focus () | |
get_child_requisition () | |
get_child_visible () | |
get_clip () | |
get_clipboard (selection) | |
get_composite_name () | |
get_device_enabled (device) | |
get_device_events (device) | |
get_direction () | |
get_display () | |
get_double_buffered () | |
get_events () | |
get_focus_on_click () | |
get_font_map () | |
get_font_options () | |
get_frame_clock () | |
get_halign () | |
get_has_tooltip () | |
get_has_window () | |
get_hexpand () | |
get_hexpand_set () | |
get_mapped () | |
get_margin_bottom () | |
get_margin_end () | |
get_margin_left () | |
get_margin_right () | |
get_margin_start () | |
get_margin_top () | |
get_modifier_mask (intent) | |
get_modifier_style () | |
get_name () | |
get_no_show_all () | |
get_opacity () | |
get_pango_context () | |
get_parent () | |
get_parent_window () | |
get_path () | |
get_pointer () | |
get_preferred_height () | |
get_preferred_height_and_baseline_for_width (width) | |
get_preferred_height_for_width (width) | |
get_preferred_size () | |
get_preferred_width () | |
get_preferred_width_for_height (height) | |
get_realized () | |
get_receives_default () | |
get_request_mode () | |
get_requisition () | |
get_root_window () | |
get_scale_factor () | |
get_screen () | |
get_sensitive () | |
get_settings () | |
get_size_request () | |
get_state () | |
get_state_flags () | |
get_style () | |
get_style_context () | |
get_support_multidevice () | |
get_template_child (widget_type, name) | |
get_tooltip_markup () | |
get_tooltip_text () | |
get_tooltip_window () | |
get_toplevel () | |
get_valign () | |
get_valign_with_baseline () | |
get_vexpand () | |
get_vexpand_set () | |
get_visible () | |
get_visual () | |
get_window () | |
grab_add () | |
grab_default () | |
grab_focus () | |
grab_remove () | |
has_default () | |
has_focus () | |
has_grab () | |
has_rc_style () | |
has_screen () | |
has_visible_focus () | |
hide () | |
hide_on_delete () | |
in_destruction () | |
init_template () | |
input_shape_combine_region (region) | |
insert_action_group (name, group) | |
intersect (area, intersection) | |
is_ancestor (ancestor) | |
is_composited () | |
is_drawable () | |
is_focus () | |
is_sensitive () | |
is_toplevel () | |
is_visible () | |
keynav_failed (direction) | |
list_accel_closures () | |
list_action_prefixes () | |
list_mnemonic_labels () | |
map () | |
mnemonic_activate (group_cycling) | |
modify_base (state, color) | |
modify_bg (state, color) | |
modify_cursor (primary, secondary) | |
modify_fg (state, color) | |
modify_font (font_desc) | |
modify_style (style) | |
modify_text (state, color) | |
override_background_color (state, color) | |
override_color (state, color) | |
override_cursor (cursor, secondary_cursor) | |
override_font (font_desc) | |
override_symbolic_color (name, color) | |
path () | |
queue_allocate () | |
queue_compute_expand () | |
queue_draw () | |
queue_draw_area (x, y, width, height) | |
queue_draw_region (region) | |
queue_resize () | |
queue_resize_no_redraw () | |
realize () | |
region_intersect (region) | |
register_window (window) | |
remove_accelerator (accel_group, accel_key, accel_mods) | |
remove_mnemonic_label (label) | |
remove_tick_callback (id) | |
render_icon (stock_id, size, detail) | |
render_icon_pixbuf (stock_id, size) | |
reparent (new_parent) | |
reset_rc_styles () | |
reset_style () | |
send_expose (event) | |
send_focus_change (event) | |
set_accel_path (accel_path, accel_group) | |
set_allocation (allocation) | |
set_app_paintable (app_paintable) | |
set_can_default (can_default) | |
set_can_focus (can_focus) | |
set_child_visible (is_visible) | |
set_clip (clip) | |
set_composite_name (name) | |
set_device_enabled (device, enabled) | |
set_device_events (device, events) | |
set_direction (dir) | |
set_double_buffered (double_buffered) | |
set_events (events) | |
set_focus_on_click (focus_on_click) | |
set_font_map (font_map) | |
set_font_options (options) | |
set_halign (align) | |
set_has_tooltip (has_tooltip) | |
set_has_window (has_window) | |
set_hexpand (expand) | |
set_hexpand_set (set) | |
set_mapped (mapped) | |
set_margin_bottom (margin) | |
set_margin_end (margin) | |
set_margin_left (margin) | |
set_margin_right (margin) | |
set_margin_start (margin) | |
set_margin_top (margin) | |
set_name (name) | |
set_no_show_all (no_show_all) | |
set_opacity (opacity) | |
set_parent (parent) | |
set_parent_window (parent_window) | |
set_realized (realized) | |
set_receives_default (receives_default) | |
set_redraw_on_allocate (redraw_on_allocate) | |
set_sensitive (sensitive) | |
set_size_request (width, height) | |
set_state (state) | |
set_state_flags (flags, clear) | |
set_style (style) | |
set_support_multidevice (support_multidevice) | |
set_tooltip_markup (markup) | |
set_tooltip_text (text) | |
set_tooltip_window (custom_window) | |
set_valign (align) | |
set_vexpand (expand) | |
set_vexpand_set (set) | |
set_visible (visible) | |
set_visual (visual) | |
set_window (window) | |
shape_combine_region (region) | |
show () | |
show_all () | |
show_now () | |
size_allocate (allocation) | |
size_allocate_with_baseline (allocation, baseline) | |
size_request () | |
style_attach () | |
style_get_property (property_name, value=None) | |
thaw_child_notify () | |
translate_coordinates (dest_widget, src_x, src_y) | |
trigger_tooltip_query () | |
unmap () | |
unparent () | |
unrealize () | |
unregister_window (window) | |
unset_state_flags (flags) |
Virtual Methods
do_adjust_baseline_allocation (baseline) |
do_adjust_baseline_request (minimum_baseline, natural_baseline) |
do_adjust_size_allocation (orientation, minimum_size, natural_size, allocated_pos, allocated_size) |
do_adjust_size_request (orientation, minimum_size, natural_size) |
do_button_press_event (event) |
do_button_release_event (event) |
do_can_activate_accel (signal_id) |
do_child_notify (child_property) |
do_composited_changed () |
do_compute_expand (hexpand_p, vexpand_p) |
do_configure_event (event) |
do_damage_event (event) |
do_delete_event (event) |
do_destroy () |
do_destroy_event (event) |
do_direction_changed (previous_direction) |
do_dispatch_child_properties_changed (n_pspecs, pspecs) |
do_drag_begin (context) |
do_drag_data_delete (context) |
do_drag_data_get (context, selection_data, info, time_) |
do_drag_data_received (context, x, y, selection_data, info, time_) |
do_drag_drop (context, x, y, time_) |
do_drag_end (context) |
do_drag_failed (context, result) |
do_drag_leave (context, time_) |
do_drag_motion (context, x, y, time_) |
do_draw (cr) |
do_enter_notify_event (event) |
do_event (event) |
do_focus (direction) |
do_focus_in_event (event) |
do_focus_out_event (event) |
do_get_accessible () |
do_get_preferred_height () |
do_get_preferred_height_and_baseline_for_width (width) |
do_get_preferred_height_for_width (width) |
do_get_preferred_width () |
do_get_preferred_width_for_height (height) |
do_get_request_mode () |
do_grab_broken_event (event) |
do_grab_focus () |
do_grab_notify (was_grabbed) |
do_hide () |
do_hierarchy_changed (previous_toplevel) |
do_key_press_event (event) |
do_key_release_event (event) |
do_keynav_failed (direction) |
do_leave_notify_event (event) |
do_map () |
do_map_event (event) |
do_mnemonic_activate (group_cycling) |
do_motion_notify_event (event) |
do_move_focus (direction) |
do_parent_set (previous_parent) |
do_popup_menu () |
do_property_notify_event (event) |
do_proximity_in_event (event) |
do_proximity_out_event (event) |
do_query_tooltip (x, y, keyboard_tooltip, tooltip) |
do_queue_draw_region (region) |
do_realize () |
do_screen_changed (previous_screen) |
do_scroll_event (event) |
do_selection_clear_event (event) |
do_selection_get (selection_data, info, time_) |
do_selection_notify_event (event) |
do_selection_received (selection_data, time_) |
do_selection_request_event (event) |
do_show () |
do_show_all () |
do_show_help (help_type) |
do_size_allocate (allocation) |
do_state_changed (previous_state) |
do_state_flags_changed (previous_state_flags) |
do_style_set (previous_style) |
do_style_updated () |
do_touch_event (event) |
do_unmap () |
do_unmap_event (event) |
do_unrealize () |
do_visibility_notify_event (event) |
do_window_state_event (event) |
Properties
Name | Type | Flags | Short Description |
---|---|---|---|
app-paintable | bool | r/w/en | Whether the application will paint directly on the widget |
can-default | bool | r/w/en | Whether the widget can be the default widget |
can-focus | bool | r/w/en | Whether the widget can accept the input focus |
composite-child | bool | r | Whether the widget is part of a composite widget |
double-buffered | bool | d/r/w/en | Whether the widget is double buffered deprecated |
events | Gdk.EventMask | r/w/en | The event mask that decides what kind of GdkEvents this widget gets |
expand | bool | r/w | Whether widget wants to expand in both directions |
focus-on-click | bool | r/w/en | Whether the widget should grab focus when it is clicked with the mouse |
halign | Gtk.Align | r/w/en | How to position in extra horizontal space |
has-default | bool | r/w/en | Whether the widget is the default widget |
has-focus | bool | r/w/en | Whether the widget has the input focus |
has-tooltip | bool | r/w/en | Whether this widget has a tooltip |
height-request | int | r/w/en | Override for height request of the widget, or -1 if natural request should be used |
hexpand | bool | r/w/en | Whether widget wants more horizontal space |
hexpand-set | bool | r/w/en | Whether to use the hexpand property |
is-focus | bool | r/w | Whether the widget is the focus widget within the toplevel |
margin | int | r/w | Pixels of extra space on all four sides |
margin-bottom | int | r/w/en | Pixels of extra space on the bottom side |
margin-end | int | r/w/en | Pixels of extra space on the end |
margin-left | int | d/r/w/en | Pixels of extra space on the left side deprecated |
margin-right | int | d/r/w/en | Pixels of extra space on the right side deprecated |
margin-start | int | r/w/en | Pixels of extra space on the start |
margin-top | int | r/w/en | Pixels of extra space on the top side |
name | str | r/w | The name of the widget |
no-show-all | bool | r/w/en | Whether Gtk.Widget.show_all() should not affect this widget |
opacity | float | r/w/en | The opacity of the widget, from 0 to 1 |
parent | Gtk.Container | r/w | The parent widget of this widget. Must be a Container widget |
receives-default | bool | r/w/en | If True, the widget will receive the default action when it is focused |
scale-factor | int | r | The scaling factor of the window |
sensitive | bool | r/w/en | Whether the widget responds to input |
style | Gtk.Style | d/r/w | The style of the widget, which contains information about how it will look (colors etc) deprecated |
tooltip-markup | str | r/w | The contents of the tooltip for this widget |
tooltip-text | str | r/w | The contents of the tooltip for this widget |
valign | Gtk.Align | r/w/en | How to position in extra vertical space |
vexpand | bool | r/w/en | Whether widget wants more vertical space |
vexpand-set | bool | r/w/en | Whether to use the vexpand property |
visible | bool | r/w/en | Whether the widget is visible |
width-request | int | r/w/en | Override for width request of the widget, or -1 if natural request should be used |
window | Gdk.Window r | The widget’s window if it is realized |
Signals
Name | Short Description |
---|---|
accel-closures-changed | |
button-press-event | The ::button-press-event signal will be emitted when a button (typically from a mouse) is pressed. |
button-release-event | The ::button-release-event signal will be emitted when a button (typically from a mouse) is released. |
can-activate-accel | Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. |
child-notify | The ::child-notify signal is emitted for each ‘child property [child-properties]’ that has changed on an object. |
composited-changed | The ::composited-changed signal is emitted when the composited status of widgets screen changes. |
configure-event | The ::configure-event signal will be emitted when the size, position or stacking of the widget‘s window has changed. |
damage-event | Emitted when a redirected window belonging to widget gets drawn into. |
delete-event | The ::delete-event signal is emitted if a user requests that a toplevel window is closed. |
destroy | Signals that all holders of a reference to the widget should release the reference that they hold. |
destroy-event | The ::destroy-event signal is emitted when a Gdk.Window is destroyed. |
direction-changed | The ::direction-changed signal is emitted when the text direction of a widget changes. |
drag-begin | The ::drag-begin signal is emitted on the drag source when a drag is started. |
drag-data-delete | The ::drag-data-delete signal is emitted on the drag source when a drag with the action Gdk.DragAction.MOVE is successfully completed. |
drag-data-get | The ::drag-data-get signal is emitted on the drag source when the drop site requests the data which is dragged. |
drag-data-received | The ::drag-data-received signal is emitted on the drop site when the dragged data has been received. |
drag-drop | The ::drag-drop signal is emitted on the drop site when the user drops the data onto the widget. |
drag-end | The ::drag-end signal is emitted on the drag source when a drag is finished. |
drag-failed | The ::drag-failed signal is emitted on the drag source when a drag has failed. |
drag-leave | The ::drag-leave signal is emitted on the drop site when the cursor leaves the widget. |
drag-motion | The ::drag-motion signal is emitted on the drop site when the user moves the cursor over the widget during a drag. |
draw | This signal is emitted when a widget is supposed to render itself. |
enter-notify-event | The ::enter-notify-event will be emitted when the pointer enters the widget‘s window. |
event | The GTK+ main loop will emit three signals for each GDK event delivered to a widget: one generic ::event signal, another, more specific, signal that matches the type of event delivered (e.g. |
event-after | After the emission of the Gtk.Widget ::event signal and (optionally) the second more specific signal, ::event-after will be emitted regardless of the previous two signals handlers return values. |
focus | |
focus-in-event | The ::focus-in-event signal will be emitted when the keyboard focus enters the widget‘s window. |
focus-out-event | The ::focus-out-event signal will be emitted when the keyboard focus leaves the widget‘s window. |
grab-broken-event | Emitted when a pointer or keyboard grab on a window belonging to widget gets broken. |
grab-focus | |
grab-notify | The ::grab-notify signal is emitted when a widget becomes shadowed by a GTK+ grab (not a pointer or keyboard grab) on another widget, or when it becomes unshadowed due to a grab being removed. |
hide | The ::hide signal is emitted when widget is hidden, for example with Gtk.Widget.hide(). |
hierarchy-changed | The ::hierarchy-changed signal is emitted when the anchored state of a widget changes. |
key-press-event | The ::key-press-event signal is emitted when a key is pressed. |
key-release-event | The ::key-release-event signal is emitted when a key is released. |
keynav-failed | Gets emitted if keyboard navigation fails. |
leave-notify-event | The ::leave-notify-event will be emitted when the pointer leaves the widget‘s window. |
map | The ::map signal is emitted when widget is going to be mapped, that is when the widget is visible (which is controlled with Gtk.Widget.set_visible()) and all its parents up to the toplevel widget are also visible. |
map-event | The ::map-event signal will be emitted when the widget‘s window is mapped. |
mnemonic-activate | |
motion-notify-event | The ::motion-notify-event signal is emitted when the pointer moves over the widget’s Gdk.Window. |
move-focus | |
parent-set | The ::parent-set signal is emitted when a new parent has been set on a widget. |
popup-menu | This signal gets emitted whenever a widget should pop up a context menu. |
property-notify-event | The ::property-notify-event signal will be emitted when a property on the widget‘s window has been changed or deleted. |
proximity-in-event | To receive this signal the Gdk.Window associated to the widget needs to enable the Gdk.EventMask.PROXIMITY_IN_MASK mask. |
proximity-out-event | To receive this signal the Gdk.Window associated to the widget needs to enable the Gdk.EventMask.PROXIMITY_OUT_MASK mask. |
query-tooltip | Emitted when Gtk.Widget :has-tooltip is True and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode. |
realize | The ::realize signal is emitted when widget is associated with a Gdk.Window, which means that Gtk.Widget.realize() has been called or the widget has been mapped (that is, it is going to be drawn). |
screen-changed | The ::screen-changed signal gets emitted when the screen of a widget has changed. |
scroll-event | The ::scroll-event signal is emitted when a button in the 4 to 7 range is pressed. |
selection-clear-event | The ::selection-clear-event signal will be emitted when the the widget‘s window has lost ownership of a selection. |
selection-get | |
selection-notify-event | |
selection-received | |
selection-request-event | The ::selection-request-event signal will be emitted when another client requests ownership of the selection owned by the widget‘s window. |
show | The ::show signal is emitted when widget is shown, for example with Gtk.Widget.show(). |
show-help | |
size-allocate | |
state-changed | The ::state-changed signal is emitted when the widget state changes. deprecated |
state-flags-changed | The ::state-flags-changed signal is emitted when the widget state changes, see Gtk.Widget.get_state_flags(). |
style-set | The ::style-set signal is emitted when a new style has been set on a widget. deprecated |
style-updated | The ::style-updated signal is emitted when the Gtk.StyleContext of a widget is changed. |
touch-event | |
unmap | The ::unmap signal is emitted when widget is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden. |
unmap-event | The ::unmap-event signal will be emitted when the widget‘s window is unmapped. |
unrealize | The ::unrealize signal is emitted when the Gdk.Window associated with widget is destroyed, which means that Gtk.Widget.unrealize() has been called or the widget has been unmapped (that is, it is going to be hidden). |
visibility-notify-event | The ::visibility-notify-event will be emitted when the widget‘s window is obscured or unobscured. deprecated |
window-state-event | The ::window-state-event will be emitted when the state of the toplevel window associated to the widget changes. |
更多推荐
已为社区贡献7条内容
所有评论(0)