键盘快捷键不要写入条目Python Gtk 3

时间:2015-11-03 21:41:40

标签: python-2.7 keyboard-shortcuts pygtk gtk3

在一个窗口中,我使用了键盘快捷键,但快捷键阻止了我的窗口条目,并且不允许我在其上书写。我有这样的事情:

self.connect("key-press-event",self._key_press_event, b_finalizar, b_agregar, c_scales, b_buscar, storeCompra,entryCliente, l_total, entry, spinCantidad, spinPrecio, storeAutocomp, tree, l_unidad)

我所拥有的事件方法就是:

def _key_press_event(self,widget,event, b_finalizar, b_agregar, c_scales, b_buscar,storeCompra,entryCliente, l_total, entry, spinCantidad, spinPrecio, storeAutocomp, tree, l_unidad):
    keyval = event.keyval
    keyval_name = Gdk.keyval_name(keyval)
    state = event.state
    ctrl = (state & Gdk.ModifierType.CONTROL_MASK)
    if ctrl and keyval_name == 'a':
        self.agregar_clicked(b_agregar, storeCompra, entry, spinCantidad, spinPrecio, storeAutocomp, tree, l_unidad, l_total)
        print "AGREGAR ITEM"
    elif ctrl and keyval_name == 'b':
        print "básculas"
    elif ctrl and keyval_name == 'f':
        self.finalizar_clicked(b_finalizar, storeCompra, entryCliente, l_total)
        print "finalizar"
    elif ctrl and keyval_name == 'c':
        self.buscar_clicked(b_buscar, entry)
        print "catalogo"
        return False
    return True

我需要能够在条目中写入并使用快捷方式,任何想法都可能有所帮助。感谢

1 个答案:

答案 0 :(得分:0)

在你的上一个州:

   elif ctrl and keyval_name == 'c':
    self.buscar_clicked(b_buscar, entry)
    print "catalogo"
   else:
    return False

return True