python类keyval_from_name()的实例源码

account_row.py 文件源码 项目:Gnome-Authenticator 作者: bil-elmoussaoui 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, parent, window, account):
        # Read default values
        self.window = window
        self.parent = parent
        self.account = account
        # Create needed widgets
        self.code_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.revealer = Gtk.Revealer()
        self.checkbox = Gtk.CheckButton()
        self.application_name = Gtk.Label(xalign=0)
        self.code_label = Gtk.Label(xalign=0)
        self.timer_label = Gtk.Label(xalign=0)
        self.accel = Gtk.AccelGroup()
        self.window.add_accel_group(self.accel)
        self.accel.connect(Gdk.keyval_from_name('C'), Gdk.ModifierType.CONTROL_MASK, 0, self.copy_code)
        self.accel.connect(Gdk.keyval_from_name("Enter"), Gdk.ModifierType.META_MASK, 0, self.toggle_code)
exhibits.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def on_key_press(self, widget, event):
        # activate
        if (event.keyval == Gdk.keyval_from_name("space") or
            event.keyval == Gdk.keyval_from_name("Return") or
            event.keyval == Gdk.keyval_from_name("KP_Enter")):
            exhibit = self.exhibits[self.cursor]
            if exhibit.package_names:
                self.emit("show-exhibits-clicked", exhibit)
            return True
        # previous
        if (event.keyval == Gdk.keyval_from_name("Left") or
            event.keyval == Gdk.keyval_from_name("KP_Left")):
            self.on_previous_clicked()
            return True
        # next
        if (event.keyval == Gdk.keyval_from_name("Right") or
            event.keyval == Gdk.keyval_from_name("KP_Right")):
            self.on_next_clicked()
            return True
        return False
exhibits.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def on_key_press(self, widget, event):
        # activate
        if (event.keyval == Gdk.keyval_from_name("space") or
            event.keyval == Gdk.keyval_from_name("Return") or
            event.keyval == Gdk.keyval_from_name("KP_Enter")):
            exhibit = self.exhibits[self.cursor]
            if exhibit.package_names:
                self.emit("show-exhibits-clicked", exhibit)
            return True
        # previous
        if (event.keyval == Gdk.keyval_from_name("Left") or
            event.keyval == Gdk.keyval_from_name("KP_Left")):
            self.on_previous_clicked()
            return True
        # next
        if (event.keyval == Gdk.keyval_from_name("Right") or
            event.keyval == Gdk.keyval_from_name("KP_Right")):
            self.on_next_clicked()
            return True
        return False
rawinput.py 文件源码 项目:dogtail 作者: vhumpa 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def keyNameToKeyCode(keyName):
    """
    Use GDK to get the keycode for a given keystring.

    Note that the keycode returned by this function is often incorrect when
    the requested keystring is obtained by holding down the Shift key.

    Generally you should use uniCharToKeySym() and should only need this
    function for nonprintable keys anyway.
    """
    keymap = Gdk.Keymap.get_for_display(Gdk.Display.get_default())
    entries = keymap.get_entries_for_keyval(
        Gdk.keyval_from_name(keyName))
    try:
        return entries[1][0].keycode
    except TypeError:
        pass
accounts.py 文件源码 项目:Gnome-Authenticator 作者: bil-elmoussaoui 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, window, accounts):
        self.accounts = accounts
        self.window = window
        self.generate()
        self.accel = Gtk.AccelGroup()
        self.window.add_accel_group(self.accel)
        self.connect("row-activated", self.activate_row)
        self.connect("row-selected", self.selected_row)
        self.accel.connect(Gdk.keyval_from_name('Up'), Gdk.ModifierType.META_MASK, 0, self.navigate)
        self.accel.connect(Gdk.keyval_from_name('Down'), Gdk.ModifierType.META_MASK, 0, self.navigate)
searchable.py 文件源码 项目:bokken 作者: thestr4ng3r 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, textview, small=False):
        self.textview = textview
        self.small = small
        # By default, don't match case
        self._matchCaseValue = False
        # key definitions
        self.key_f = Gdk.keyval_from_name("f")
        self.key_g = Gdk.keyval_from_name("g")
        self.key_G = Gdk.keyval_from_name("G")
        self.key_F3 = Gdk.keyval_from_name("F3")
        self.key_Esc = Gdk.keyval_from_name("Escape")
        # signals
        self.connect("key-press-event", self._key)
        self.textview.connect("populate-popup", self._populate_popup)
        # colors for textview and entry backgrounds
        self.textbuf = self.textview.get_buffer()
        self.textbuf.create_tag("yellow-background", background="yellow")
        #MEOW
        #colormap = self.get_colormap()
        #self.bg_normal = colormap.alloc_color("white")
        #self.bg_notfnd = colormap.alloc_color("red")

        parse, self.bg_normal = Gdk.Color.parse('white')
        parse, self.bg_notfnd = Gdk.Color.parse('red')

        # build the search tab
        self._build_search(None)
        self.searching = True
        self.timer_id = None
main.py 文件源码 项目:pytimetrack 作者: fhackerz 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def do_key_press_event(self, event):
        if event.keyval == Gdk.keyval_from_name('Prior'):
            self._do_history(1)
            return True
        if event.keyval == Gdk.keyval_from_name('Next'):
            self._do_history(-1)
            return True
        return Gtk.Entry.do_key_press_event(self, event)
softwarepane.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def on_search_entry_key_press_event(self, event):
        """callback when a key is pressed in the search entry widget"""
        if not self.is_applist_view_showing():
            return
        if ((event.keyval == Gdk.keyval_from_name("Down") or
            event.keyval == Gdk.keyval_from_name("KP_Down")) and
            self.is_applist_view_showing() and
            len(self.app_view.tree_view.get_model()) > 0):
            # select the first item in the applist search result
            self.app_view.tree_view.grab_focus()
            self.app_view.tree_view.set_cursor(Gtk.TreePath(),
                                                   None, False)
softwarepane.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def on_search_entry_key_press_event(self, event):
        """callback when a key is pressed in the search entry widget"""
        if not self.is_applist_view_showing():
            return
        if ((event.keyval == Gdk.keyval_from_name("Down") or
            event.keyval == Gdk.keyval_from_name("KP_Down")) and
            self.is_applist_view_showing() and
            len(self.app_view.tree_view.get_model()) > 0):
            # select the first item in the applist search result
            self.app_view.tree_view.grab_focus()
            self.app_view.tree_view.set_cursor(Gtk.TreePath(),
                                                   None, False)
rawinput.py 文件源码 项目:dogtail 作者: vhumpa 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def keyNameToKeySym(keyName):
    keyName = keyNameAliases.get(keyName.lower(), keyName)
    keySym = Gdk.keyval_from_name(keyName)
    # various error 'codes' returned for non-recognized chars in versions of GTK3.X
    if keySym == 0xffffff or keySym == 0x0 or keySym is None:
        try:
            keySym = uniCharToKeySym(keyName)
        except:  # not even valid utf-8 char
            try:  # Last attempt run at a keyName ('Meta_L', 'Dash' ...)
                keySym = getattr(Gdk, 'KEY_' + keyName)
            except AttributeError:
                raise KeyError(keyName)
    return keySym


问题


面经


文章

微信
公众号

扫码关注公众号