contra

simple gtk/python test

Aug 3rd, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. # testing out gtk with python simple dial pad
  5.  
  6. import gtk
  7.  
  8. myWindow = gtk.Window()  #create the window
  9. myWindow.connect('destroy', lambda w: gtk.main_quit()) #make pid end after closing gui
  10.  
  11. guiBox = gtk.VBox() #the box
  12. myWindow.add(guiBox) #add box to the window
  13.  
  14. entry = gtk.Entry() #text field
  15. guiBox.pack_start(entry) #add textfield to the box
  16.  
  17. table = gtk.Table(2,2, gtk.TRUE) #create table 3x3
  18.  
  19. padArray = [1,2,3,4,5,6,7,8,9,"#",0,"*"] #initialize pad numbers
  20. x = 0
  21. y = 0
  22.  
  23. for i in padArray:      #lets place the buttons
  24.     button = gtk.Button(str(i))
  25.  
  26.     table.attach(button,x,x+1,y,y+1)
  27.  
  28.     x+=1
  29.     if x > 2:
  30.         x = 0
  31.         y+=1
  32.  
  33. guiBox.pack_start(table) #add table to the box
  34.  
  35. myWindow.show_all() #show box and all inside
  36.  
  37. gtk.main() #main lewp
Advertisement
Add Comment
Please, Sign In to add comment