组合键a+应该以我的母语波兰语mod1返回带有尾部的字母,而 gtk 返回 aogonek。ą
如何解决此键和其他键的此问题?
(...)
def on_key_release(self, widget, event, data=None):
keyval = event.keyval
keyname = Gdk.keyval_name(keyval)
ctrl = (event.state & Gdk.ModifierType.CONTROL_MASK)
shift = (event.state & Gdk.ModifierType.SHIFT_MASK)
mod1 = (event.state & Gdk.ModifierType.MOD1_MASK)
super = (event.state & Gdk.ModifierType.SUPER_MASK)
hyper = (event.state & Gdk.ModifierType.HYPER_MASK)
meta = (event.state & Gdk.ModifierType.META_MASK)
lock = (event.state & Gdk.ModifierType.LOCK_MASK)
if keyname in self.buffer:
self.buffer.remove(keyname)
if self.buffer:
self.textbuffer.insert_at_cursor('you released '+'+'.join(self.buffer)+'\n')
def on_key_down(self, widget, event, data=None):
keyval = event.keyval
keyname = Gdk.keyval_name(keyval)
ctrl = (event.state & Gdk.ModifierType.CONTROL_MASK)
shift = (event.state & Gdk.ModifierType.SHIFT_MASK)
mod1 = (event.state & Gdk.ModifierType.MOD1_MASK)
super = (event.state & Gdk.ModifierType.SUPER_MASK)
hyper = (event.state & Gdk.ModifierType.HYPER_MASK)
meta = (event.state & Gdk.ModifierType.META_MASK)
lock = (event.state & Gdk.ModifierType.LOCK_MASK)
if keyname in 'AĄz aogonek żółćgęśaą' and keyname and (shift or mod1 or ctrl or super or hyper or meta or lock) not in self.buffer:
self.buffer.append(keyname)
if self.buffer:
self.textbuffer.insert_at_cursor('you pressed '+'+'.join(self.buffer)+'\n')
(...)
九州编程
烙印99
相关分类