rtcwake_gui/StatusUi.py

51 lines
1.5 KiB
Python
Raw Permalink Normal View History

2016-10-19 00:12:14 +02:00
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class StatusDevice():
device = ""
def __init__(self, page, device):
self.device = device
self.vBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
self.vBox.set_border_width(10)
self.line1 = line("Device:", self.device.name)
self.line2 = line("Status:", "Off")
self.line3 = line("Wake up time:", "Now")
page.pack_start(self.line1.box, True, True, 0)
page.pack_start(self.line2.box, True, True, 0)
page.pack_start(self.line3.box, True, True, 0)
self.update()
page.pack_start(self.vBox, True, True, 0)
def update(self):
self.line1.value.set_text(self.device.name)
active = "Off"
if self.device.devStatus["active"]:
active = "On"
self.line2.value.set_text(active)
if self.device.devStatus["active"]:
if not self.line3.box.get_visible():
self.line3.box.show()
self.line3.value.set_text(str(self.device.devStatus["date"]))
elif self.line3.box.get_visible():
self.line3.box.hide()
class line():
def __init__(self, name, value):
self.box = Gtk.Box(spacing=10)
self.label = Gtk.Label(name, halign=Gtk.Align.START)
2016-10-22 22:13:50 +02:00
self.value = Gtk.Label(value, halign=Gtk.Align.END, selectable=True)
2016-10-19 00:12:14 +02:00
self.box.pack_start(self.label, True, True, 0)
self.box.pack_start(self.value, True, True, 0)