Python gi.repository.Gdk 模块,Event() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用gi.repository.Gdk.Event()

项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
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
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
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
项目:any_ping_indicator    作者:leggedrobotics    | 项目源码 | 文件源码
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))
项目:gnome-appfolders-manager    作者:muflone    | 项目源码 | 文件源码
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)
项目:cozy    作者:geigi    | 项目源码 | 文件源码
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)
项目:cozy    作者:geigi    | 项目源码 | 文件源码
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)
项目:cozy    作者:geigi    | 项目源码 | 文件源码
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")
项目:cozy    作者:geigi    | 项目源码 | 文件源码
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()
项目:sticky-notes    作者:rubyAce71697    | 项目源码 | 文件源码
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())