-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
84 lines (59 loc) · 2.42 KB
/
main.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
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk as gtk
from gauges import *
from buttons import *
from fetchers import *
from actions import SimpleScriptWithArgument
from tempwidget import TempWidget
def file_gauge(heading, filename, suffix):
return LabelWidget(heading, "", from_file(filename, suffix)).widget()
class Base:
def __init__(self):
self.create_window()
self.create_lightswitches()
temp = TempWidget("data/wanted_temp")
self.container.pack_start(temp.widget(), True, True, 5)
self.create_gauges()
self.container.show()
self.window.show()
def create_lightswitches(self):
switches = gtk.HBox(homogeneous=True, spacing=5)
action = SimpleScriptWithArgument("./regulator.sh", activate_args=["on"], deactivate_args=["off"])
button = SwitchWidget("Lys", action.action)
switches.pack_start(button.widget(), False, False, 5)
button = SwitchWidget("Nattmodus", None)
switches.pack_start(button.widget(), False, False, 5)
button = SwitchWidget("Radio", None)
switches.pack_start(button.widget(), False, False, 5)
switches.show()
self.container.pack_start(switches,
expand=True, fill=True, padding=0)
def create_gauges(self):
gauges = Gauges()
gauges.add(file_gauge("Ute", "data/temp_ute", "° C"))
gauges.add(file_gauge("Inne gulv", "data/temp_inne_gulv", "° C"))
gauges.add(file_gauge("Vann 1", "data/vann1", "%"))
gauges.add(file_gauge("Inne tak", "data/temp_inne_tak", "° C"))
gauges.add(LabelWidget("").widget())
gauges.add(file_gauge("Vann 2", "data/vann2", "%"))
self.container.pack_start(gauges.widget(),
expand=False, fill=True, padding=0)
def create_window(self):
self.window = gtk.Window()
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_default_size(600, 1024)
self.container = gtk.VBox(False, 0)
self.window.add(self.container)
def main(self):
gtk.main()
def delete_event(self, widet, event, data=None):
return False
def destroy(self, widget, data=None):
gtk.main_quit()
if __name__ == "__main__":
base = Base()
base.main()