-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcherui.py
73 lines (50 loc) · 1.82 KB
/
launcherui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk #, Gdk
from gi.repository.GdkPixbuf import Pixbuf
from os import system
import launcher
class LauncherWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Launch")
self.set_default_size(600, 500)
scrolled = Gtk.ScrolledWindow()
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
flowbox = Gtk.FlowBox()
flowbox.set_valign(Gtk.Align.START)
flowbox.set_max_children_per_line(30)
flowbox.set_selection_mode(Gtk.SelectionMode.NONE)
self.create_flowbox(flowbox)
scrolled.add(flowbox)
#self.add(vbox)
self.add(scrolled)
self.show_all()
def addBtn(self, name, icon, executable):
row = Gtk.ListBoxRow()
btnIcon = Gtk.IconView.new()
liststore = Gtk.ListStore(Pixbuf, str)
iconview = Gtk.IconView.new()
iconview.set_model(liststore)
iconview.set_pixbuf_column(0)
iconview.set_text_column(1)
pixbuf = Gtk.IconTheme.get_default().load_icon(icon, 48, 0)
liststore.append([pixbuf, name])
btn = Gtk.Button()
btn.connect("clicked", self.btnclicked, executable)
btn.add(iconview)
return btn
def btnclicked(self,button,executable):
print ("Running:", executable)
system(executable)
def create_flowbox (self, flowbox):
for app in launcher.development:
button = self.addBtn(app.name,app.icon,app.executable)
flowbox.add(button)
for app in launcher.network:
button = self.addBtn(app.name,app.icon,app.executable)
flowbox.add(button)
win = LauncherWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()