SihabSahariar / PyQt-React-Boilerplate

A boilerplate for using python to build a desktop application using PyQt webengine and React.js as the application front-end.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyQt React Boilerplate

Project Structure

.
├── public                  # Public files for react
├── server                  # PyQt Web Server
│   ├── api
│   └── utils
├── src                     # React application source code
│   └── ...
└── main.py                 # Application entry point

Setting Up Development Environment

Environment variables

All environment variables are stored in .env. This is where we store sensitive information that we do not want to include in the source code, such as database login information.

  1. Create a copy of .env.example and rename it as .env.

  2. Fill in the missing information, such as database login username and password.

To access variables defined in .env, package python-dotenv is used.

from dotenv import load_dotenv

load_dotenv()

Access ENVIRONMENT variable for example

ENVIRONMENT = os.environ['ENVIRONMENT']

React GUI

  1. Install yarn https://classic.yarnpkg.com/en/docs/install/#windows-stable

  2. Install node dependencies

    yarn
  3. Run react app

    yarn start

PyQt Web Server

  1. Install virtualenv

    pip install virtualenv
  2. Create virtualenv

    python -m venv ./venv
  3. Activate virtualenv

    # win
    venv/Scripts/activate.bat
    
    # mac
    source venv/bin/activate
  4. Install python dependencies

    pip install -r requirements.txt
  5. Run Application

    python main.py

Packaging for distribution

Build react app

Static files will be built in the ./build directory

yarn build

Build PyQt app

(I am still figuring this out)

About

A boilerplate for using python to build a desktop application using PyQt webengine and React.js as the application front-end.


Languages

Language:Python 36.0%Language:HTML 30.8%Language:JavaScript 17.6%Language:CSS 14.0%Language:Shell 1.6%