Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import pygtk
- pygtk.require('2.0')
- from gi.repository import Gdk, Gtk
- import gobject
- import sys, os.path
- class MyTextView(Gtk.TextView):
- __gsignals__ = {
- 'custom-keypress': (gobject.SIGNAL_RUN_FIRST | gobject.SIGNAL_ACTION, gobject.TYPE_NONE, (gobject.TYPE_INT,))
- }
- def __init__(self):
- Gtk.TextView.__init__(self)
- self.connect("custom-keypress", self._keyp)
- def _keyp(self, view, value):
- print "keyp ", value
- binding_set = Gtk.binding_set_find("GtkTextView")
- Gtk.binding_entry_add_signall(binding_set, Gdk.KEY_plus, Gdk.ModifierType.CONTROL_MASK, 'custom-keypress', [Gtk.BindingArg()])
- if __name__ == "__main__":
- win = Gtk.Window()
- page = MyTextView()
- win.set_default_size(800, 600)
- win.add(page)
- win.connect('destroy', Gtk.main_quit)
- win.show_all()
- Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement