May-30-2022, 02:19 PM
I am sorry i dont see the point of this exercize. Its not working anyway :
gpio.board not define
the button are working in timerEven. i just want to get rid of the button in the QPushButton window so it start automatically. I need to create different files like i said for class and methods. I am not gonna redo this again. I have tons of homeworks i already passing the course its got to be quick and simple. This college suck anyway to learn programming, we are not learning anything.
I tried with the other code you posted and the problem still the same:
I really dont know how to do this.
gpio.board not define
the button are working in timerEven. i just want to get rid of the button in the QPushButton window so it start automatically. I need to create different files like i said for class and methods. I am not gonna redo this again. I have tons of homeworks i already passing the course its got to be quick and simple. This college suck anyway to learn programming, we are not learning anything.
I tried with the other code you posted and the problem still the same:
I really dont know how to do this.
import tkinter as tk import itertools import datetime as DT import time import RPi.GPIO as GPIO from time import sleep import datetime import time import yaml #fichier yaml configuration de l'intervalle fichier = open("diaporama.yaml", "r") document = yaml.load(fichier, Loader=yaml.Loader) print(document["heureA"]) print(document["heureD"]) #fichier yaml configuration du choix d'images with open('voilier.yaml') as y: for ligne in y: print(ligne) with open('yatch.yaml') as yatch: for y in yatch: print(y) #connection Raspberry Pi GPIO.setmode(GPIO.BOARD) GPIO.setup(document["bouton1"],GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(document["bouton2"],GPIO.IN,pull_up_down=GPIO.PUD_UP) dateSTR = datetime.datetime.now().strftime("%H:%M:%S" ) images = ['/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/jpg2png1/tshenandoah.png', '/home/pi/Desktop/jpg2png1/Wolfhound.png', '/home/pi/Desktop/jpg2png1/Aunderway.png'] 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', ] class ImageViewer(tk.Tk): """A tkinter window that displays images like a slideshow""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Label to display the image self.image_label = tk.Label(self) self.image_label.pack() # Label to display the image file name self.name_label = tk.Label(self, width=30) #self.name_label.pack() self.image = None self.delay = 2000 self.running = False def start(self, image_files, loop=True, delay=None): """ Start slide show. Set loop to True to cycle through images forever. Set delay to seconds that image is shown. """ if loop: """Cycle forever""" #self.image_files = itertools.cycle(image_files) if GPIO.input(document["bouton1"])==1: self.image_files1 = itertools.cycle(images) if GPIO.input(document["bouton1"])==0: self.image_files1 = itertools.cycle(image_files1) else: """Show slides once""" #self.image_files = iter(image_files) self.image_files1 = iter(image_files1) if delay is not None: self.delay = delay * 1000 self.running = True self.update_image() def stop(self): """Stop slideshow""" self.running = False def update_image(self): """Show the next image""" if self.running: try: image_file = next(self.image_files1) self.name_label["text"] = image_file self.image = tk.PhotoImage(file=image_file) self.image_label["image"] = self.image self.after(self.delay, self.update_image) except StopIteration: self.running = False viewer = ImageViewer() viewer.start(images, loop=True, delay=1) viewer.mainloop()