Posts: 18
Joined: Sat Sep 09, 2017 1:26 am
Location: New York, USA

Problems Making GUI

Sun Mar 25, 2018 5:50 pm


I am trying to make a python GUI, which controls my little StopMotion App. Here is the code:

Code: Select all

from picamera import PiCamera
from guizero import App, Text, Slider, TextBox, PushButton
from time import sleep
from gpiozero import Button
from os import system

def change_FPS(slider_value):
  FPS.value = slider_value

def check():

def start_stopmotion():
  frame = 1
  while True: 
        camera.capture("/home/pi/Desktop/StopMotion/" + str(folder_name) + "/frame%03d.jpg" % frame)
        frame += 1
    except KeyboardInterrupt:
        start = False

  system('avconv -r ' + str(FPS) + ' -i /Desktop/StopMotion/ ' + str(folder_name) + '/frame%03d.jpg -qscale 2 ' + output_name + '.h264')
app = App(title="StopMotion")
welcome_message = Text(app, text='''Welcome to Stop Motion!
Please enter he name of the folder you will be importing the images.
This folder should be located in /home/pi/Desktop/StopMotion.
After that please enter the name of the file which will be created.''')

button = Button(17)
camera = PiCamera()
text1 = Text(app, text='Enter folder name: ')
folder_name = TextBox(app, width=30)
text2 = Text(app, text='Enter file name:')
output_name = TextBox(app, width=30)
text3 = Text(app, text='Enter number of FPS on the slider:')
FPS = Slider(app, command=change_FPS, start=1, end=30)
text4 = Text(app, text='''You can take pictures by pressing the button.
After desired number of frames press ctrl + c. Good Luck!''')
pushbutton = PushButton(app, command=start_stopmotion, text='Start StopMotion!')
checkbuton = PushButton(app, command=check, text='Check values')
checktext1 = Text(app, text='NO INFO')
checktext2 = Text(app, text='NO INFO')
Every time I take a picture with my GPIO button, there is this error:

Code: Select all

stream = io.open(stream, 'wb' if output else 'rb', buffering)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/Desktop/StopMotion/[TextBox] object with text ""/frame001.jpg'
Is there anything I am doing wrong? Please help!

Thanks in advance!

User avatar
Posts: 1897
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Problems Making GUI

Sun Mar 25, 2018 6:13 pm

That's because folder_name is a TextBox and you tried getting the string representation of that.

Code: Select all

>>> print(str(folder_name))
[TextBox] object with text ""
I think what you meant to do was get the contents of what has been entered in the TextBox

Code: Select all

camera.capture("/home/pi/Desktop/StopMotion/" + folder_name.get() + "/frame%03d.jpg" % frame)
She who travels light — forgot something.

Posts: 18
Joined: Sat Sep 09, 2017 1:26 am
Location: New York, USA

Re: Problems Making GUI

Sun Mar 25, 2018 7:20 pm

Thank You.
Now my GUI and file saving work perfectly.

Return to “Python”

Who is online

Users browsing this forum: No registered users and 3 guests