Skip to content

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

Notifications You must be signed in to change notification settings

ivan0313/PyQt-React-Boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages