-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.py
More file actions
executable file
·53 lines (40 loc) · 1.67 KB
/
App.py
File metadata and controls
executable file
·53 lines (40 loc) · 1.67 KB
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class ourwindow(Gtk.Window):
def __init__(self):
self.temp = 72
Gtk.Window.__init__(self, title="Thermostat")
hbox = Gtk.Box(spacing= 10)
hbox.set_homogeneous(False)
vbox_left = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
vbox_left.set_homogeneous(False)
vbox_right = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
vbox_right.set_homogeneous(False)
hbox.pack_start(vbox_left, True, True, 0)
hbox.pack_start(vbox_right, True, True, 0)
Gtk.Window.set_default_size(self, 400,325)
Gtk.Window.set_position(self, Gtk.WindowPosition.CENTER)
self.label = Gtk.Label(label=self.temp)
self.label.set_justify(Gtk.Justification.CENTER)
vbox_left.pack_start(self.label, True, True, 0)
#vbox_left.pack_start(label, True, True, 0)
buttonDecrease = Gtk.Button()
buttonDecrease.connect("clicked", self.whenButtonDecrease_clicked)
buttonIncrease = Gtk.Button()
buttonIncrease.connect("clicked", self.whenButtonIncreased_clicked)
vbox_left.pack_start(buttonDecrease, True, True, 0)
vbox_right.pack_start(buttonIncrease, True, True, 0)
self.add(hbox)
def whenButtonDecrease_clicked(self, button):
self.temp= self.temp-1
self.label.set_text(str(self.temp))
def whenButtonIncreased_clicked(self, button):
self.temp+=1
self.label.set_text(str(self.temp))
window = ourwindow()
window.connect("delete-event", Gtk.main_quit)
window.show_all()
Gtk.main()