Advertisement
Guest User

Untitled

a guest
Jun 28th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import pygtk
  4. pygtk.require('2.0')
  5. from gi.repository import Gdk, Gtk
  6.  
  7. import gobject
  8. import sys, os.path
  9.  
  10. class MyTextView(Gtk.TextView):
  11.     __gsignals__ = {
  12.         'custom-keypress': (gobject.SIGNAL_RUN_FIRST | gobject.SIGNAL_ACTION, gobject.TYPE_NONE, (gobject.TYPE_INT,))
  13.     }
  14.  
  15.     def __init__(self):
  16.         Gtk.TextView.__init__(self)
  17.         self.connect("custom-keypress", self._keyp)
  18.  
  19.     def _keyp(self, view, value):
  20.         print "keyp ", value
  21.  
  22. binding_set = Gtk.binding_set_find("GtkTextView")
  23. Gtk.binding_entry_add_signall(binding_set, Gdk.KEY_plus, Gdk.ModifierType.CONTROL_MASK, 'custom-keypress', [Gtk.BindingArg()])
  24.  
  25. if __name__ == "__main__":
  26.     win = Gtk.Window()
  27.     page = MyTextView()
  28.     win.set_default_size(800, 600)
  29.     win.add(page)
  30.     win.connect('destroy', Gtk.main_quit)
  31.     win.show_all()
  32.     Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement