当前位置: 首页>>代码示例>>Python>>正文


Python Gdk.keyval_from_name方法代码示例

本文整理汇总了Python中gi.repository.Gdk.keyval_from_name方法的典型用法代码示例。如果您正苦于以下问题:Python Gdk.keyval_from_name方法的具体用法?Python Gdk.keyval_from_name怎么用?Python Gdk.keyval_from_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gdk的用法示例。


在下文中一共展示了Gdk.keyval_from_name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_window_accel_groups

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def set_window_accel_groups(self):
    group = Gtk.AccelGroup()
    ctrl  = Gdk.ModifierType.CONTROL_MASK

    group.connect(Gdk.keyval_from_name('f'), ctrl, 0, self.on_revealer_accel_pressed)

    group.connect(Gdk.keyval_from_name('KP_Subtract'), ctrl, 0, self.on_zoom_decrease_accel_pressed)
    group.connect(Gdk.keyval_from_name('minus'), ctrl, 0, self.on_zoom_decrease_accel_pressed)

    group.connect(Gdk.keyval_from_name('KP_Add'), ctrl, 0, self.on_zoom_increase_accel_pressed)
    group.connect(Gdk.keyval_from_name('plus'), ctrl, 0, self.on_zoom_increase_accel_pressed)

    group.connect(Gdk.keyval_from_name('KP_0'), ctrl, 0, self.on_zoom_reset_accel_pressed)
    group.connect(Gdk.keyval_from_name('0'), ctrl, 0, self.on_zoom_reset_accel_pressed)

    self.window.add_accel_group(group) 
开发者ID:hardpixel,项目名称:devdocs-desktop,代码行数:18,代码来源:devdocs_desktop.py

示例2: test_debug_mode_eventhandler

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def test_debug_mode_eventhandler(self):
        """Run keybinding and mouse click in debug mode and therefore log it."""
        # Keybinding
        event = Gdk.Event().new(Gdk.EventType.KEY_PRESS)
        event.keyval = Gdk.keyval_from_name("j")
        self.vimiv["library"].emit("key_press_event", event)
        last_line = self.read_log(string=False)[-1]
        self.assertEqual(last_line, "%-15s %s\n" % ("[key]", "j: scroll_lib j"))
        # Mouse click
        event = Gdk.Event().new(Gdk.EventType.BUTTON_PRESS)
        event.button = 1
        self.vimiv["window"].emit("button_press_event", event)
        last_line = self.read_log(string=False)[-1]
        self.assertEqual(last_line, "%-15s %s\n" % ("[key]", "Button1: next")) 
开发者ID:karlch,项目名称:vimiv,代码行数:16,代码来源:log_test.py

示例3: test_key_press

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def test_key_press(self):
        """Press key."""
        self.vimiv["library"].file_select(None, Gtk.TreePath(1), None, True)
        image_before = self.vimiv.get_path()
        event = Gdk.Event().new(Gdk.EventType.KEY_PRESS)
        event.keyval = Gdk.keyval_from_name("n")
        self.vimiv["main_window"].emit("key_press_event", event)
        image_after = self.vimiv.get_path()
        self.assertNotEqual(image_before, image_after)
        event.keyval = Gdk.keyval_from_name("O")
        self.vimiv["main_window"].emit("key_press_event", event)
        self.assertTrue(self.vimiv["library"].is_focus()) 
开发者ID:karlch,项目名称:vimiv,代码行数:14,代码来源:eventhandler_test.py

示例4: test_add_number_via_keypress

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def test_add_number_via_keypress(self):
        """Add a number to the numstr by keypress."""
        self.assertFalse(self.vimiv["eventhandler"].get_num_str())
        event = Gdk.Event().new(Gdk.EventType.KEY_PRESS)
        event.keyval = Gdk.keyval_from_name("2")
        self.vimiv["library"].emit("key_press_event", event)
        self.assertEqual(self.vimiv["eventhandler"].get_num_str(), "2")
        # Clear as it might interfere
        self.vimiv["eventhandler"].num_clear() 
开发者ID:karlch,项目名称:vimiv,代码行数:11,代码来源:eventhandler_test.py

示例5: test_key_press_modifier

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def test_key_press_modifier(self):
        """Press key with modifier."""
        before = self.settings["show_hidden"].get_value()
        event = Gdk.Event().new(Gdk.EventType.KEY_PRESS)
        event.keyval = Gdk.keyval_from_name("h")
        event.state = Gdk.ModifierType.CONTROL_MASK
        self.vimiv["library"].emit("key_press_event", event)
        after = self.settings["show_hidden"].get_value()
        self.assertNotEqual(before, after) 
开发者ID:karlch,项目名称:vimiv,代码行数:11,代码来源:eventhandler_test.py

示例6: onKeyPress

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def onKeyPress(self, widget, event):
        if event.keyval in list(map(Gdk.keyval_from_name, ("Return", "KP_Enter"))):
            if not event.get_state() & Gdk.ModifierType.CONTROL_MASK:
                buffer = self.entry.get_buffer()
                if buffer.props.text.startswith("pas"):
                    # don't log password changes
                    self.connection.client.telnet.sensitive = True
                self.connection.client.run_command(buffer.props.text,
                                                   show_reply=True)
                self.emit("messageTyped", buffer.props.text)
                self.addMessage(buffer.props.text, True)

                self.history.append(buffer.props.text)
                buffer.props.text = ""
                self.pos = len(self.history)
                return True

        elif event.keyval == Gdk.keyval_from_name("Up"):
            if self.pos > 0:
                buffer = self.entry.get_buffer()
                self.pos -= 1
                buffer.props.text = self.history[self.pos]
            widget.grab_focus()
            return True

        elif event.keyval == Gdk.keyval_from_name("Down"):
            buffer = self.entry.get_buffer()
            if self.pos == len(self.history) - 1:
                self.pos += 1
                buffer.props.text = ""
            elif self.pos < len(self.history):
                self.pos += 1
                buffer.props.text = self.history[self.pos]
            widget.grab_focus()
            return True 
开发者ID:pychess,项目名称:pychess,代码行数:37,代码来源:ConsolePanel.py

示例7: onKeyPress

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def onKeyPress(self, widget, event):
        if event.keyval in list(map(Gdk.keyval_from_name,
                                    ("Return", "KP_Enter"))):
            if not event.get_state() & Gdk.ModifierType.CONTROL_MASK:
                buffer = self.writeView.get_buffer()
                if buffer.props.text:
                    self.emit("messageTyped", buffer.props.text)
                    buffer.props.text = ""
                return True 
开发者ID:pychess,项目名称:pychess,代码行数:11,代码来源:ChatView.py

示例8: __init__

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
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 
开发者ID:inguma,项目名称:bokken,代码行数:31,代码来源:searchable.py

示例9: on_key_press

# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import keyval_from_name [as 别名]
def on_key_press(self, widget, event):
        from gi.repository import Gtk
        from gi.repository import Gdk
        if (event.keyval == Gdk.keyval_from_name("Home") or
            ((event.keyval == Gdk.keyval_from_name("a") and
              event.get_state() & Gdk.ModifierType.CONTROL_MASK))):
            buffer = widget.get_buffer()
            cursor_pos = buffer.get_property("cursor-position")
            iter = buffer.get_iter_at_offset(cursor_pos)
            line_cnt = iter.get_line()
            start = buffer.get_iter_at_line(line_cnt)
            start.forward_chars(2)
            buffer.place_cursor(start)
            return True
        elif (event.keyval == Gdk.keyval_from_name("End") or
              (event.keyval == Gdk.keyval_from_name("e") and
               event.get_state() & Gdk.ModifierType.CONTROL_MASK)):
            buffer = widget.get_buffer()
            end = buffer.get_end_iter()
            buffer.place_cursor(end)
            return True
        elif event.keyval == Gdk.keyval_from_name("Return"):
            echo = False
            buffer = widget.get_buffer()
            cursor_pos = buffer.get_property("cursor-position")
            iter = buffer.get_iter_at_offset(cursor_pos)
            line_cnt = iter.get_line()
            start = buffer.get_iter_at_line(line_cnt)
            line_len = iter.get_chars_in_line()
            buffer_cnt = buffer.get_line_count()
            if (buffer_cnt - line_cnt) > 1:
                line_len -= 1
                echo = True
            end = buffer.get_iter_at_line_offset(line_cnt, line_len)
            line = buffer.get_text(start, end, True)
            self.append_text("\n")
            if line.startswith(self.prompt):
                line = line[2:]
            else:
                self.append_text("%s " % self.prompt)
                end = buffer.get_end_iter()
                buffer.place_cursor(end)
                return True
            if echo:
                self.append_text(("%s " % self.prompt) + line)
                end = buffer.get_end_iter()
                buffer.place_cursor(end)
                return True
            _retval = self.process_command(line)
            if _retval is not None:
                self.append_text("%s\n" % str(_retval))
            self.append_text("%s " % self.prompt)
            end = buffer.get_end_iter()
            buffer.place_cursor(end)
            return True
        return False 
开发者ID:gramps-project,项目名称:addons-source,代码行数:58,代码来源:QueryGramplet.py


注:本文中的gi.repository.Gdk.keyval_from_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。