demo.py 1.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# coding:utf-8
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton

from state_tooltip import StateTooltip


class Window(QWidget):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.resize(800, 300)
        self.btn = QPushButton('点我', parent=self)
        self.btn.move(310, 225)
        self.btn.clicked.connect(self.onButtonClicked)
        self.stateTooltip = None
        with open('resource/style/demo.qss', encoding='utf-8') as f:
            self.setStyleSheet(f.read())

    def onButtonClicked(self):
        if self.stateTooltip:
            self.stateTooltip.setContent('模型训练完成啦 😆')
            self.stateTooltip.setState(True)
            self.stateTooltip = None
        else:
            self.stateTooltip = StateTooltip('正在训练模型', '客官请耐心等待哦~~', self)
            self.stateTooltip.move(520, 30)
            self.stateTooltip.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = Window()
    w.show()
    sys.exit(app.exec_())