Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- if 3 == sys.version_info[0]: ## 3.X is default if dual system
- import tkinter as tk ## Python 3.x
- else:
- import Tkinter as tk ## Python 2.x
- win=tk.Tk()
- win.title("Q")
- def toggle():
- if b1.config('text')[-1] == 'AMBIENT':
- b1.config(text='OFF')
- GPIO.setup(24, GPIO.OUT)
- GPIO.output(24, GPIO.LOW)
- else:
- b1.config(text='AMBIENT')
- GPIO.output(24, GPIO.HIGH)
- if b2.config('text')[-1] == 'CEILING':
- b2.config(text='OFF')
- GPIO.setup(18, GPIO.OUT)
- GPIO.output(18, GPIO.LOW)
- else:
- b2.config(text='CEILING')
- GPIO.output(18, GPIO.HIGH)
- b1 = tk.Button(win, text="AMBIENT", command=toggle)
- b2 = tk.Button(win, text="CEILING", command=toggle)
- ## 3 & 4 not used in this example
- ##b3 = Button(win, text="LASER", command=toggle)
- ##b4 = Button(win, text="RADIO", command=toggle)
- b1.pack(pady=2)
- b2.pack(pady=2)
- ##b3.pack(pady=2)
- ##b4.pack(pady=2)
- win.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement