• Benvenuti su RaspberryItaly!
Benvenuto ospite! Login Login con Facebook Registrati Login with Facebook


Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5

[-]
Tags
python con varibile problema sleep e tkinter

[Problema] Tkinter e Python con varibile sleep
#1
Ciao spero di non aver sbagliato sezione...

ho un problema con il mio progetto...

ho creato una serie di variabili in TKinter con dei textbox
battezzate come DoubleVar essendo decimali

però non riesco a esportarle dentro la funzione sleep()

Codice:
import sys
import wiringpi2 as wiringpi
from time import sleep
import RPi.GPIO as GPIO
import Tkinter as tkinter
from Tkinter import *
from Tkinter import IntVar
import tkMessageBox
import math
import Tix
from Tkconstants import *


GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(40,GPIO.OUT)
GPIO.setup(38,GPIO.OUT)
GPIO.setup(36,GPIO.OUT)

GPIO.output(38,GPIO.LOW)
GPIO.output(36,GPIO.LOW)
GPIO.output(40,GPIO.LOW)


root = Tk()
root.title("programma 1")
geom = "320x200"
root.geometry(geom)


Label(root,text="Set Valve open").place(x=10, y=10);
a = DoubleVar()
e = Entry(root,textvariable=e).place(x=150,y=10)
a = float (e.get)

Label(root, text="Set Valve Delay").place(x=10, y=50);
b = DoubleVar()
f = Entry(root, textvariable=f).place(x=150,y=50)
b = float(f.get)

Label(root, text="Set Shoot Time").place(x=10, y=90);
c = DoubleVar()
g = Entry(root, textvariable=g).place(x=150,y=90)
c = float(g.get)

def start():
   GPIO.output(36,GPIO.HIGH)
   sleep(a)
   GPIO.output(36,GPIO.LOW)
   sleep(b)
   GPIO.output(38,GPIO.HIGH)    
   sleep(a)
   GPIO.output(38,GPIO.LOW)    
   sleep(b)
   GPIO.output(40,GPIO.HIGH)    
   sleep(c)
   GPIO.output(40,GPIO.LOW)    
   sleep(b)
   GPIO.output(36,GPIO.LOW)
   GPIO.output(38,GPIO.LOW)
   GPIO.output(40,GPIO.LOW);
   
toggleButton = Button(root, text="Start", command=start).place(x=10, y=150)

quitButton = Button(root, text="Quit", command=exit).place(x=110, y=150)


root.mainloop()
piú fotografo che altro... www.christianpiccinini.it
Risposta
#2
risolto Cool

Codice:
import sys
import wiringpi2 as wiringpi
from time import sleep
import RPi.GPIO as GPIO
import Tkinter as tkinter
from Tkinter import *
from Tkinter import IntVar
import tkMessageBox
import math
import Tix
from Tkconstants import *


GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(40,GPIO.OUT)
GPIO.setup(38,GPIO.OUT)
GPIO.setup(36,GPIO.OUT)

GPIO.output(38,GPIO.LOW)
GPIO.output(36,GPIO.LOW)
GPIO.output(40,GPIO.LOW)


root = Tk()
root.title("programma 1")
geom = "320x200"
root.geometry(geom)

a = DoubleVar ()
b = DoubleVar ()
c = DoubleVar ()
x = DoubleVar ()
y = DoubleVar ()
z = DoubleVar ()

Label(root,text="Set Valve open").place(x=10, y=10);
e = Entry(root, textvariable=x).place(x=150,y=10)

Label(root, text="Set Valve Delay").place(x=10, y=50);
f = Entry(root, textvariable=y).place(x=150,y=50)

Label(root, text="Set Shoot Time").place(x=10, y=90);
g = Entry(root, textvariable=z).place(x=150,y=90)

def start():
    a = x.get()
    b = y.get()
    c = z.get()
    GPIO.output(36,GPIO.HIGH)
    sleep(a)
    GPIO.output(36,GPIO.LOW)
    sleep(b)
    GPIO.output(38,GPIO.HIGH)    
    sleep(a)
    GPIO.output(38,GPIO.LOW)    
    sleep(b)
    GPIO.output(40,GPIO.HIGH)    
    sleep(c)
    GPIO.output(40,GPIO.LOW)    
    sleep(b)
    GPIO.output(36,GPIO.LOW)
    GPIO.output(38,GPIO.LOW)
    GPIO.output(40,GPIO.LOW);
    
toggleButton = Button(root, text="Start", command=start).place(x=10, y=150)

quitButton = Button(root, text="Quit", command=exit).place(x=110, y=150)

root.mainloop()
piú fotografo che altro... www.christianpiccinini.it
Risposta
  


Vai al forum:


Navigazione: 2 Ospite(i)
Forum con nuovi Post
Forum senza nuovi post
Forum bloccato
Forum Redirect