Exemple #1
0
class OneSing(QFrame):
    # 大量创建,这样可以省内存。
    __solts__ = ('parent', 'ggparent', 'detailFrame', 'row', 'column', 'ids',
     'picName', 'picLabel', 'nameLabel',
     'mainLayout',
     'mousePos',
     'result','catch',
     'singsIds', 'singsUrls')

    clicked = pyqtSignal(str, str)

    def __init__(self, row, column, ids=None, parent=None, picName=None):
        super(OneSing, self).__init__()

        self.setObjectName('oneSing')
        # 自己的位置信息。
        self.row = row
        self.column = column
        # 歌单号。
        self.ids = str(ids)
        # 大图的缓存名。
        self.picName = picName

        self.setMinimumSize(180, 235)

        self.picLabel = QLabel()
        self.picLabel.setObjectName('picLabel')
        self.picLabel.setMinimumSize(180, 180)
        self.picLabel.setMaximumSize(180, 180)

        self.nameLabel = QLabel()
        self.nameLabel.setMaximumWidth(180)
        self.nameLabel.setWordWrap(True)

        self.mainLayout = QVBoxLayout(self)

        self.mainLayout.addWidget(self.picLabel)
        self.mainLayout.addWidget(self.nameLabel)

    # 功能。
    def setStyleSheets(self, styleSheet=None):
        if styleSheet:
            self.setStyleSheet(styleSheet)

    # 事件。
    def mousePressEvent(self, event):
        # 记录下当前鼠标的位置。
        self.mousePos = QCursor.pos()

    def mouseReleaseEvent(self, event):
        # 先进行判断,防止误点将鼠标移开后还是会判断为已经点击的尴尬。
        if QCursor.pos() != self.mousePos:
            return
        else:
            self.clicked.emit(self.ids, self.picName)
class OneSing(QFrame):
    # 大量创建,这样可以省内存。
    __solts__ = ('parent', 'ggparent', 'detailFrame', 'row', 'column', 'ids',
                 'picName', 'picLabel', 'nameLabel', 'mainLayout', 'mousePos',
                 'result', 'catch', 'singsIds', 'singsUrls')

    clicked = pyqtSignal(int, str)

    def __init__(self, row, column, ids=None, parent=None, picName=None):
        super(OneSing, self).__init__()

        self.setObjectName('oneSing')
        # 自己的位置信息。
        self.row = row
        self.column = column
        # 歌单号。
        self.ids = ids
        # 大图的缓存名。
        self.picName = picName

        self.setMinimumSize(180, 235)

        self.picLabel = QLabel()
        self.picLabel.setObjectName('picLabel')
        self.picLabel.setMinimumSize(180, 180)
        self.picLabel.setMaximumSize(180, 180)

        self.nameLabel = QLabel()
        self.nameLabel.setMaximumWidth(180)
        self.nameLabel.setWordWrap(True)

        self.mainLayout = QVBoxLayout(self)

        self.mainLayout.addWidget(self.picLabel)
        self.mainLayout.addWidget(self.nameLabel)

    # 功能。
    def setStyleSheets(self, styleSheet=None):
        if styleSheet:
            self.setStyleSheet(styleSheet)

    # 事件。
    def mousePressEvent(self, event):
        # 记录下当前鼠标的位置。
        self.mousePos = QCursor.pos()

    def mouseReleaseEvent(self, event):
        # 先进行判断,防止误点将鼠标移开后还是会判断为已经点击的尴尬。
        if QCursor.pos() != self.mousePos:
            return
        else:
            self.clicked.emit(self.ids, self.picName)
Exemple #3
0
class PhoneAndEMailFrame(QFrame):

    def __init__(self, parent=None):
        super(PhoneAndEMailFrame, self).__init__()
        self.parent = parent
        self.resize(520, 300)
        with open('QSS/phoneAndEMailFrame.qss', 'r') as f:

            self.setStyleSheet(f.read())

        self.mainLayout = VBoxLayout(self)

        self.header = Header("用户名", self)
        self.header.setMinimumHeight(40)
        self.header.connectCloseButton(self.parent.accept)
        self.mainLayout.addWidget(self.header)

        self.mainLayout.addStretch(1)

        self.usernameLine = InputLine(self, 220, 32, '请输入用户名')
        self.usernameLine.setObjectName('usernameLine')
        self.usernameCenterBox = HStretchBox(self.mainLayout, self.usernameLine)   
        
        self.mainLayout.addSpacing(10) 
        
        self.passwordLine = InputLine(self, 220, 32, '请输入密码')
        self.passwordLine.setObjectName('passwordLine')
        self.passwordCenterBox = HStretchBox(self.mainLayout, self.passwordLine)
        self.passwordLine.setEchoMode(QLineEdit.Password)

        self.warningIconLabel = QLabel()
        self.warningIconLabel.setObjectName('warningIconLabel')
        self.warningIconLabel.setMaximumSize(14, 14)
        self.warningIconLabel.setMinimumSize(14, 14)
        self.warningIconLabel.hide()
        self.warningLabel = QLabel("请输入用户名")
        self.warningLabel.hide()
        self.warningLabel.setObjectName('warningLabel')

        self.warningCenterBox = HStretchBox(self.mainLayout, self.warningIconLabel, self.warningLabel, 
            behindStretch=2)

        self.mainLayout.addSpacing(30) 

        self.enterLoginButton = QPushButton("登 录")
        self.enterLoginButton.setObjectName("enterButton")
        self.enterLoginButton.setMaximumSize(217, 27)
        self.enterLoginButton.setMinimumSize(217, 27)
        self.enterLoginCenterBox = HStretchBox(self.mainLayout, self.enterLoginButton)

        self.mainLayout.addSpacing(30)
        
        self.mainLayout.addStretch(1)

    def checkAndGetLoginInformation(self):
        username = self.usernameLine.text()
        password = self.passwordLine.text()
        
        if not username or not password:
            self.warningIconLabel.show()

        if not username:
            self.warningLabel.setText('请输入用户名')
            self.warningLabel.show()
            return False

        if not password:
            self.warningLabel.setText('请输入密码')
            self.warningLabel.show()
            return False

        self.warningIconLabel.hide()
        self.warningLabel.hide()

        return username, password

    def setWarningAndShowIt(self, warningStr):
        self.warningLabel.setText(warningStr)

        self.warningLabel.show()
        self.warningIconLabel.show()

    def connectLogin(self, functionName):
        self.enterLoginButton.clicked.connect(functionName)
Exemple #4
0
class PhoneAndEMailFrame(QFrame):
    def __init__(self, parent=None):
        super(PhoneAndEMailFrame, self).__init__()
        self.parent = parent
        self.resize(520, 300)
        with open('QSS/phoneAndEMailFrame.qss', 'r') as f:

            self.setStyleSheet(f.read())

        self.mainLayout = VBoxLayout(self)

        self.header = Header("用户名", self)
        self.header.setMinimumHeight(40)
        self.header.connectCloseButton(self.parent.accept)
        self.mainLayout.addWidget(self.header)

        self.mainLayout.addStretch(1)

        self.usernameLine = InputLine(self, 220, 32, '请输入用户名')
        self.usernameLine.setObjectName('usernameLine')
        self.usernameCenterBox = HStretchBox(self.mainLayout,
                                             self.usernameLine)

        self.mainLayout.addSpacing(10)

        self.passwordLine = InputLine(self, 220, 32, '请输入密码')
        self.passwordLine.setObjectName('passwordLine')
        self.passwordCenterBox = HStretchBox(self.mainLayout,
                                             self.passwordLine)
        self.passwordLine.setEchoMode(QLineEdit.Password)

        self.warningIconLabel = QLabel()
        self.warningIconLabel.setObjectName('warningIconLabel')
        self.warningIconLabel.setMaximumSize(14, 14)
        self.warningIconLabel.setMinimumSize(14, 14)
        self.warningIconLabel.hide()
        self.warningLabel = QLabel("请输入用户名")
        self.warningLabel.hide()
        self.warningLabel.setObjectName('warningLabel')

        self.warningCenterBox = HStretchBox(self.mainLayout,
                                            self.warningIconLabel,
                                            self.warningLabel,
                                            behindStretch=2)

        self.mainLayout.addSpacing(30)

        self.enterLoginButton = QPushButton("登 录")
        self.enterLoginButton.setObjectName("enterButton")
        self.enterLoginButton.setMaximumSize(217, 27)
        self.enterLoginButton.setMinimumSize(217, 27)
        self.enterLoginCenterBox = HStretchBox(self.mainLayout,
                                               self.enterLoginButton)

        self.mainLayout.addSpacing(30)

        self.mainLayout.addStretch(1)

    def checkAndGetLoginInformation(self):
        username = self.usernameLine.text()
        password = self.passwordLine.text()

        if not username or not password:
            self.warningIconLabel.show()

        if not username:
            self.warningLabel.setText('请输入用户名')
            self.warningLabel.show()
            return False

        if not password:
            self.warningLabel.setText('请输入密码')
            self.warningLabel.show()
            return False

        self.warningIconLabel.hide()
        self.warningLabel.hide()

        return username, password

    def setWarningAndShowIt(self, warningStr):
        self.warningLabel.setText(warningStr)

        self.warningLabel.show()
        self.warningIconLabel.show()

    def connectLogin(self, functionName):
        self.enterLoginButton.clicked.connect(functionName)