pygtk入门(3)-事件

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
用于事件的回调函数的格式:(注意和用于信号的不同)

 

 

def callback_func(widget, event, callback_data ):

def callback_meth(self, widget, event, callback_data ):

 

GdkEvent是python对象,其type属性指示了发生了什么事件,其它属性都依赖于事件的type,有以下这些值:

 

 

NOTHING

DELETE

DESTROY

EXPOSE

MOTION_NOTIFY

BUTTON_PRESS

_2BUTTON_PRESS

_3BUTTON_PRESS

BUTTON_RELEASE

KEY_PRESS

KEY_RELEASE

ENTER_NOTIFY

LEAVE_NOTIFY

FOCUS_CHANGE

CONFIGURE

MAP

UNMAP

PROPERTY_NOTIFY

SELECTION_CLEAR

SELECTION_REQUEST

SELECTION_NOTIFY

PROXIMITY_IN

PROXIMITY_OUT

DRAG_ENTER

DRAG_LEAVE

DRAG_MOTION

DRAG_STATUS

DROP_START

DROP_FINISHED

CLIENT_EVENT

VISIBILITY_NOTIFY

NO_EXPOSE

SCROLL

WINDOW_STATE

SETTING

比如以下事件处理程序

 

button.connect("button_press_event", button_press_callback)

def button_press_callback(widget, event, data ):


 button_press_callback函数返回的值表示该事件是否进一步被GTK+事件处理机制传播返回true表示该事件已得到处理,不应进一步传播返回FALSE继续正常事件处理

使用object.disconnect(id)能从对象的connect列表中移走回调。

你也能用以下2个函数临时性地禁止和允许信号处理。

 

object.signal_handler_block(handler_id)

object.signal_handler_unblock(handler_id)


你可能感兴趣的:(gtk)