pygtk_events

含有章节索引的中文 文章模板

::-- ehu4ever [2005-08-08 03:51:44]

1. 五花八门的事件

除了上个章节所说的“信号发生处理机制”,“X事件响应机制”里还有一大堆的“事件”:“回调函数”也是用来响应这些事件的。 这些事件是:

  event
  button_press_event
  button_release_event
  scroll_event
  motion_notify_event
  delete_event
  destroy_event
  expose_event
  key_press_event
  key_release_event
  enter_notify_event
  leave_notify_event
  configure_event
  focus_in_event
  focus_out_event
  map_event
  unmap_event
  property_notify_event
  selection_clear_event
  selection_request_event
  selection_notify_event
  proximity_in_event
  proximity_out_event
  visibility_notify_event
  client_event
  no_expose_event
  window_state_even

以上这些东东归gtk.gdk管,比如gtk.gtk.DRAG_ENTER。

下面我们把callback和event边起来,就像这样:

button.connect("button_press_event", button_press_callback)

上面的button是一个GtkWidget。这样,当鼠标在这个button按了一下,button_press_callback就被调用了。这个button_press_callback的定义可能是这样的:

def button_press_callback(widget, event, data ):

这个callback的返回值决定了还要不要继续处理其它事件,返回True表示打完收功,而False表示继续standby。想知道更详细,请看这里:Advanced Event and Signal Handling

The GDK selection and drag-and-drop APIs also emit a number of events which are reflected in GTK+ by signals. See Section 22.3.2, “Signals On the Source Widget” and Section 22.3.4, “Signals On the Destination Widget” for details on the signatures of the callback functions for these signals:

selection_received
selection_get
drag_begin_event
drag_end_event
drag_data_delete
drag_motion
drag_drop
drag_data_get
drag_data_received

pygtk_events (last edited 2009-12-25 07:17:34 by localhost)