-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode
87 lines (67 loc) · 2.39 KB
/
Code
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
85
#!/usr/bin/python3
from tkinter import *
from time import *
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(3,GPIO.OUT)
GPIO.setwarnings(False)
root=Tk()
root.geometry("450x140+100+100")
root.title("Haupemenue")
led_status = "aus"
scale_vorhanden = "nein"
scale_wert = 0
bewaesserung = "True"
def hauptmenue(): #Hauptmenuebuttons erstellen und anordnen
btn_LED = Button(root, text="LED", command=led)
btn_LED.place(x=10, y=20, height=100, width=100)
btn_exit = Button(root, text="Beenden", command=root.destroy)
btn_exit.place(x=340, y=20, height=100, width=100)
def led(): #Button und neues Fenster erstellen
led=Toplevel()
led.title("Bewaesserung")
led.geometry("500x170+100+100")
lbl_led = Label(led, text="LED AN AUS")
btn_exit = Button(led, text="Hauptmenue", fg="red", command=led.destroy)
btn_exit.place(x=400, y=140, height=30, width=100)
btn_led = Button(led, text="LED Toggle",command=led_toggle)
btn_led.place(x=340, y=20, height=100, width=100)
scale()
def led_toggle():
global led_status
if led_status == "aus":
GPIO.output(3,True)
led_status = "an"
btn_led.config(bg = "green",text = "Bewaesserung\n laeuft")
else:
GPIO.output(3,False)
led_status = "aus"
btn_led.config(bg = "red", text = "Bewaesserung\n kann\n gestartet\n werden")
def scale(): #scale erstellen und wert auslesen
def scale_value():
wert = 0
global scale_wert
scale_wert = scale1.get()
led_automatisch()
global scale_vorhanden
if scale_vorhanden == "nein":
scale1 = Scale(led, from_=0, to=200, length = 200, orient=HORIZONTAL)
scale1.place(x=340, y=20)
scale_vorhanden = "ja"
Button(led, text="Setzen", command=scale_value).place(x=340, y=50)
def led_automatisch(): #Scale Wert aus globaler variable einlesen, mit wert vergleichen und hochzaehlen
global scale_wert
wert = 0
print(wert)
while wert <= scale_wert:
GPIO.output(3,True)
wert = wert +1
warten.after(1000,led_automatisch)
print(wert)
else:
GPIO.output(3,False)
def main(): #starte hauptmenue und loop
hauptmenue()
root.mainloop()
if __name__ == '__main__':
main()