fork(26) download
  1. from gi.repository import Gtk as gtk
  2. from gi.repository import Gdk as gdk
  3. import json
  4.  
  5.  
  6. class FlowBoxWindow:
  7.  
  8. def __init__(self):
  9.  
  10. self.window = gtk.Window()
  11. self.screen = gdk.Screen.get_default()
  12. self.icon_theme = gtk.IconTheme.get_default()
  13. self.window.set_size_request(self.screen.get_width(),
  14. self.screen.get_height())
  15. self.window.set_name("flow_box")
  16. self.window.move(0, 0)
  17. self.window.set_keep_above(False)
  18. self.window.set_resizable(False)
  19. self.window.set_decorated(False)
  20. self.window.set_border_width(0)
  21. self.window.connect("destroy", gtk.main_quit)
  22.  
  23. hbox_container = gtk.HBox()
  24.  
  25. scrolled_window_categories = gtk.ScrolledWindow()
  26. scrolled_window_categories.set_policy(gtk.PolicyType.AUTOMATIC,
  27. gtk.PolicyType.NEVER)
  28.  
  29. viewportv_categories = gtk.Viewport()
  30. viewportv_categories.add(hbox_container)
  31. scrolled_window_categories.add(viewportv_categories)
  32. self.window.add(scrolled_window_categories)
  33.  
  34. self.notebook_categories = gtk.Notebook()
  35. hbox_container.add(self.notebook_categories)
  36.  
  37. self.create_app_menu()
  38. self.window.show_all()
  39.  
  40. def create_app_menu(self):
  41.  
  42. for category in json.load(open('settings.json')):
  43.  
  44. # create container for app buttons
  45. box_categories = gtk.Box()
  46. box_categories.set_name("scrolledwindow")
  47. box_categories.set_size_request(self.screen.get_width(),
  48. self.screen.get_height() - 101)
  49. pixbuffer = self.icon_theme.load_icon(category['icon-name'],
  50. int(category['icon-size']),
  51. 0)
  52. image = gtk.Image()
  53. image.set_from_pixbuf(pixbuffer)
  54.  
  55. # flowbox area
  56. app_window = gtk.ScrolledWindow()
  57. app_window.set_policy(gtk.PolicyType.NEVER,
  58. gtk.PolicyType.AUTOMATIC)
  59.  
  60. apps_container = gtk.FlowBox()
  61. apps_container.set_valign(gtk.Align.START)
  62. apps_container.set_max_children_per_line(30)
  63. apps_container.set_selection_mode(gtk.SelectionMode.NONE)
  64.  
  65. for app in category['apps']:
  66. app_label = gtk.Label(app['name'])
  67. app_button = gtk.Button()
  68. app_button.add(app_label)
  69. apps_container.add(app_button)
  70.  
  71. app_window.add(apps_container)
  72. box_categories.add(app_window)
  73.  
  74. self.notebook_categories.append_page(box_categories, image)
  75.  
  76. if __name__ == '__main__':
  77. app = FlowBoxWindow()
  78. gtk.main()
  79.  
Runtime error #stdin #stdout #stderr 0.02s 9936KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'gi'