Содержание

PyQt5

pip install pyqt5 

Примеры

:!: Простое окно
import sys
from PyQt5 import QtWidgets,QtGui
 
app = QtWidgets.QApplication(sys.argv)
windows = QtWidgets.QWidget()
windows.resize(500,500)
windows.move(100,100)
 
windows.setWindowTitle('Title')
# set icon
windows.setWindowIcon(QtGui.QIcon('icon.png'))
windows.show()
sys.exit(app.exec_())
:!: Поток, прогресс бар
import sys
import time
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QWidget, QPushButton, QProgressBar, QVBoxLayout, QApplication
 
class Thread(QThread):
    _signal = pyqtSignal(int)
    def __init__(self):
        super(Thread, self).__init__()
 
    def __del__(self):
        self.wait()
 
    def run(self):
        for i in range(100):
            time.sleep(0.1)
            self._signal.emit(i)
 
class Example(QWidget):
    def __init__(self):
        super(Example, self).__init__()
        self.setWindowTitle('QProgressBar')
        self.btn = QPushButton('Click me')
        self.btn.clicked.connect(self.btnFunc)
        self.pbar = QProgressBar(self)
        self.pbar.setValue(0)
        self.resize(300, 100)
        self.vbox = QVBoxLayout()
        self.vbox.addWidget(self.pbar)
        self.vbox.addWidget(self.btn)
        self.setLayout(self.vbox)
        self.show()
 
    def btnFunc(self):
        self.thread = Thread()
        self.thread._signal.connect(self.signal_accept)
        self.thread.start()
        self.btn.setEnabled(False)
 
    def signal_accept(self, msg):
        self.pbar.setValue(int(msg))
        if self.pbar.value() == 99:
            self.pbar.setValue(0)
            self.btn.setEnabled(True)
 
if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example()
    ex.show()
    sys.exit(app.exec_())
:!: Форма Qml, связь сигнало-слота

Подключение модулей нужно проверить, есть лишние

import sys, time
from PySide2 import QtWidgets
from PySide2.QtQml import QQmlApplicationEngine 
from PySide2.QtCore import QObject, Slot
from PySide2.QtQuick import QQuickView
from PySide2.QtGui import QGuiApplication
 
class Messenger(QObject):
    @Slot(str)
    def PrintMessage(self, message):
        print('Your message: "'+ message +'"')
 
app= QGuiApplication(sys.argv)
view= QQmlApplicationEngine('win.qml')
mes = Messenger()
 
ctx = view.rootContext()
ctx.setContextProperty("messenger", mes)
 
sys.exit(app.exec_())
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.1
 
ApplicationWindow 
{
    visible: true; width: 360; height: 360
 
    Rectangle {
        id: button
        width: 150; height: 40
        color: "darkgray"
        anchors.horizontalCenter: page.horizontalCenter
        y: 120
        MouseArea {
            id: buttonMouseArea
            objectName: "buttonMouseArea"
            anchors.fill: parent
            onClicked: {
                messenger.PrintMessage("da suka daaaa sukaaa")
            }
        }
        Text {
            id: buttonText
            text: "Press me!"
            anchors.horizontalCenter: button.horizontalCenter
            anchors.verticalCenter: button.verticalCenter
            font.pointSize: 16
        }
    }
}
:!: