Git Product home page Git Product logo

kangvcar / wendy Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 4.0 17.87 MB

Wendy是一个Python GUI框架,它允许用HTML、CSS、Javascript、Ajax建立一个应用程序的GUI。 它使用CEF嵌入WxPython窗体,通过Flask启动本地服务器来响应GUI请求。 项目GUI默认使用了流行的AdminLTE模板,您可以随意替换任意模板,替换规则请参考Flask。 您可以随时下载本项目并修改成为你的应用程序。 本项目还提供了打包程序脚本使得程序更方便分发。

License: MIT License

Python 0.15% JavaScript 66.93% CSS 19.15% HTML 13.75% Ruby 0.01% NSIS 0.02%
python gui cefpython3 wxpython flask bootstrap4 adminlte3 javascript

wendy's Introduction

Wendy

Wendy is a Python GUI framework that allows to build an application GUI with HTML, CSS, Javascript, Ajax.
It uses CEF (Chrome Embedded Framework) to embed WxPython forms , through Flask to start a local server to respond to GUI requests .
The project GUI uses the popular AdminLTE template (Free admin dashboard template based on Bootstrap 4) by default, you can replace any template you want, please refer to Flask for replacement rules.
You can always download this project and modify it into your application.
The project also provides a packager script to make the application easier to distribute.

Wendy是一个Python GUI框架,它允许用HTML、CSS、Javascript、Ajax建立一个应用程序的GUI。
它使用CEF嵌入WxPython窗体,通过Flask启动本地服务器来响应GUI请求。
项目GUI默认使用了流行的AdminLTE模板,您可以随意替换任意模板,替换规则请参考Flask。
您可以随时下载本项目并修改成为你的应用程序。
本项目还提供了打包程序脚本使得程序更方便分发。

Components

wxPython - 构建窗体
CEF Python - Chrome Embedded Framework
Flask - 本地 web Server
Gevent - 启动 Flask 服务
AdminLTE - Bootstrap Web UI
xmlhttprequest - Communication with Flask to update UI
eel - A little Python library

How to Use

Get Started

Clone

Clone this repo

git clone https://github.com/kangvcar/Wendy.git

Setup Environment

  • Python==3.7
  • Flask==2.0.1
  • cefpython3==66.1
  • PyInstaller==3.6
  • wxPython==4.1.1
  • gevent==21.1.2
pip install pipenv
cd Wendy
pipenv install
pipenv shell
# 启动
python -m wendy

Test Application

cd into the repo folder.
Start the application to make sure everything is working python -m wendy
The application comes with a sample GUI with some interactions with the backend.
The included HTML and Javascript functions are a sample of how actions can be performed.

Structure

__main__.py

Starts the application. It is a cefpython (portable chrome browser) application, and the windowing system.
It calls a function called find_port() which finds an open port on the local machine.
It then calls the function start_server() which starts the Flask web server.

start_gevent.py

This file is used to run gevent which handles running Flask and the incoming connections from your web gui.
start_gevent is importing the Flask application from app.py

app.py

This is the Flask application. This is where routing for http calls will be, creating the HTML, and the backend of the application.
This is where main part of the application is handled.

__info__.py

Fields that contain your application name and related information.

__init__.py

Configures paths for the application.
Contains functions for getting and creating paths for your application.

Templates directory

Contains the HTML files for the application

Static directory

Contains the resources for the HTML files. Fonts, images, javascript libraries etc.

Rebrand Project

Windowing and Icons

The top of __main__.py sets the size of the application.
icon.ico is the icon used by the window.

When creating an icon, you can bundle multiple sizes together to ensure it appears nicely at different sizes.
You can download icobundle to combine the icons into one file.
You can use this command. It also shows the different sizes you should create (eg icon24.ico is the 24x24 pixels size)
.\icobundl.exe -o icon.ico icon16.ico icon24.ico icon32.ico icon40.ico icon48.ico icon64.ico icon96.ico icon128.ico icon256.ico

Name, version etc

Modify __info__.py

Modifying the Application

After rebranding the project, development on the new application can begin.

Main Program Logic

app.py is the Flask application that controls the main logic of the application.
Sample AJAX functions are included in the HTML to communicate with the backend Flask application.

GUI

Bootstrap is used for the HTML. This is not required, any HTML can be used.
Modifying the files in the templates and static directories will allow you change the GUI.
You call run python app.py and go to localhost:5000 in your browser to work on your application without having to execute __main__.py.
templates/index.html contains Javascript calls to the backend to retrieve data.

Create Windows Executable and Installer

PyInstaller and exe

An exe for the application is created with PyInstaller.
build/build.spec is the PyInstaller spec which configures PyInstaller.
Extra files and directories to include (eg icon.ico) are set in the spec file.
To prevent the console window from appearing set EXE(console=False).

NSIS installer

Install NSIS http://nsis.sourceforge.net/Download

The installer is created with nsis.
build/installer.nsi is the template that will be automatically modified when creating a new build.
Modify build/icon.ico and build/header.bmp for your application.
Modify build/license.txt to be the contents of your application's license.
Modify the fields at the top of build/build.py

Create new build

$ cd build/
$ python build.py

This will run pyinstaller to create the exe, copy it into build/dist/, and then create the installer with nsis.
A file containing multiple hashes of the installer is also created.

Notes

  • requirements.txt minimum versions show what was tested with

References

CEFPython - Python bindings for the Chromium Embedded Framework
Flask - Python microframework
AdminLTE - Web Front-End Framework
PyInstaller - Turn Python projects into executables
NSIS - Creates installer
Neuron - Python project for creating desktop applications

Screenshot

Wendy Screenshot

License

The license for this project is the MIT License

wendy's People

Contributors

kangvcar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.