Hi,
I already post about this but i am totally lost i have no clue how to make it work. I am unable to make my button work in tkinter. So i have to make it work in pygame or pyside so my button may work.
this is a new approach but i cant chose between the 2 albums. The album will switch only if i click button first before starting the script.
Thank you
I already post about this but i am totally lost i have no clue how to make it work. I am unable to make my button work in tkinter. So i have to make it work in pygame or pyside so my button may work.
this is a new approach but i cant chose between the 2 albums. The album will switch only if i click button first before starting the script.
from PySide.QtCore import *
from PySide.QtGui import *
import RPi.GPIO as GPIO
from time import sleep
import datetime
import time
import yaml
fichier = open("output.yaml", "r")
fichier1 = open("output1.yaml", "r")
document = yaml.load(fichier, Loader=yaml.Loader)
documents = yaml.load(fichier1, Loader=yaml.Loader)
print(documents["heure"])
print(document["heure"])
GPIO.setmode(GPIO.BOARD)
button1=16
button2=12
GPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(button2,GPIO.IN,pull_up_down=GPIO.PUD_UP)
dateSTR = datetime.datetime.now().strftime("%H:%M:%S" )
class Slides(QWidget):
def __init__(self, image_files, parent=None):
QWidget.__init__(self, parent)
self.image_files = image_files
print(datetime.datetime.now())
if dateSTR > ("08:30:00") and dateSTR < (document["heure"]): <--------how can we pass the hour from a file to stop the program?
s = '<>'*300
self.label = QLabel(s, self)
self.label.setGeometry(10, 30, 1200, 800)
self.button = QPushButton("D�but du diaporama",self)
self.button.setGeometry(10, 10, 160, 30)
self.button.clicked.connect(self.timerEvent)
self.timer = QBasicTimer()
self.step = 0
if GPIO.input(button2)==0: <--------------i would like to freeze image when i click the button instead of freezing the whole script
self.delay = 20000 # milliseconds
if GPIO.input(button2)==1:
self.delay = 2000
sf = "Slides are shown {} seconds apart"
self.setWindowTitle(sf.format(self.delay/1000.0))
def timerEvent(self, e=None):
if self.step >= len(self.image_files):
self.timer.stop()
self.button.setText('Fin du diaporama')
return
self.timer.start(self.delay, self)
file = self.image_files[self.step]
image = QPixmap(file)
self.label.setPixmap(image)
self.setWindowTitle("{} --> {}".format(str(self.step), file))
self.step += 1
# pick image files you have in the working folder
# or give full path name
if GPIO.input(button1)==1:
#if func1==False:
#func1=True
#sleep(.1)
image_files = [
'/home/pi/Desktop/jpg2png/athenaR.png',
'/home/pi/Desktop/jpg2png/EosR.png',
'/home/pi/Desktop/jpg2png/k.png',
'/home/pi/Desktop/jpg2png1/athena1.png',
'/home/pi/Desktop/jpg2png1/meteor.png',
'/home/pi/Desktop/jpg2png/falconR.png',
'/home/pi/Desktop/jpg2png/seacloudR.png',
'/home/pi/Desktop/jpg2png/SeagleR.png'
]
if GPIO.input(button1)==0:
#if func2==False:
# func2=True
image_files1 = [
'/home/pi/Desktop/jpg2png2/Ar.png',
'/home/pi/Desktop/jpg2png2/AntibeR.png',
'/home/pi/Desktop/jpg2png2/dubai.png',
'/home/pi/Desktop/jpg2png2/KHALILAHR.png',
'/home/pi/Desktop/jpg2png2/luxuy-yachtR.png',
'/home/pi/Desktop/jpg2png2/turquoiseR.png',
]
app = QApplication([])
if GPIO.input(button1)==1:
w = Slides(image_files)
if GPIO.input(button1)==0:
w = Slides(image_files1)
# setGeometry(x, y, w, h) x,y = upper left corner coordinates
w.setGeometry(100, 100, 1200, 800)
w.show()
app.exec_()I have no clue how to solve the problem.Thank you
