Advertisement
metalx1000

Python - GTK - Basic Number Pad

Sep 8th, 2012
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import gtk
  4.  
  5. def press(widget):
  6.     num = entry.get_text()
  7.     pnum = widget.get_label()
  8.     entry.set_text(num + pnum)
  9.  
  10. def send_press(widget):
  11.     print "Dialing: " + entry.get_text()
  12.  
  13. win=gtk.Window()
  14. win.connect('destroy', lambda w: gtk.main_quit())
  15.  
  16. box = gtk.VBox()
  17. win.add(box)
  18.  
  19. entry=gtk.Entry()
  20. box.pack_start(entry)
  21.  
  22. table=gtk.Table(2, 2, gtk.TRUE)
  23.  
  24. a = [1,2,3,4,5,6,7,8,9,"#",0,"*"]
  25. x = 0
  26. y = 0
  27.  
  28. for i in a:
  29.     button=gtk.Button(str(i))
  30.     button.connect("clicked", press)
  31.     table.attach(button,x,x+1,y,y+1)
  32.     x+=1
  33.     if x > 2:
  34.         x = 0
  35.         y+=1
  36.  
  37.  
  38. box.pack_start(table)
  39.  
  40. send=gtk.Button("SEND")
  41. send.connect("clicked", send_press)
  42. box.pack_start(send)
  43.  
  44. win.show_all()
  45.  
  46. gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement