0

I want to make multiple frames depends on each other when I click on a button. What is the suitable code for this? My code is below. In my GUI I want to control a fan speed from the Raspberry Pi, then I click on a button to appear another window

import tkinter
import RPi.GPIO as GPIO
import time


GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)
GPIO.output(14, GPIO.LOW)

q = GPIO.PWM(14,50)
num = 5

window = tkinter.Tk()

def fan_on():
    q.start(5)

def fan_off():
    q.ChangeDutyCycle(0)

def speed_up():
    global num
    num += 10
    q.ChangeDutyCycle(num)

def speed_down():
    global num
    num -= 10
    q.ChangeDutyCycle(num)

def quit():
    GPIO.cleanup()
    exit()


btn1 = tkinter.Button(window, text="Fan 0n" ,command=fan_on)
btn2 = tkinter.Button(window, text="Fan Off" ,command=fan_off)
btn3 = tkinter.Button(window, text="SPEED UP ⬆" ,command=speed_up)
btn4 = tkinter.Button(window, text="SPEED DOWN ⬇" ,command=speed_down)
#lbl = tkinter.Label(window, text="temp.°C")

btn5 = tkinter.Button(window, text="Quit" ,command=quit)

btn1.place(x=0 , y=20)
btn2.place(x=328, y=20)
btn3.pack()
btn4.pack()
btn5.place(y=300)
#lbl.place(x=180, y=180)

window.geometry("400x400")
window.mainloop()
nbro
  • 15,395
  • 32
  • 113
  • 196
  • I don't see any frames at all. What do you mean by "multiple frames"? What's preventing you from creating multiple frames? – Bryan Oakley Mar 21 '17 at 02:14
  • Maybe this question can help: http://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter/7557028#7557028 – j_4321 Mar 21 '17 at 08:14

0 Answers0