-
Notifications
You must be signed in to change notification settings - Fork 0
/
Led.py
44 lines (37 loc) · 1.37 KB
/
Led.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
import time
from tkinter import *
from PIL import Image, ImageTk
from Configuration import config
class Led:
imageOn = Image.open(config.get('APPLICATION', 'LED_ON_IMG'))
imageOff = Image.open(config.get('APPLICATION', 'LED_OFF_IMG'))
STATE_ON = "ON"
STATE_OFF = "OFF"
def __init__(self, parent):
self.state = Led.STATE_OFF
self.img = ImageTk.PhotoImage(Led.imageOff)
self.label = Label(parent, image=self.img, bg="black")
self.label.image = self.img
self.label.pack()
def swithOn(self):
self.img = ImageTk.PhotoImage(Led.imageOn)
self.label.configure(image=self.img)
self.state = Led.STATE_ON
def swithOff(self):
self.img = ImageTk.PhotoImage(Led.imageOff)
self.label.configure(image=self.img)
self.state = Led.STATE_OFF
# deprecated: use swithOn/swithOff methods instead
'''
def changeColor(self):
if ( self.state == Led.STATE_OFF):
self.img = ImageTk.PhotoImage(Led.imageOn)
self.label.configure(image=self.img)
self.state = Led.STATE_ON
elif ( self.state == Led.STATE_ON):
self.img = ImageTk.PhotoImage(Led.imageOff)
self.label.configure(image=self.img)
self.state = Led.STATE_OFF
else:
raise Exception('Unknow led state')
'''