示例#1
0
    def __init__(self):
        QWidget.__init__(self, ctx.mainScreen)
        self.setObjectName("InformationWindow")
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFixedHeight(50)
        self.setMaximumWidth(800)
        self.setStyleSheet("""
            QFrame#frame { border: 1px solid rgba(255,255,255,30);
                           /*border-radius: 4px;*/
                           background-color: rgba(0,0,0,100);}

            QLabel { border:none;
                     color:#FFFFFF;}

            QProgressBar { border: 1px solid white;}

            QProgressBar::chunk { background-color: #F1610D;
                                  width: 0.5px;}
        """)

        self.gridlayout = QGridLayout(self)
        self.frame = QFrame(self)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QHBoxLayout(self.frame)
        self.horizontalLayout.setContentsMargins(10, 0, 10, 0)

        # Spinner
        self.spinner = QLabel(self.frame)
        self.spinner.setMinimumSize(QSize(16, 16))
        self.spinner.setMaximumSize(QSize(16, 16))
        self.spinner.setIndent(6)
        self.movie = QMovie(':/images/working.mng')
        self.spinner.setMovie(self.movie)
        self.movie.start()
        self.horizontalLayout.addWidget(self.spinner)

        # Message
        self.label = QLabel(self.frame)
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.icon = QLabel(self.frame)
        self.icon.setFixedWidth(16)
        self.icon.setFixedHeight(16)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.addWidget(self.icon)
        self.horizontalLayout.addWidget(self.label)

        self.gridlayout.addWidget(self.frame, 0, 0, 1, 1)
示例#2
0
 def __init__(self, parent=None):
     super(MainIndex, self).__init__(parent)
     self.desktop = QApplication.desktop()
     self.screenRect = self.desktop.screenGeometry()
     self.h = self.screenRect.height()
     self.w = self.screenRect.width()
     self.xr = self.w / 930
     self.yr = self.h / 640
     self.zr = min(self.xr, self.yr)
     self.token = ''
     self.top_wi = QWidget(self)
     self.logo_la = QLabel(self.top_wi)
     self.manual_but = QPushButton(self)
     # self.manual_tex = QLabel(self)
     self.auto_but = QPushButton(self)
     # self.auto_tex = QLabel(self)
     self.home_but = QPushButton(self)
     # self.home_tex = QLabel(self)
     self.loading = QLabel(self)
     self.gif = QMovie('./resource/image/load.gif')
     self.set_ui()
     with open('mainindex.qss', 'r') as f:
         self.setStyleSheet(f.read())
示例#3
0
 def __init__(self, parent=None):
     super(Index, self).__init__(parent)
     self.desktop = QApplication.desktop()
     self.screenRect = self.desktop.screenGeometry()
     self.h = self.screenRect.height()
     self.w = self.screenRect.width()
     self.xr = self.w / 930
     self.yr = self.h / 640
     self.zr = min(self.xr, self.yr)
     self.top_wi = QWidget(self)
     self.logo_la = QLabel(self.top_wi)
     self.ind_wi = QWidget(self)
     self.login_but = QPushButton(self.ind_wi)
     self.joke_but = QPushButton(self.ind_wi)
     self.register_but = QPushButton(self.ind_wi)
     self.imp_la = QLabel(self.ind_wi)
     self.account_le = QLineEdit(self.ind_wi)
     self.psw_le = QLineEdit(self.ind_wi)
     self.loading = QLabel(self)
     self.gif = QMovie('./resource/image/load.gif')
     self.set_ui()
     with open('index.qss', 'r') as f:
         self.setStyleSheet(f.read())
示例#4
0
    def __init__(self, main):
        super(MainWidget, self).__init__()
        self.main_win = main
        self.setObjectName("MainWidget")

        v_layout = QVBoxLayout()
        label = QLabel(self)
        label.setAlignment(Qt.AlignCenter)
        movie = QMovie("main_bg.gif")
        label.setMovie(movie)
        movie.start()
        v_layout.addWidget(label)
        h_layout = QHBoxLayout()
        btn1 = QPushButton("愛")
        btn1.setFixedWidth(30)
        btn1.clicked.connect(self.sub_pack)
        h_layout.addWidget(btn1, alignment=Qt.AlignLeft | Qt.AlignBottom)

        btn2 = QPushButton("嫌")
        btn2.setFixedWidth(30)
        btn2.clicked.connect(self.to_pack)
        h_layout.addWidget(btn2, alignment=Qt.AlignRight | Qt.AlignBottom)
        v_layout.addLayout(h_layout)
        self.setLayout(v_layout)
示例#5
0
    def __init__(self):
        QWidget.__init__(self, ctx.mainScreen)
        self.setObjectName("InformationWindow")
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFixedHeight(50)
        self.setMaximumWidth(800)
        self.setStyleSheet("""
            QFrame#frame { border: 1px solid rgba(255,255,255,30);
                           /*border-radius: 4px;*/
                           background-color: rgba(0,0,0,100);}

            QLabel { border:none;
                     color:#FFFFFF;}

            QProgressBar { border: 1px solid white;}

            QProgressBar::chunk { background-color: #F1610D;
                                  width: 0.5px;}
        """)

        self.gridlayout = QGridLayout(self)
        self.frame = QFrame(self)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QHBoxLayout(self.frame)
        self.horizontalLayout.setContentsMargins(10, 0, 10, 0)

        # Spinner
        self.spinner = QLabel(self.frame)
        self.spinner.setMinimumSize(QSize(16, 16))
        self.spinner.setMaximumSize(QSize(16, 16))
        self.spinner.setIndent(6)
        self.movie = QMovie(':/images/working.mng')
        self.spinner.setMovie(self.movie)
        self.movie.start()
        self.horizontalLayout.addWidget(self.spinner)

        # Message
        self.label = QLabel(self.frame)
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.icon = QLabel(self.frame)
        self.icon.setFixedWidth(16)
        self.icon.setFixedHeight(16)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.addWidget(self.icon)
        self.horizontalLayout.addWidget(self.label)

        self.gridlayout.addWidget(self.frame,0,0,1,1)
示例#6
0
 def b9():
     m1 = QMovie('基数排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#7
0
 def b6():
     m1 = QMovie('希尔排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#8
0
 def b5():
     m1 = QMovie('选择排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#9
0
 def b4():
     m1 = QMovie('归并排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#10
0
 def b3():
     m1 = QMovie('快速排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#11
0
class InformationWindow(QWidget):
    def __init__(self):
        QWidget.__init__(self, ctx.mainScreen)
        self.setObjectName("InformationWindow")
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFixedHeight(50)
        self.setMaximumWidth(800)
        self.setStyleSheet("""
            QFrame#frame { border: 1px solid rgba(255,255,255,30);
                           /*border-radius: 4px;*/
                           background-color: rgba(0,0,0,100);}

            QLabel { border:none;
                     color:#FFFFFF;}

            QProgressBar { border: 1px solid white;}

            QProgressBar::chunk { background-color: #F1610D;
                                  width: 0.5px;}
        """)

        self.gridlayout = QGridLayout(self)
        self.frame = QFrame(self)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QHBoxLayout(self.frame)
        self.horizontalLayout.setContentsMargins(10, 0, 10, 0)

        # Spinner
        self.spinner = QLabel(self.frame)
        self.spinner.setMinimumSize(QSize(16, 16))
        self.spinner.setMaximumSize(QSize(16, 16))
        self.spinner.setIndent(6)
        self.movie = QMovie(':/images/working.mng')
        self.spinner.setMovie(self.movie)
        self.movie.start()
        self.horizontalLayout.addWidget(self.spinner)

        # Message
        self.label = QLabel(self.frame)
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.icon = QLabel(self.frame)
        self.icon.setFixedWidth(16)
        self.icon.setFixedHeight(16)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.addWidget(self.icon)
        self.horizontalLayout.addWidget(self.label)

        self.gridlayout.addWidget(self.frame, 0, 0, 1, 1)

    def update(self, message, type=None, spinner=False):
        fontMetric = self.label.fontMetrics()
        textWidth = fontMetric.width(message)

        if type:
            self.icon.show()
            if type == "error":
                self.icon.setPixmap(QPixmap(":/gui/pics/dialog-error.png"))
                self.setStyleSheet(
                    " QFrame#frame {background-color: rgba(255,0,0,100);} ")

            elif type == "warning":
                self.icon.setPixmap(QPixmap(":/gui/pics/dialog-warning.png"))
                self.setStyleSheet(
                    " QFrame#frame {background-color: rgba(0,0,0,100);} ")

            self.setFixedWidth(textWidth + self.icon.width() + 50)
            self.label.setText(message)

        else:
            self.icon.hide()
            self.setStyleSheet(
                " QFrame#frame {background-color: rgba(0,0,0,100);} ")
            self.setFixedWidth(textWidth + self.icon.width() + 100)
            self.label.setText(message)

        self.spinner.setVisible(spinner)
        self.move(ctx.mainScreen.width() / 2 - self.width() / 2,
                  ctx.mainScreen.height() - self.height() / 2 - 50)

        self.show()

    def refresh(self):
        ctx.mainScreen.processEvents()

    def show(self):
        QWidget.show(self)
        self.refresh()

    def hide(self):
        QWidget.hide(self)
        self.refresh()
示例#12
0
class MainIndex(QWidget):
    auto_pressed_sg = pyqtSignal(dict)
    home_pressed_sg = pyqtSignal()
    search_pressed_sg = pyqtSignal()

    def __init__(self, parent=None):
        super(MainIndex, self).__init__(parent)
        self.desktop = QApplication.desktop()
        self.screenRect = self.desktop.screenGeometry()
        self.h = self.screenRect.height()
        self.w = self.screenRect.width()
        self.xr = self.w / 930
        self.yr = self.h / 640
        self.zr = min(self.xr, self.yr)
        self.token = ''
        self.top_wi = QWidget(self)
        self.logo_la = QLabel(self.top_wi)
        self.manual_but = QPushButton(self)
        # self.manual_tex = QLabel(self)
        self.auto_but = QPushButton(self)
        # self.auto_tex = QLabel(self)
        self.home_but = QPushButton(self)
        # self.home_tex = QLabel(self)
        self.loading = QLabel(self)
        self.gif = QMovie('./resource/image/load.gif')
        self.set_ui()
        with open('mainindex.qss', 'r') as f:
            self.setStyleSheet(f.read())

    def set_ui(self):
        self.setWindowTitle('Hall')
        self.setObjectName('hall')
        self.resize(self.w, self.h)
        effect1 = QGraphicsDropShadowEffect()
        effect1.setOffset(10, 10)
        effect1.setColor(QColor(0, 0, 0, 80))
        effect1.setBlurRadius(20)
        effect2 = QGraphicsDropShadowEffect()
        effect2.setOffset(10, 10)
        effect2.setColor(QColor(0, 0, 0, 80))
        effect2.setBlurRadius(20)
        effect3 = QGraphicsDropShadowEffect()
        effect3.setOffset(10, 10)
        effect3.setColor(QColor(0, 0, 0, 80))
        effect3.setBlurRadius(20)
        self.top_wi.setObjectName('top')
        self.top_wi.resize(self.xr * 930, self.yr * 95)
        self.logo_la.setObjectName('logo')
        self.logo_la.resize(self.xr * 65, self.zr * 65)
        self.logo_la.move(self.xr * 29, self.yr * 16)
        self.manual_but.setObjectName('box')
        self.manual_but.resize(self.xr * 180, self.yr * 320)
        self.manual_but.move(self.xr * 112, self.yr * 194)
        self.manual_but.setText(change_vertical('战局搜索'))
        self.manual_but.setStyleSheet(
            'border-radius:{}px;font-size:{}px;'.format(
                self.zr * 20, int(self.zr * 30)))
        self.manual_but.setGraphicsEffect(effect1)
        self.manual_but.clicked.connect(self.search_press)
        # self.manual_tex.setObjectName('manual_tex')
        # self.manual_tex.resize(self.xr * 34, self.yr * 413)
        # self.manual_tex.move(self.xr * 68, self.yr * 152)
        # self.manual_tex.setText(change_vertical('是当一辈子的懦夫,还是三十秒的勇士?'))
        # self.manual_tex.setStyleSheet('font-size:{}px;'.format(int(self.zr * 17)))
        self.auto_but.setObjectName('box')
        self.auto_but.resize(self.xr * 180, self.yr * 320)
        self.auto_but.move(self.xr * 381, self.yr * 194)
        self.auto_but.setText(change_vertical('自动场'))
        self.auto_but.setStyleSheet(
            'border-radius:{}px;font-size:{}px;'.format(
                self.zr * 20, int(self.zr * 30)))
        self.auto_but.setGraphicsEffect(effect2)
        self.auto_but.clicked.connect(self.auto_press)
        # self.auto_tex.setObjectName('auto_tex')
        # self.auto_tex.resize(self.xr * 34, self.yr * 413)
        # self.auto_tex.move(self.xr * 340, self.yr * 152)
        # self.auto_tex.setText(change_vertical('机器就要由机器来终结'))
        # self.auto_tex.setStyleSheet('font-size:{}px;'.format(int(self.zr * 17)))
        self.home_but.setObjectName('box')
        self.home_but.resize(self.xr * 180, self.yr * 320)
        self.home_but.move(self.xr * 660, self.yr * 194)
        self.home_but.setText(change_vertical('沙之家'))
        self.home_but.setStyleSheet(
            'border-radius:{}px;font-size:{}px;'.format(
                self.zr * 20, int(self.zr * 30)))
        self.home_but.setGraphicsEffect(effect3)
        self.home_but.clicked.connect(self.home_press)
        # self.home_tex.setObjectName('home_tex')
        # self.home_tex.resize(self.xr * 34, self.yr * 413)
        # self.home_tex.move(self.xr * 610, self.yr * 152)
        # self.home_tex.setText(change_vertical('常回家看看!'))
        # self.home_tex.setStyleSheet('font-size:{}px;'.format(int(self.zr * 17)))
        self.loading.setObjectName('load')
        self.loading.resize(self.xr * 150, self.yr * 150)
        self.loading.move(self.xr * 760, self.yr * 500)
        self.loading.setScaledContents(True)
        self.loading.setMovie(self.gif)
        self.gif.start()

    def auto_press(self):
        res = play(self.token)
        if res["status"] == 0:
            self.auto_pressed_sg.emit(res)

    def home_press(self):
        self.home_pressed_sg.emit()

    def search_press(self):
        self.search_pressed_sg.emit()

    def get_token(self, t):
        self.token = t
示例#13
0
class Index(QWidget):
    show_mainindex_sg = pyqtSignal(int, str)
    show_register_sg = pyqtSignal()

    def __init__(self, parent=None):
        super(Index, self).__init__(parent)
        self.desktop = QApplication.desktop()
        self.screenRect = self.desktop.screenGeometry()
        self.h = self.screenRect.height()
        self.w = self.screenRect.width()
        self.xr = self.w / 930
        self.yr = self.h / 640
        self.zr = min(self.xr, self.yr)
        self.top_wi = QWidget(self)
        self.logo_la = QLabel(self.top_wi)
        self.ind_wi = QWidget(self)
        self.login_but = QPushButton(self.ind_wi)
        self.joke_but = QPushButton(self.ind_wi)
        self.register_but = QPushButton(self.ind_wi)
        self.imp_la = QLabel(self.ind_wi)
        self.account_le = QLineEdit(self.ind_wi)
        self.psw_le = QLineEdit(self.ind_wi)
        self.loading = QLabel(self)
        self.gif = QMovie('./resource/image/load.gif')
        self.set_ui()
        with open('index.qss', 'r') as f:
            self.setStyleSheet(f.read())

    def set_ui(self):
        self.setWindowTitle('Login')
        self.setObjectName('index')
        self.resize(self.w, self.h)
        self.top_wi.setObjectName('top')
        self.top_wi.resize(930 * self.xr, 95 * self.yr)
        self.logo_la.setObjectName('logo')
        self.logo_la.resize(65 * self.xr, 65 * self.zr)
        self.logo_la.move(29 * self.xr, 16 * self.yr)
        effect = QGraphicsDropShadowEffect()
        effect.setOffset(10, 10)
        effect.setColor(QColor(0, 0, 0, 80))
        effect.setBlurRadius(20)
        self.ind_wi.setObjectName('login')
        self.ind_wi.resize(327 * self.xr, 388 * self.yr)
        self.ind_wi.move(300 * self.xr, 150 * self.yr)
        self.ind_wi.setGraphicsEffect(effect)
        self.joke_but.setObjectName('joke')
        self.joke_but.resize(130 * self.xr, 30 * self.yr)
        self.joke_but.move(76 * self.xr, 234 * self.yr)
        self.joke_but.setFlat(True)
        self.joke_but.setText('忘记密码?我也没办法')
        self.login_but.setObjectName('button')
        self.login_but.move(64 * self.xr, 260 * self.yr)
        self.login_but.resize(202 * self.xr, 45 * self.yr)
        self.login_but.setText('登陆')
        self.login_but.clicked.connect(self.login)
        self.register_but.setObjectName('button')
        self.register_but.move(64 * self.xr, 315 * self.yr)
        self.register_but.resize(202 * self.xr, 45 * self.yr)
        self.register_but.setText('注册')
        self.register_but.clicked.connect(self.show_register)
        self.imp_la.setObjectName('imp_label')
        self.imp_la.resize(100 * self.zr, 100 * self.zr)
        self.imp_la.move(115 * self.xr + 100 * (self.xr - self.zr) / 2, 15 * self.yr)
        self.imp_la.setStyleSheet('border-radius:{}px;'.format(self.zr * 49))
        self.account_le.setObjectName('input')
        self.account_le.setTextMargins(20, 0, 0, 0)
        self.account_le.resize(213 * self.xr, 45 * self.yr)
        self.account_le.move(59 * self.xr, 126 * self.yr)
        self.account_le.setPlaceholderText('账号')
        self.psw_le.setObjectName('input')
        self.psw_le.setTextMargins(20, 0, 0, 0)
        self.psw_le.resize(213 * self.xr, 45 * self.yr)
        self.psw_le.move(59 * self.xr, 181 * self.yr)
        self.psw_le.setPlaceholderText('密码')
        self.psw_le.setEchoMode(QLineEdit.Password)
        self.loading.setObjectName('load')
        self.loading.resize(self.xr * 150, self.yr * 150)
        self.loading.move(self.xr * 760, self.yr * 500)
        self.loading.setScaledContents(True)
        self.loading.setMovie(self.gif)
        self.gif.start()
        self.ind_wi.setStyleSheet('#input{border-radius:' + str(self.zr * 20) + 'px;}' + '#button{border-radius:' + str(
            self.zr * 20) + 'px;' + 'font-size:' + str(int(self.zr * 18)) + 'px;}')

    def login(self):
        account_p = self.account_le.text()
        psw_p = self.psw_le.text()
        dic = login(account_p, psw_p)
        if dic['status'] == 0:
            self.show_mainindex_sg.emit(dic['data']['user_id'], dic['data']['token'])
        elif dic['status'] == 1:
            self.account_le.clear()
            self.psw_le.clear()
            self.account_le.setStyleSheet('border:4px solid;border-color:red;')
            self.account_le.setPlaceholderText('网络超时')
        else:
            self.account_le.clear()
            self.psw_le.clear()
            self.account_le.setStyleSheet('border:4px solid;border-color:red;')
            self.account_le.setPlaceholderText('账号不存在或密码错误')

    def show_register(self):
        self.show_register_sg.emit()
示例#14
0
class ProgressWindow(QWidget):
    def __init__(self, message):
        QWidget.__init__(self, ctx.mainScreen)
        self.setObjectName("ProgressWindow")
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFixedHeight(50)
        self.setMaximumWidth(800)
        self.setStyleSheet("""
            QFrame#frame { border: 1px solid rgba(255,255,255,30);
                           /*border-radius: 4px;*/
                           background-color: rgba(255,0,0,100);}

            QLabel { border:none;
                     color:#FFFFFF;}

            QProgressBar { border: 1px solid white;}

            QProgressBar::chunk { background-color: #F1610D;
                                  width: 0.5px;}
        """)

        self.gridlayout = QGridLayout(self)
        self.frame = QFrame(self)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QHBoxLayout(self.frame)
        self.horizontalLayout.setContentsMargins(6, 0, 0, 0)

        # Spinner
        self.spinner = QLabel(self.frame)
        self.spinner.setMinimumSize(QSize(16, 16))
        self.spinner.setMaximumSize(QSize(16, 16))
        self.spinner.setIndent(6)
        self.movie = QMovie(':/images/working.mng')
        self.spinner.setMovie(self.movie)
        self.movie.start()
        self.horizontalLayout.addWidget(self.spinner)

        # Message
        self.label = QLabel(self.frame)
        self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.horizontalLayout.addWidget(self.label)
        self.gridlayout.addWidget(self.frame, 0, 0, 1, 1)

        self.update(message)

    def update(self, message):
        self.spinner.setVisible(True)
        fontMetric = self.label.fontMetrics()
        textWidth = fontMetric.width(message)
        self.setFixedWidth(textWidth + 100)
        self.label.setText(message)
        self.move(ctx.mainScreen.width() / 2 - self.width() / 2,
                  ctx.mainScreen.height() - self.height() / 2 - 50)
        self.show()

    def refresh(self):
        ctx.mainScreen.processEvents()

    def show(self):
        QWidget.show(self)
        self.refresh()

    def pop(self):
        QWidget.hide(self)
        self.refresh()
示例#15
0
 def b7():
     m1 = QMovie('插入排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#16
0
 def b10():
     m1 = QMovie('堆排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#17
0
class InformationWindow(QWidget):

    def __init__(self):
        QWidget.__init__(self, ctx.mainScreen)
        self.setObjectName("InformationWindow")
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFixedHeight(50)
        self.setMaximumWidth(800)
        self.setStyleSheet("""
            QFrame#frame { border: 1px solid rgba(255,255,255,30);
                           /*border-radius: 4px;*/
                           background-color: rgba(0,0,0,100);}

            QLabel { border:none;
                     color:#FFFFFF;}

            QProgressBar { border: 1px solid white;}

            QProgressBar::chunk { background-color: #F1610D;
                                  width: 0.5px;}
        """)

        self.gridlayout = QGridLayout(self)
        self.frame = QFrame(self)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QHBoxLayout(self.frame)
        self.horizontalLayout.setContentsMargins(10, 0, 10, 0)

        # Spinner
        self.spinner = QLabel(self.frame)
        self.spinner.setMinimumSize(QSize(16, 16))
        self.spinner.setMaximumSize(QSize(16, 16))
        self.spinner.setIndent(6)
        self.movie = QMovie(':/images/working.mng')
        self.spinner.setMovie(self.movie)
        self.movie.start()
        self.horizontalLayout.addWidget(self.spinner)

        # Message
        self.label = QLabel(self.frame)
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.icon = QLabel(self.frame)
        self.icon.setFixedWidth(16)
        self.icon.setFixedHeight(16)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.addWidget(self.icon)
        self.horizontalLayout.addWidget(self.label)

        self.gridlayout.addWidget(self.frame,0,0,1,1)

    def update(self, message, type=None, spinner=False):
        fontMetric = self.label.fontMetrics()
        textWidth = fontMetric.width(message)

        if type:
            self.icon.show()
            if type == "error":
                self.icon.setPixmap(QPixmap(":/gui/pics/dialog-error.png"))
                self.setStyleSheet(" QFrame#frame {background-color: rgba(255,0,0,100);} ")

            elif type == "warning":
                self.icon.setPixmap(QPixmap(":/gui/pics/dialog-warning.png"))
                self.setStyleSheet(" QFrame#frame {background-color: rgba(0,0,0,100);} ")

            self.setFixedWidth(textWidth + self.icon.width() + 50)
            self.label.setText(message)

        else:
            self.icon.hide()
            self.setStyleSheet(" QFrame#frame {background-color: rgba(0,0,0,100);} ")
            self.setFixedWidth(textWidth + self.icon.width() + 100)
            self.label.setText(message)

        self.spinner.setVisible(spinner)
        self.move(ctx.mainScreen.width()/2 - self.width()/2,
                  ctx.mainScreen.height() - self.height()/2 - 50)

        self.show()

    def refresh(self):
        ctx.mainScreen.processEvents()

    def show(self):
        QWidget.show(self)
        self.refresh()

    def hide(self):
        QWidget.hide(self)
        self.refresh()
示例#18
0
 def b2():
     m1 = QMovie('冒泡排序.gif')
     self.textBrowser.setMovie(m1)
     m1.start()
示例#19
0
class ProgressWindow(QWidget):
    def __init__(self, message):
        QWidget.__init__(self, ctx.mainScreen)
        self.setObjectName("ProgressWindow")
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFixedHeight(50)
        self.setMaximumWidth(800)
        self.setStyleSheet("""
            QFrame#frame { border: 1px solid rgba(255,255,255,30);
                           /*border-radius: 4px;*/
                           background-color: rgba(255,0,0,100);}

            QLabel { border:none;
                     color:#FFFFFF;}

            QProgressBar { border: 1px solid white;}

            QProgressBar::chunk { background-color: #F1610D;
                                  width: 0.5px;}
        """)

        self.gridlayout = QGridLayout(self)
        self.frame = QFrame(self)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QHBoxLayout(self.frame)
        self.horizontalLayout.setContentsMargins(6, 0, 0, 0)

        # Spinner
        self.spinner = QLabel(self.frame)
        self.spinner.setMinimumSize(QSize(16, 16))
        self.spinner.setMaximumSize(QSize(16, 16))
        self.spinner.setIndent(6)
        self.movie = QMovie(':/images/working.mng')
        self.spinner.setMovie(self.movie)
        self.movie.start()
        self.horizontalLayout.addWidget(self.spinner)

        # Message
        self.label = QLabel(self.frame)
        self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.horizontalLayout.addWidget(self.label)
        self.gridlayout.addWidget(self.frame,0,0,1,1)

        self.update(message)

    def update(self, message):
        self.spinner.setVisible(True)
        fontMetric = self.label.fontMetrics()
        textWidth = fontMetric.width(message)
        self.setFixedWidth(textWidth + 100)
        self.label.setText(message)
        self.move(ctx.mainScreen.width()/2 - self.width()/2,
                  ctx.mainScreen.height() - self.height()/2 - 50)
        self.show()

    def refresh(self):
        ctx.mainScreen.processEvents()

    def show(self):
        QWidget.show(self)
        self.refresh()

    def pop(self):
        QWidget.hide(self)
        self.refresh()
示例#20
0
    def __init__(self, parent=None):

        # to prevent GUI lockup in long run.
        #----------------------------------------------------------------------
        QApplication.processEvents()

        QDialog.__init__(self, parent)

        self.setFixedSize(QSize(500, 400))
        self.setWindowTitle("Classes Availability")
        self.setWindowIcon(QIcon('assets/icon.png'))

        # Background Image.
        #----------------------------------------------------------------------
        if (os.path.exists('assets/main_background.jpg') == True):
            # Background Image.
            self.Label_bg = QLabel(self)
            self.Label_bg.resize(1000, 500)
            self.Label_bg.move(-255, -50)
            movie = QMovie("assets/main_background.jpg")
            self.Label_bg.setMovie(movie)
            movie.start()
        else:
            # Background Color.
            color = QColor('#3484A9')
            self.setAutoFillBackground(True)
            p = self.palette()
            p.setColor(self.backgroundRole(), color)
            self.setPalette(p)

        # Sub Background part with transparency.
        #----------------------------------------------------------------------
        self.Label_sbg = QLabel(self)
        self.Label_sbg.setText('')
        self.Label_sbg.resize(450, 320)
        self.Label_sbg.move(25, 60)
        self.Label_sbg.setStyleSheet(
            "background-color:#50000000; border-radius:10px")

        # reading the csv for findinout the total class available.
        #----------------------------------------------------------------------
        class_sound = ''
        with open('audio/classes.csv', 'r') as file:
            # skipping the header of the csv file.
            f_csv = csv.reader(file)
            next(f_csv)  # can access the header by  header = next(f_csv)

            class_sound = '\tId    \t\tName \n           ' + '----------------' * 3

            reader = csv.reader(file)
            for row in reader:
                class_sound = class_sound + '\n\t' + row[0] + ' :\t\t' + row[1]

        # Adding text field here.
        #----------------------------------------------------------------------
        self.b = QPlainTextEdit(self)

        # self.b.setDisabled(True)
        self.b.setReadOnly(True)  # Read only.
        self.b.insertPlainText("\n")

        self.b.setStyleSheet(
            "color:#91000C; font-size:15px; font-weight:bold; background-color:#000000"
        )

        self.b.insertPlainText(class_sound)
        self.b.move(50, 80)
        self.b.resize(400, 280)

        # class header text.
        #----------------------------------------------------------------------
        x = '       Total Classes Available : '
        self.header = QLabel(self)
        self.header.setText(x)
        self.header.resize(340, 25)
        self.header.move(70, 15)
        self.header.setStyleSheet(
            "color:#000000; font-size:20px; font-weight:bold")

        self.numClass = QLabel(self)
        self.numClass.setText(row[0])
        self.numClass.resize(25, 25)
        self.numClass.move(360, 16)
        self.numClass.setStyleSheet(
            "color:#91000C; font-size:20px; font-weight:bold")


######################################################################################################################################
######################################################################################################################################
######################################################################################################################################

#def run():
#    if __name__ =='__main__':
#
#        QApplication.processEvents()
#        my_app = QCoreApplication.instance()
#        if my_app is None:
#            my_app = QApplication(sys.argv)
#        window = TotalClassAvailable()
#        window.show()
#
#        sys.exit(my_app.exec_())
#
#try:
#    run()
#except:
#    print('\nSERVICE SHUTDOWN\n')