your_pic.set(latest_photo) AttributeError: 'Picture' object has no attribute 'set'

249 views Asked by At

I can't work out how to give the 'Picture' object a attribute 'set' in this code so my code for your_pic.set(lastest_photo) is not working properly. The 3rd line from the bottom defines the Picture, so I'm not sure what I'm missing. Could someone please help.

from picamera import PiCamera
from gpiozero import Button
from time import gmtime, strftime
from overlay_functions import *
from guizero import App, PushButton, Text, Picture

def next_overlay():
    global overlay
    overlay = next(all_overlays)
    preview_overlay(camera, overlay)

def take_picture():
    global output
    output = strftime("/home/pi/allseeingpi/image-%d-%m %H:%M.png", gmtime())
    camera.capture(output)
    camera.stop_preview()
    remove_overlays(camera)
    output_overlay(output, overlay)

    size = 400, 400
    gif_img = Image.open(output)
    gif_img.thumbnail(size, Image.ANTIALIAS)
    gif_img.save(latest_photo, 'gif')

    your_pic.set(latest_photo)

def new_picture():
    camera.start_preview(alpha=128)
    preview_overlay(camera, overlay)

next_overlay_btn = Button(23)
next_overlay_btn.when_pressed = next_overlay
take_pic_btn = Button(25)
take_pic_btn.when_pressed = take_picture

camera = PiCamera()
camera.resolution = (800, 480)
camera.hflip = True

camera.start_preview()

output = ""
latest_photo = '/home/pi/allseeingpi/latest.gif'  

app = App("The All-Seeing Pi", 800, 480)
message = Text(app, "I spotted you!")
your_pic = Picture(app, latest_photo)
new_pic = PushButton(app, new_picture, text="New picture")
app.display()
0

There are 0 answers