Advertisement
metalx1000

GTK Text input set focus

Apr 23rd, 2015
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import pygtk
  4. pygtk.require('2.0')
  5. import gtk
  6.  
  7. class HelloWorld:
  8.  
  9.     def hello(self, widget, data=None):
  10.         print "Hello World"
  11.  
  12.     def delete_event(self, widget, event, data=None):
  13.         print "delete event occurred"
  14.  
  15.         return False
  16.  
  17.     def destroy(self, widget, data=None):
  18.         print "destroy signal occurred"
  19.         gtk.main_quit()
  20.  
  21.     def __init__(self):
  22.         self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  23.         self.window.connect("delete_event", self.delete_event)
  24.         self.window.connect("destroy", self.destroy)
  25.         self.window.set_border_width(10)
  26.    
  27.         self.box = gtk.VBox(False, 0)
  28.         self.window.add(self.box)
  29.  
  30.         self.button = gtk.Button("Close Window")
  31.         self.button.connect("clicked", self.hello, None)
  32.         self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
  33.         self.box.pack_start(self.button)
  34.  
  35.    
  36.         self.entry1=gtk.Entry()
  37.         self.box.pack_start(self.entry1)
  38.  
  39.         self.entry2=gtk.Entry()
  40.         self.box.pack_start(self.entry2)
  41.  
  42.         self.entry3=gtk.Entry()
  43.         self.box.pack_start(self.entry3)
  44.  
  45.         self.entry4=gtk.Entry()
  46.         self.box.pack_start(self.entry4)
  47.  
  48.         self.window.show_all()
  49.  
  50.         self.entry2.grab_focus()
  51.     def main(self):
  52.         gtk.main()
  53.  
  54. if __name__ == "__main__":
  55.     hello = HelloWorld()
  56.     hello.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement