示例#1
0
class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(1081, 599)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/images/funcell.png")),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Form.setWindowIcon(icon)
        Form.setStyleSheet(
            _fromUtf8(
                "QToolButton[objectName=\"closetoolButton\"] {\n"
                "border:0px;\n"
                "}\n"
                "QToolButton[objectName=\"closetoolButton\"]:hover {\n"
                "image:url(:/images/close_hover.png);\n"
                "}\n"
                "QToolButton[objectName=\"closetoolButton\"]:pressed {\n"
                "image:url(:/images/close_pressed.png);\n"
                "}\n"
                "\n"
                "QToolButton[objectName=\"closetoolButton_2\"] {\n"
                "border:0px;\n"
                "}\n"
                "QToolButton[objectName=\"closetoolButton_2\"]:hover {\n"
                "image:url(:/images/min_hover.png);\n"
                "}\n"
                "QToolButton[objectName=\"closetoolButton_2\"]:pressed {\n"
                "image:url(:/images/min_pressed.png);\n"
                "}\n"
                "\n"
                "QWidget[objectName=\"Form\"]{\n"
                "border-image:url(\":/images/funcell_bg.png\");\n"
                "}\n"
                "\n"
                "QToolButton[objectName=\"toolButton\"]{\n"
                "background-color: rgb(85, 255, 127);\n"
                "border-radius: 10px;\n"
                "}\n"
                "QLineEdit[objectName=\"lineEdit\"],QLineEdit[objectName=\"lineEdit_2\"]{\n"
                "border:0px;\n"
                "background-color:transparent;\n"
                "}\n"
                "QCheckBox[objectName=\"checkBox\"],QLabel[objectName=\"label_3\"],QLineEdit[objectName=\"lineEdit\"],QLineEdit[objectName=\"lineEdit_2\"]{\n"
                "font-family:\'微软雅黑\';\n"
                "color:white;\n"
                "}\n"
                "\n"
                "QLabel[objectName=\"label_4\"],QLabel[objectName=\"label_5\"]{\n"
                "font-family:\'微软雅黑\';\n"
                "color:red;\n"
                "}\n"
                ""))
        self.widget = QtGui.QWidget(Form)
        self.widget.setGeometry(QtCore.QRect(-1, -1, 1081, 601))
        self.widget.setObjectName(_fromUtf8("widget"))
        self.line_2 = QtGui.QFrame(self.widget)
        self.line_2.setGeometry(QtCore.QRect(320, 225, 420, 3))
        self.line_2.setFrameShape(QtGui.QFrame.HLine)
        self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
        self.line_2.setObjectName(_fromUtf8("line_2"))
        self.label = QtGui.QLabel(self.widget)
        self.label.setGeometry(QtCore.QRect(320, 182, 30, 30))
        self.label.setText(_fromUtf8(""))
        self.label.setPixmap(QtGui.QPixmap(_fromUtf8(":/images/use.png")))
        self.label.setObjectName(_fromUtf8("label"))
        self.line_3 = QtGui.QFrame(self.widget)
        self.line_3.setGeometry(QtCore.QRect(320, 295, 420, 3))
        self.line_3.setFrameShape(QtGui.QFrame.HLine)
        self.line_3.setFrameShadow(QtGui.QFrame.Sunken)
        self.line_3.setObjectName(_fromUtf8("line_3"))
        self.checkBox = QtGui.QCheckBox(self.widget)
        self.checkBox.setGeometry(QtCore.QRect(670, 365, 71, 16))
        self.checkBox.setChecked(True)
        self.checkBox.setObjectName(_fromUtf8("checkBox"))
        self.toolButton = QtGui.QToolButton(self.widget)
        self.toolButton.setGeometry(QtCore.QRect(320, 425, 420, 61))
        self.toolButton.setAutoRepeat(False)
        self.toolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self.toolButton.setObjectName(_fromUtf8("toolButton"))
        self.lineEdit = QtGui.QLineEdit(self.widget)
        self.lineEdit.setGeometry(QtCore.QRect(390, 185, 321, 25))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("微软雅黑"))
        self.lineEdit.setFont(font)
        self.lineEdit.setText(_fromUtf8(""))
        self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
        self.line_4 = QtGui.QFrame(self.widget)
        self.line_4.setGeometry(QtCore.QRect(360, 255, 3, 25))
        self.line_4.setFrameShape(QtGui.QFrame.VLine)
        self.line_4.setFrameShadow(QtGui.QFrame.Sunken)
        self.line_4.setObjectName(_fromUtf8("line_4"))
        self.lineEdit_2 = QtGui.QLineEdit(self.widget)
        self.lineEdit_2.setGeometry(QtCore.QRect(390, 255, 321, 25))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("微软雅黑"))
        self.lineEdit_2.setFont(font)
        self.lineEdit_2.setText(_fromUtf8(""))
        self.lineEdit_2.setEchoMode(QtGui.QLineEdit.Password)
        self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
        self.line = QtGui.QFrame(self.widget)
        self.line.setGeometry(QtCore.QRect(360, 185, 3, 25))
        self.line.setFrameShape(QtGui.QFrame.VLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.line.setObjectName(_fromUtf8("line"))
        #         self.label_3 = QtGui.QLabel(self.widget)
        #         self.label_3.setGeometry(QtCore.QRect(640, 525, 105, 31))
        #         self.label_3.setObjectName(_fromUtf8("label_3"))
        self.label_3 = MyLabel(self)
        self.label_3.setGeometry(QtCore.QRect(640, 525, 105, 31))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.label_3.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.label_2 = QtGui.QLabel(self.widget)
        self.label_2.setGeometry(QtCore.QRect(320, 250, 30, 30))
        self.label_2.setText(_fromUtf8(""))
        self.label_2.setPixmap(QtGui.QPixmap(_fromUtf8(":/images/suo.png")))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.closetoolButton = QtGui.QToolButton(self.widget)
        self.closetoolButton.setGeometry(QtCore.QRect(1050, 5, 27, 22))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/images/close_normal.png")),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.closetoolButton.setIcon(icon)
        self.closetoolButton.setIconSize(QtCore.QSize(27, 22))
        self.closetoolButton.setObjectName(_fromUtf8("closetoolButton"))
        self.closetoolButton_2 = QtGui.QToolButton(self.widget)
        self.closetoolButton_2.setGeometry(QtCore.QRect(1020, 5, 27, 22))
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/images/min_normal.png")),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.closetoolButton_2.setIcon(icon1)
        self.closetoolButton_2.setIconSize(QtCore.QSize(27, 22))
        self.closetoolButton_2.setObjectName(_fromUtf8("closetoolButton_2"))
        self.label_4 = QtGui.QLabel(self.widget)
        self.label_4.setGeometry(QtCore.QRect(770, 210, 105, 31))
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.label_5 = QtGui.QLabel(self.widget)
        self.label_5.setGeometry(QtCore.QRect(770, 280, 105, 31))
        self.label_5.setObjectName(_fromUtf8("label_5"))

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
        self.closetoolButton.clicked.connect(self.close)
        self.closetoolButton_2.clicked.connect(self.showMinimized)
        self.toolButton.clicked.connect(self.LoginTask)
        self.initUserInfo()

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "请登录", None))
        self.checkBox.setText(_translate("Form", "记住密码", None))
        self.toolButton.setText(_translate("Form", "登 录", None))
        self.label_3.setText(_translate("Form", "没有帐号?立即注册", None))
        self.closetoolButton.setText(_translate("Form", "...", None))
        self.closetoolButton_2.setText(_translate("Form", "...", None))
        self.label_4.setText(_translate("Form", "游戏ProductCode", None))
        self.label_5.setText(_translate("Form", "游戏ProductKey", None))

    def mouseMoveEvent(self, event):
        if (event.buttons() == Qt.LeftButton):
            self.endPos = event.globalPos() - self.startPos
            self.move(self.endPos)

    def mousePressEvent(self, event):

        if (event.button() == Qt.LeftButton):
            self.startPos = event.globalPos() - self.frameGeometry().topLeft()

        elif (event.button() == Qt.MiddleButton):
            self.closeWindowAnimation()

    def registerTask(self):
        print 'register user'

    def saveUserInfo(self):
        GameFile = file_operate.getFullPath("Log/GameFile.log")
        checkflag = "False"
        if self.checkBox.isChecked():
            checkflag = "True"
        info = self.lineEdit.text() + '|' + self.lineEdit_2.text(
        ) + '|' + checkflag

        logFile = codecs.open(GameFile, 'w', 'utf-8')
        content = info + '\r\n'
        logFile.write(unicode(content, 'gbk'))
        logFile.close()

    def initUserInfo(self):
        GameFile = file_operate.getFullPath("Log/GameFile.log")
        if not os.path.exists('Log'):
            os.makedirs('Log')
        if os.path.exists(GameFile):
            f = open(GameFile, 'a+')
            data = str(f.read())
            f.close()
            if len(data) > 0 and data.find('|') != -1:
                logFile = codecs.open(GameFile, 'a+', 'utf-8')
                for line in logFile.readlines():
                    line = line.rstrip("\r\n")
                    Info = line.split('|')
                    if Info[2] == "True":
                        self.lineEdit.setText(Info[0])
                        self.lineEdit_2.setText(Info[1])
                        self.checkBox.setChecked(True)
                    else:
                        self.checkBox.setChecked(False)
                    break

    def getHostAddress(self):
        address = ''
        try:
            config = ET.parse(file_operate.getCommonXmlPath())
            root = config.getroot()
            host = root.find("host")
            address = host.get("address")
        except Exception, e:
            print e
            print "Error: cannot parse file: commonconfig.xml."
            return -1
        return address
示例#2
0
class InputDlg(QDialog):
    def __init__(self, parent = None):
        super(InputDlg,self).__init__(parent)
        self.setWindowTitle("家族信息表")
        self.setWindowIcon(QIcon("./icon/dialog.png"))
        self.personInfo = PersonInfo()
        self.CreateWidgets()
        self.Layout()
        self.connect(self.birthdayEditLabel, SIGNAL("mouseDoubleClicked()"), self.ShowBirthCalendar)
        self.connect(self.birthCalendar, SIGNAL("selectionChanged()"), self.ShowBirthday)
        self.connect(self.deadCheckBox, SIGNAL("stateChanged(int)"), self.SetDeath)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

    def CreateWidgets(self):
        self.nameLabel = QLabel("姓名:")
        self.birthdayLabel = QLabel("出生年月:")
        self.birthdayEditLabel = MyLabel("1900-01-01")
        self.birthdayEditLabel.setFrameStyle(QFrame.Panel|QFrame.Sunken)
        self.addressLabel = QLabel("地址:")
        self.deathdayLabel = QLabel("去世年月:")
        self.deathdayEditLabel = MyLabel("- - - ")
        self.deathdayEditLabel.setFrameStyle(QFrame.Panel|QFrame.Sunken)

        self.nameEdit = QLineEdit()
        self.addressEdit = QLineEdit()
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            Qt.Horizontal, self)

        self.confirmButton = QPushButton("确定")
        self.cancelButton = QPushButton("取消")

        self.birthCalendar = QCalendarWidget()
        self.birthCalendar.setWindowTitle("出生年月")
        self.birthCalendar.setWindowIcon(QIcon("./icon/calendar1.png"))
        self.birthCalendar.hide()
        self.deathCalendar = QCalendarWidget()
        self.deathCalendar.setWindowTitle("去世年月")
        self.deathCalendar.setWindowIcon(QIcon("./icon/calendar2.png"))
        self.deathCalendar.hide()

        self.deadCheckBox = QCheckBox("去世")  # 默认未去世
        self.marryCheckBox = QCheckBox("结婚")
        self.marryCheckBox.toggle()  # 默认结婚


    def Layout(self):
        self.UpLayout()
        mainLayout = QGridLayout(self)
        mainLayout.addLayout(self.upLayout, 0, 0)

    def UpLayout(self):
        self.upLayout = QGridLayout()
        self.upLayout.addWidget(self.nameLabel, 0, 0)
        self.upLayout.addWidget(self.nameEdit, 0, 1)
        self.upLayout.addWidget(self.birthdayLabel, 1, 0)
        self.upLayout.addWidget(self.birthdayEditLabel, 1, 1)
        self.upLayout.addWidget(self.addressLabel, 2, 0)
        self.upLayout.addWidget(self.addressEdit, 2, 1)
        self.upLayout.addWidget(self.deadCheckBox, 3, 0)
        self.upLayout.addWidget(self.marryCheckBox, 3, 1)
        self.upLayout.addWidget(self.deathdayLabel, 4, 0)
        self.upLayout.addWidget(self.deathdayEditLabel, 4, 1)
        self.upLayout.addWidget(self.buttons, 5, 1)

    def ShowBirthCalendar(self):
        self.birthCalendar.show()

    def ShowDeathCalendar(self):
        self.deathCalendar.show()

    def SetDeath(self, state):
        # state为2时,表示复选框选中
        if state == 2:
            self.connect(self.deathdayEditLabel, SIGNAL("mouseDoubleClicked()"), self.ShowDeathCalendar)
            self.connect(self.deathCalendar, SIGNAL("selectionChanged()"), self.ShowDeathday)
        # 否则将之前建立的连接断开
        else:
            self.disconnect(self.deathdayEditLabel, SIGNAL("mouseDoubleClicked()"), self.ShowDeathCalendar)
            self.disconnect(self.deathCalendar, SIGNAL("selectionChanged()"), self.ShowDeathday)    


    def ShowBirthday(self):
        birthday = self.birthCalendar.selectedDate()
        birthdayString = birthday.toString()
        pattern = re.compile(r"\d+")  # 匹配月、日、年
        birthdayList = re.findall(pattern, birthdayString)
        self.birthdayEditLabel.setText(str(birthdayList[2])+"-"+str(birthdayList[0])+"-"+str(birthdayList[1]))

    def ShowDeathday(self):
        deathday = self.deathCalendar.selectedDate()
        deathdayString = deathday.toString()
        pattern = re.compile(r"\d+")  # 匹配月、日、年
        deathdayList = re.findall(pattern, deathdayString)
        self.deathdayEditLabel.setText(str(deathdayList[2])+"-"+str(deathdayList[0])+"-"+str(deathdayList[1]))

    # 获取对话框中的数据
    def GetData(self):
        personInfo = PersonInfo()
        personInfo.name = self.nameEdit.text()
        personInfo.birthday = self.birthdayEditLabel.text()
        personInfo.address = self.addressEdit.text()
        if self.marryCheckBox.checkState() == 2:
            personInfo.marry = "是"
        else:
            personInfo.marry = "否"
        if self.deadCheckBox.checkState() == 2:
            personInfo.alive = "否"
            personInfo.deathday = self.deathdayEditLabel.text()
        else:
            personInfo.alive = "是"
            personInfo.deathday = "- - -"
        return personInfo
示例#3
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(467, 536)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setGeometry(QtCore.QRect(10, 90, 441, 401))
        self.frame.setStyleSheet("")
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.layoutWidget = QtWidgets.QWidget(self.frame)
        self.layoutWidget.setGeometry(QtCore.QRect(10, 10, 421, 381))
        self.layoutWidget.setObjectName("layoutWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.account_lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
        self.account_lineEdit.setMinimumSize(QtCore.QSize(293, 35))
        self.account_lineEdit.setMaximumSize(QtCore.QSize(293, 16777215))
        self.account_lineEdit.setStyleSheet("font: 14pt \"华文楷体\";")
        self.account_lineEdit.setClearButtonEnabled(True)
        self.account_lineEdit.setObjectName("account_lineEdit")
        self.gridLayout.addWidget(self.account_lineEdit, 0, 1, 1, 1)
        self.password_label = QtWidgets.QLabel(self.layoutWidget)
        self.password_label.setStyleSheet("font: 14pt \"华文楷体\";")
        self.password_label.setAlignment(QtCore.Qt.AlignCenter)
        self.password_label.setObjectName("password_label")
        self.gridLayout.addWidget(self.password_label, 1, 0, 1, 1)
        self.login_label = QtWidgets.QPushButton(self.layoutWidget)
        self.login_label.setMinimumSize(QtCore.QSize(0, 40))
        self.login_label.setMaximumSize(QtCore.QSize(16777215, 40))
        self.login_label.setStyleSheet("font: 14pt \"华文楷体\";")
        self.login_label.setObjectName("login_label")
        self.gridLayout.addWidget(self.login_label, 4, 0, 1, 2)
        self.password_lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
        self.password_lineEdit.setMinimumSize(QtCore.QSize(293, 35))
        self.password_lineEdit.setMaximumSize(QtCore.QSize(293, 16777215))
        self.password_lineEdit.setStyleSheet("font: 14pt \"华文楷体\";")
        self.password_lineEdit.setEchoMode(QtWidgets.QLineEdit.Password)
        self.password_lineEdit.setClearButtonEnabled(True)
        self.password_lineEdit.setObjectName("password_lineEdit")
        self.gridLayout.addWidget(self.password_lineEdit, 1, 1, 1, 1)
        self.picture_label = MyLabel(self.layoutWidget)
        self.picture_label.setMinimumSize(QtCore.QSize(293, 190))
        self.picture_label.setMaximumSize(QtCore.QSize(293, 190))
        self.picture_label.setStyleSheet("font: 14pt \"华文楷体\";\n"
"background-color: rgb(0, 255, 255);")
        self.picture_label.setAlignment(QtCore.Qt.AlignCenter)
        self.picture_label.setObjectName("picture_label")
        self.gridLayout.addWidget(self.picture_label, 2, 1, 2, 1)
        self.account_label = QtWidgets.QLabel(self.layoutWidget)
        self.account_label.setStyleSheet("font: 14pt \"华文楷体\";")
        self.account_label.setAlignment(QtCore.Qt.AlignCenter)
        self.account_label.setObjectName("account_label")
        self.gridLayout.addWidget(self.account_label, 0, 0, 1, 1)
        self.refresh_button = QtWidgets.QPushButton(self.layoutWidget)
        self.refresh_button.setMinimumSize(QtCore.QSize(50, 60))
        self.refresh_button.setStyleSheet("font: 14pt \"华文楷体\";")
        self.refresh_button.setObjectName("refresh_button")
        self.gridLayout.addWidget(self.refresh_button, 2, 0, 1, 1)
        self.autoSelect_button = QtWidgets.QPushButton(self.layoutWidget)
        self.autoSelect_button.setMinimumSize(QtCore.QSize(50, 60))
        self.autoSelect_button.setStyleSheet("font: 14pt \"华文楷体\";")
        self.autoSelect_button.setObjectName("autoSelect_button")
        self.gridLayout.addWidget(self.autoSelect_button, 3, 0, 1, 1)
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(20, 10, 421, 81))
        self.label.setStyleSheet("font: 14pt \"华文楷体\";\n"
"border-image: url(:/image/qiangpiao.png);")
        self.label.setText("")
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 467, 23))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        self.refresh_button.clicked.connect(MainWindow.reFresh)
        self.autoSelect_button.clicked.connect(MainWindow.autoSelect)
        self.login_label.clicked.connect(MainWindow.login)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.account_lineEdit.setPlaceholderText(_translate("MainWindow", "请在此处输入你的12306账号"))
        self.password_label.setText(_translate("MainWindow", "Password"))
        self.login_label.setText(_translate("MainWindow", "Login"))
        self.password_lineEdit.setPlaceholderText(_translate("MainWindow", "请在此输入你的12306密码"))
        self.picture_label.setText(_translate("MainWindow", "验证码图片"))
        self.account_label.setText(_translate("MainWindow", "Account"))
        self.refresh_button.setText(_translate("MainWindow", "Refresh"))
        self.autoSelect_button.setText(_translate("MainWindow", "AutoSelect"))