python程序界面

发布时间:2019-09-22 07:59:02编辑:auto阅读(1453)

    # -*- coding: utf-8 -*-
    
    # Form implementation generated from reading ui file 'Main.ui'
    #
    # Created: Thu Jan 29 16:25:31 2015
    #      by: PyQt4 UI code generator 4.11.3
    #
    # WARNING! All changes made in this file will be lost!
    
    from PyQt4 import QtCore, QtGui
    import sys,time
    
    try:
        _fromUtf8 = QtCore.QString.fromUtf8
    except AttributeError:
        def _fromUtf8(s):
            return s
    
    try:
        _encoding = QtGui.QApplication.UnicodeUTF8
        def _translate(context, text, disambig):
            return QtGui.QApplication.translate(context, text, disambig, _encoding)
    except AttributeError:
        def _translate(context, text, disambig):
            return QtGui.QApplication.translate(context, text, disambig)
    
    class Ui_Dialog(QtGui.QDialog):
        def __init__(self):
            super(Ui_Dialog, self).__init__()
           
            self.setupUi(self)
            self.retranslateUi(self)
            self.flag0=True
            self.flag1=True
            timer=QtCore.QTimer(self)  
            QtCore.QObject.connect(timer,QtCore.SIGNAL("timeout()"),self.ScanCodeChange)
            timer.start(8000)  
            
            bannertimer=QtCore.QTimer(self)  
            QtCore.QObject.connect(bannertimer,QtCore.SIGNAL("timeout()"),self.BannerChange)
            bannertimer.start(5000)         
            
        #This is the scanCodePic changed operation.
        def ScanCodeChange(self):       
            if self.flag0==True:
                self.label_2.setPixmap(QtGui.QPixmap(_fromUtf8("D:/ADPic/scan01.jpg")))
                self.flag0=False
            else:
                self.label_2.setPixmap(QtGui.QPixmap(_fromUtf8("D:/ADPic/scan02.jpg")))
                self.flag0=True
                
        #This is the BannerPic changed operation.
        def BannerChange(self):       
            if self.flag1==True:
                self.label.setPixmap(QtGui.QPixmap(_fromUtf8("D:/ADPic/bank01.jpg")))
                self.flag1=False
            else:
                self.label.setPixmap(QtGui.QPixmap(_fromUtf8("D:/ADPic/bank02.jpg")))
                self.flag1=True     
                
        def setupUi(self, Dialog):
            Dialog.setObjectName(_fromUtf8("Dialog"))
            Dialog.resize(1000, 1000)
            Dialog.setAutoFillBackground(True)
            self.label = QtGui.QLabel(Dialog)
            self.label.setGeometry(QtCore.QRect(0, 0, 1500, 600))
            self.label.setText(_fromUtf8(""))
            self.label.setPixmap(QtGui.QPixmap(_fromUtf8("D:/ADPic/bank01.jpg")))
            self.label.setScaledContents(True)
            self.label.setObjectName(_fromUtf8("label"))
            self.textBrowser = QtGui.QTextBrowser(Dialog)
            self.textBrowser.setGeometry(QtCore.QRect(0, 600, 600,500))
            self.textBrowser.setObjectName(_fromUtf8("textBrowser"))
            #self.widget = QtGui.QWidget(Dialog)
            #self.widget.setGeometry(QtCore.QRect(399, 389, 371, 191))
            #self.widget.setObjectName(_fromUtf8("widget"))
            self.label_2 = QtGui.QLabel(Dialog)
            self.label_2.setGeometry(QtCore.QRect(600, 600, 850, 300))
            self.label_2.setText(_fromUtf8(""))
            self.label_2.setPixmap(QtGui.QPixmap(_fromUtf8("D:/ADPic/scan01.jpg")))
            self.label_2.setScaledContents(True)
            self.label_2.setObjectName(_fromUtf8("label_2"))
            self.retranslateUi(Dialog)
            QtCore.QMetaObject.connectSlotsByName(Dialog)
            
        def retranslateUi(self, Dialog):
            self.textBrowser.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:18pt; font-weight:600;\">说明:</span></p>\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:18pt; font-weight:600;\">1.请按回车键输入手机接收到的验证码。</span></p>\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:18pt; font-weight:600;\">2.输入时请您仔细核实,按回车键进行输入,按ESC键进行退出。</span></p>\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:18pt; font-weight:600;\">3.输入完成后按回车键进行奖品领取。</span></p>\n"
    "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None))
          
        def keyPressEvent(self, event):      
            if event.key() == QtCore.Qt.Key_Return:
                dialog=CheckUi_dialog()
                dialog.show()
                dialog.setModal(False)
               
                dialog.exec_()
                #print 'showcheckdialog'
            else:
                #when the normal screen works it need to display(to avoid esc)!
                QtGui.QDialog.keyPressEvent(self, event)            
                
                
    class CheckUi_dialog(QtGui.QDialog):
        def __init__(self):
            super(CheckUi_dialog, self).__init__() 
            self.checksetupUi(self)
            self.checkretranslateUi(self)
         
        def checksetupUi(self, dialog):
            dialog.setObjectName(_fromUtf8("dialog"))
            dialog.resize(456, 218)
            self.pushButton_2 = QtGui.QPushButton(dialog)
            self.pushButton_2.setGeometry(QtCore.QRect(300, 150, 111, 41))
            self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
            self.pushButton = QtGui.QPushButton(dialog)
            self.pushButton.setGeometry(QtCore.QRect(60, 150, 111, 41))
            self.pushButton.setObjectName(_fromUtf8("pushButton"))
            self.label = QtGui.QLabel(dialog)
            self.label.setGeometry(QtCore.QRect(20, 70, 101, 31))
            self.label.setObjectName(_fromUtf8("label"))
            self.textEdit = QtGui.QLineEdit(dialog)
            self.textEdit.setGeometry(QtCore.QRect(130, 70, 291, 31))
            self.textEdit.setObjectName(_fromUtf8("textEdit"))
            self.textEdit.setFocus()
            QtCore.QObject.connect(self.textEdit, QtCore.SIGNAL("returnPressed()"), self.text)
            self.checkretranslateUi(dialog)         
            QtCore.QMetaObject.connectSlotsByName(dialog)
            dialog.setTabOrder(self.pushButton, self.pushButton_2) 
        def text(self):  
            if not self.textEdit.text():
                QtGui.QMessageBox.about(self,(_fromUtf8("提示!")), (_fromUtf8("请输入验证码!")))
            else:
                if (int(self.textEdit.text())==5):
                    #print 'codesuccess'
                    QtGui.QMessageBox.about(self,(_fromUtf8("恭喜您!")), (_fromUtf8("恭喜您,您的验证码通过,请您及时领取奖品!")))
                else:
                    QtGui.QMessageBox.about(self,(_fromUtf8("很抱歉!")), (_fromUtf8("很抱歉,您的验证码输入不正确,请您再次验证核实")))
                    #print 'codefailed'
        def checkretranslateUi(self, dialog):
            dialog.setWindowTitle(_translate("dialog", "输入验证码", None))
            self.pushButton_2.setText(_translate("dialog", "取 消", None))
            self.pushButton.setText(_translate("dialog", "确 定", None))
            self.label.setText(_translate("dialog", "<html><head/><body><p><span style=\" font-size:12pt; font-weight:600;\">输入验证码:</span></p></body></html>", None))
    
          
                       
    
        
    if __name__ == '__main__':
        app = QtGui.QApplication(sys.argv)
        win = Ui_Dialog()
        #win.show()
        win.showFullScreen()
        sys.exit(app.exec_())
    #import 001_rc
    

关键字