Exemplo n.º 1
0
def test_bool_arg_binding():
    """
    Ensure that a keybinding signal with a boolean argument is
    emitted.
    """

    class Test(gtk.Button):
        __gsignals__ = {"sig": (gobject.SIGNAL_ACTION | gobject.SIGNAL_RUN_LAST, None, (bool,))}

        def __init__(self):
            super(gtk.Button, self).__init__()

        def do_sig(self, val):
            self.val = val

    test = Test()
    gtk.binding_entry_add_signal(Test, gtk.keysyms.r, 0, "sig", bool, True)
    gtk.bindings_activate(test, gtk.keysyms.r, 0)
    assert test.val
    gtk.binding_entry_add_signal(Test, gtk.keysyms.k, 0, "sig", bool, False)
    gtk.bindings_activate(test, gtk.keysyms.k, 0)
    assert not test.val
Exemplo n.º 2
0
def on_button_press(widget, event):
    height=widget.allocation.height
    if event.y < height/5:
        gtk.bindings_activate(widget, BACKSPACE, 0)
    elif event.y > height*4/5:
        gtk.bindings_activate(widget, SPACE, 0)