Skip to content

Jasperabez/PythonGUI-Flask

Repository files navigation

PythonGUI-Flask

Quick template/example of setting up a python GUI app using Flask, and flaskwebgui

Part of my exploration in creating GUI applications with python, to know more check out my blog

Setting up

Clone this repo and set up a virtual environment to install required modules

git clone https://github.com/Jasperabez/PythonGUI-Flask.git
cd PythonGUI-Flask
virtualenv .venv
pip install -r requirements.txt

Start the application by running run.py, which would look something like this: screenshot

Project Layout

RecordingUploaderGUI

Contains the flask code (templates, views, models). Tried to follow closely to the layout highlighted by the flask docs

RecordingUploaderLogic

separate the additional "backend" processing you need to do from the GUI, currently a dummy function is being utilized by the flask code. It also contains a FTP + API function for my usecase.

Feel free to change the name however you would like for your own projects.

Packaging (PyInstaller)

Optional step to freeze your app as a executable, primarily for distribution

In RecordingUploaderGUI\__init__.py this section of code (existing) ensures templates, static folder is directed properly when frozen

if getattr(sys, 'frozen', False):
    base_dir = os.path.join(sys._MEIPASS)
    app = Flask(__name__,
        static_folder=os.path.join(base_dir, 'static'),
        template_folder=os.path.join(base_dir, 'templates'))
else:
    app = Flask(__name__)

When freezing using pyintaller, use flag --add-data for any templates and static folder.

pyinstaller --add-data "RecordingUploaderGUI/templates:templates" run.py

Credits

License

MIT License

About

Quick template/example of setting up a python GUI app using Flask

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published