-
Notifications
You must be signed in to change notification settings - Fork 0
/
temperature.py
30 lines (19 loc) · 926 Bytes
/
temperature.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
import Adafruit_DHT
import time
import tkinter as tk
from guisettings import *
sensor=Adafruit_DHT.DHT11
gpio=27
class TemperatureWidget(tk.Frame):
def __init__(self, root, *args, **kwargs):
tk.Frame.__init__(self, root, *args, **kwargs)
self.root = root
self.temperatureLabel = tk.Label(self, text="Innen: " + str(self.getCurrent()) + "°", font = ('arial', LABEL_FONT_SIZE, 'bold'), background = "#" + BACKGROUND)
self.temperatureLabel.grid()
self.updateTemperature()
def updateTemperature(self):
self.temperatureLabel.configure(text = "Innen: " + str(self.getCurrent()) + "°", font = ('arial', LABEL_FONT_SIZE, 'bold'), background = "#" + BACKGROUND)
self.after(30000, self.updateTemperature)
def getCurrent(self):
humidity, temperature = Adafruit_DHT.read_retry(sensor, gpio)
return temperature