desktop.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/python
  2. from gi.repository import Gtk
  3. class GridWindow (Gtk.Window):
  4. def __init__(self):
  5. Gtk.Window.__init__(self, title="Grid Example")
  6. path = "/home/joshua/.config/awesome/icons/Faenza/apps/96/"
  7. #create the gtk images and set the images they display
  8. image1 = Gtk.Image()
  9. image2 = Gtk.Image()
  10. image3 = Gtk.Image()
  11. image4 = Gtk.Image()
  12. image5 = Gtk.Image()
  13. image6 = Gtk.Image()
  14. image7 = Gtk.Image()
  15. image8 = Gtk.Image()
  16. image1.set_from_file(path + "libreoffice-writer.png")
  17. image2.set_from_file(path + "libreoffice-writer.png")
  18. image3.set_from_file(path + "libreoffice-writer.png")
  19. image4.set_from_file(path + "libreoffice-writer.png")
  20. image5.set_from_file(path + "libreoffice-writer.png")
  21. image6.set_from_file(path + "libreoffice-writer.png")
  22. image7.set_from_file(path + "libreoffice-writer.png")
  23. image8.set_from_file(path + "libreoffice-writer.png")
  24. #add the images to a button widget
  25. button1 = Gtk.Button(use_underline=False)
  26. button2 = Gtk.Button(use_underline=False)
  27. button3 = Gtk.Button(use_underline=False)
  28. button4 = Gtk.Button(use_underline=False)
  29. button5 = Gtk.Button(use_underline=False)
  30. button6 = Gtk.Button(use_underline=False)
  31. button7 = Gtk.Button(use_underline=False)
  32. button8 = Gtk.Button(use_underline=False)
  33. button1.add(image1)
  34. button2.add(image2)
  35. button3.add(image3)
  36. button4.add(image4)
  37. button5.add(image5)
  38. button6.add(image6)
  39. button7.add(image7)
  40. button8.add(image8)
  41. #connect the various signals
  42. # button1.connect("clicked", self.clicked1)
  43. #create the labels
  44. label1 = Gtk.Label ("label1")
  45. label2 = Gtk.Label ("label2")
  46. label3 = Gtk.Label ("label3")
  47. label4 = Gtk.Label ("label4")
  48. #add the buttons to the grid
  49. grid.add(button1)
  50. grid.attach(button2, 1, 0, 1, 1)
  51. grid.attach(button5, 2, 0, 1, 1)
  52. grid.attach(button6, 3, 0, 1, 1)
  53. grid.attach(button7, 4, 0, 1, 1)
  54. grid.attach(button8, 5, 0, 1, 1)
  55. grid.attach(label1, 0, 1, 1, 1)
  56. grid.attach(label2, 1, 1, 1, 1)
  57. grid.attach(button3, 0, 2, 1, 1)
  58. grid.attach(button4, 1, 2, 1, 1)
  59. grid.attach(label3, 0, 3, 1, 1)
  60. grid.attach(label4, 1, 3, 1, 1)
  61. #define what happens when you click a button
  62. # def clicked1 (self, button):
  63. # print ("hello")
  64. win = GridWindow()
  65. win.connect("delete-event", Gtk.main_quit)
  66. win.show_all()
  67. Gtk.main()