我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用gi.repository.Gdk.Event()。
def _send_keys(view, s): print("_send_keys %s" % s) MAPPING = {'@': 'at', '.': 'period', '\t': 'Tab', '\n': 'Return', '?': 'question', '\a': 'Down', # fake ' ': 'space', '\v': 'Page_Down', # fake } for key in s: event = Gdk.Event(Gdk.KEY_PRESS) event.window = view.window if key.isdigit(): key = "_" + key if hasattr(Gdk, key): event.keyval = getattr(Gdk, key) else: event.keyval = getattr(Gdk, MAPPING[key]) Gtk.main_do_event(event) # \a means down key - its a just a fake to get it working
def on_button_close_clicked(self, _): """Called on close button clicked. Emit close signal. :param _: :return: """ self.emit("delete-event", gdk.Event(gdk.EventType.DELETE))
def on_action_quit_activate(self, action): """Close the application by closing the main window""" event = Gdk.Event() event.key.type = Gdk.EventType.DELETE self.ui.win_main.event(event)
def _on_enter_notify(self, widget, event): """ On enter notify change overlay opacity :param widget: as Gtk.EventBox :param event: as Gdk.Event """ self.overlay.set_opacity(0.8) self.play_revealer.set_reveal_child(True)
def _on_leave_notify(self, widget, event): """ On leave notify change overlay opacity :param widget: as Gtk.EventBox (can be None) :param event: as Gdk.Event (can be None) """ if not self.selected: self.overlay.set_opacity(1.0) self.play_revealer.set_reveal_child(False)
def _on_enter_notify(self, widget, event): """ On enter notify add css hover class :param widget: as Gtk.EventBox :param event: as Gdk.Event """ if self.ui.current_track_element is not self and not self.selected: self.play_img.set_from_icon_name( "media-playback-start-symbolic", Gtk.IconSize.SMALL_TOOLBAR) self.box.get_style_context().add_class("box_hover") self.play_img.get_style_context().add_class("box_hover")
def _on_leave_notify(self, widget, event): """ On leave notify remove css hover class :param widget: as Gtk.EventBox (can be None) :param event: as Gdk.Event (can be None) """ self.box.get_style_context().remove_class("box_hover") self.play_img.get_style_context().remove_class("box_hover") if self.ui.current_track_element is not self and not self.selected: self.play_img.clear()
def on_eventbox1_button_press_event(self,widget,event): #print self.window.get_size()[1] #print "This event called" #print Gdk.Event if event.type == 5: if self.revealer.get_reveal_child(): self.collapse_window() else: self.reveal_window() else: self.window.begin_move_drag(event.button, event.x_root, event.y_root, event.get_time())