Giter Club home page Giter Club logo

pyqt5-comet's Introduction

PyQt5 开发框架

简介:

采用pyqtSlot+QMutex+QThread+pyqtSignal研发的多线程使用框架。 https://pypi.org/project/PyQt5-comet/

安装方法:

pip install -i https://test.pypi.org/simple/ PyQt5-comet --prefix="我的项目路径"
复制Lib\site-packages\PyLib和Lib\site-packages\main.py到项目根目录,即可开始使用。

需要支持模块:

pip install pyqt5 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple

安装教程:

首先执行安装PyQt5模块。

pip install pyqt5 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple

然后执行:

pip install -i https://test.pypi.org/simple/ PyQt5-comet --prefix="我的项目路径"
or
pip install PyQt5-comet --prefix="我的项目路径"

最后将Lib\site-packages\PyLib和Lib\site-packages\main.py复制到项目根目录。

使用教程

目录结构为:

-PyLib
    Controller.py
    MainUi.py
    Module-Test.py
    ProgramManagement.py
    MainUi.ui
main.py

模块介绍:

main.py 启动GUI
Controller.py 控制器
MainUi.py GUI界面
Module-Test.py 测试模块
ProgramManagement.py 多线程和模块加载器

开发教程

开发好需要完成的逻辑,固定class RunModule 方法update 返回值为字符串,保存为Module-Test.py文件。

import _thread
import os

class RunModule:
    def __init__(self, tmp_dict):
        self.log = tmp_dict.get("log")
        pass

    def _log(self,threadName):
        print(os.getpid())
        print(self.log)
        print(threadName)

    def run(self):
        _thread.start_new_thread(self._log,("Thread-1",))

    def update(self):
        self.run()
        return self.log
        pass

在控制器中加载,name="Module-Test" 是需要加载的模块名称,log=str("TEST LOG PRINT") 是传递的参数。
connect(self._lookTestsLog)是回调函数。
注:函数调用规范 on_组件名称_组件动作() 定义后就可以通过装饰器调用任意组件和动作。

    @pyqtSlot()
    def on_pushButton_clicked(self):
        self.q.lock()
        self.runCmd_ = runCmd(name="Module-Test", log=str("TEST LOG PRINT"))
        self.runCmd_.cmdsign.connect(self._lookTestsLog)
        self.runCmd_.start()
        self.runCmd_.wait()
        self.q.unlock()
    def _lookTestsLog(self, log):
        self.label.setText(log)

最后运行main.py即可。

pyqt5-comet's People

Contributors

skyblueeternal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

renpan1986

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.