#button_example.py
from tkinter import *
from gpiozero import LED
led=LED(17)
rootWin = Tk()
frame = Frame(rootWin) #Create a frame to organize the buttons
frame.pack()
def quitFunc(): #The quitFunc just prints a message!
led.off()
def speakFunc(): #The speakFunc just prints a message!
led.on()
#Define button1, which has a foreground (fg) color of red, displays the
#text "Quit", and will call the quitFunc when it is clicked.
#It will be inside the frame created above.
button1 = Button(frame, text="off", fg="red", command=quitFunc)
button1.pack(side=LEFT)
#Create another button, displaying the text "Speak" and programmed to
#call the speakFunc when it is clicked.
button2 = Button(frame, text="on", command=speakFunc)
button2.pack(side=LEFT)
rootWin.mainloop() #Run the main loop.
پیام #button_example.py
31 دسامبر 2016در همان حوالی فید
این پیام
P