Make Cross Platform Desktop Apps with Flask
h
CoolCoderSJ

CREATE YOUR FIRST CROSS PLATFORM DESKTOP APP IN UNDER 15 MINUTES [PYTHON OR HTML]

How pog

In today's times, most websites have a standalone application. There are many ways to create desktop apps, C++, Electron, etc.
However, this tutorial is for all of you python lovers.

Prior Knowledge Required -

  • Flask

This tutorial uses Flask. If you don't know flask, don't worry! This tutorial can easily be understood to handle HTML files too!

Packages required -

Make sure you download these PyPi shudder packages before hand -

  • PyQTWebEngine - pip3 install PyQTWebEngine
  • Flask - pip3 install flask
  • pyinstaller - pip3 install pyinstaller

Let's Begin!

This is best done locally, as pyinstaller automatically detects OS. If you run on replit, it will build for Ubuntu.

Use this python code in your main.py -

Run it!

Now when you run this, a window with your flask content comes!

Bundle with PyInstaller

Again, recommended to do this locally.


Open up your Command Prompt, Terminal, etc. And cd into your apps directory.


EXAMPLE -

App Directory - C:\a_user\myapp

Powershell, cmd, etc. Command to use -

Note: If your path has spaces, put it in quotes


Once you cd into your directory, run this command -

BUT WAIT

Use these flags to enhance your app - (Put them between APP NAME and main.py)

FlagWhat it does
-cConsole Project only
-wWindow Project only
--add-data 'from;to-where'If your project has other files such as a static folder (Images, js, and cs), templates folder for html files, or other files.

ADD DATA EXAPMLE

Note, use ; for windows and : for Unix (mac, linux)

also note: . means root

WINDOWS

LINUX AND MAC

Run it!

(WINDOWS INSTRUCTIONS)

Now, you should see a folder called dist. Open it- there should be one folder, named YOUR APP NAME. Open that. Finally launch the exe, and voila! You can use this to generate an installer for your app.

You are viewing a single comment. View All
alanchen12

ok but can you atttach a repl lol

CoolCoderSJ

@alanchen12 why...?

also if u like it pls upvote...

OldWizard209

Dont cycle squeez.. @CoolCoderSJ

CoolCoderSJ

@OldWizard209 ok...

just tryna break the cookie stereotype