class NetEaseSearchResultFrame(QFrame): def __init__(self, parent): super(NetEaseSearchResultFrame, self).__init__() self.parent = parent # self.singsFrame = QFrame() self.singsFrameLayout = VBoxLayout(self) self.noSingsContentsLabel = QLabel(self) self.noSingsContentsLabel.setMaximumHeight(60) self.noSingsContentsLabel.setObjectName("noSingsLable") self.noSingsContentsLabel.hide() self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsResultTable.setObjectName('singsTable') self.singsResultTable.setMinimumWidth(self.parent.width()) self.singsResultTable.setColumnWidths({ i: j for i, j in zip(range(3), [ self.parent.width() / 3 * 1.25, self.parent.width() / 3 * 1.25, self.parent.width() / 3 * 0.5 ]) }) self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop | Qt.AlignCenter) self.centerLabelLayout = HBoxLayout() self.centerLabelLayout.addStretch(1) self.centerLabelLayout.addWidget(self.noSingsContentsLabel) self.centerLabelLayout.addStretch(1) self.singsFrameLayout.addLayout(self.centerLabelLayout)
class SingsSearchResultFrameBase(QFrame): def __init__(self, parent): super(SingsSearchResultFrameBase, self).__init__() self.parent = parent self.singsFrameLayout = VBoxLayout(self) self.noSingsContentsLabel = QLabel(self) self.noSingsContentsLabel.setMaximumHeight(60) self.noSingsContentsLabel.setObjectName("noSingsLable") self.noSingsContentsLabel.hide() self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsResultTable.setObjectName('singsTable') self.singsResultTable.setMinimumWidth(self.parent.width()) self.singsResultTable.setColumnWidths({i:j for i,j in zip(range(3), [self.parent.width()/3*1.25,self.parent.width()/3*1.25,self.parent.width()/3*0.5])}) self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop|Qt.AlignCenter) self.centerLabelLayout = HBoxLayout() self.centerLabelLayout.addStretch(1) self.centerLabelLayout.addWidget(self.noSingsContentsLabel) self.centerLabelLayout.addStretch(1) self.singsFrameLayout.addLayout(self.centerLabelLayout)
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)
class SearchArea(ScrollArea): def __init__(self, parent=None): super(SearchArea, self).__init__(self) self.parent = parent self.setObjectName("searchArea") with open('QSS/searchArea.qss', 'r', encoding='utf-8') as f: self.setStyleSheet(f.read()) self.mainLayout = QVBoxLayout(self.frame) self.titleLabel = QLabel(self.frame) # 搜索结果的tab。 self.contentsTab = QTabWidget(self.frame) # 加入布局。 self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.contentsTab) self.setSingsFrame() # 布局。 def setSingsFrame(self): # 单曲界面。 self.singsFrame = QFrame() self.singsFrameLayout = VBoxLayout(self.singsFrame) self.noSingsContentsLabel = QLabel(self.singsFrame) self.noSingsContentsLabel.setMaximumHeight(60) self.noSingsContentsLabel.setObjectName("noSingsLable") self.noSingsContentsLabel.hide() self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsResultTable.setObjectName('singsTable') self.singsResultTable.setMinimumWidth(self.width()) self.singsResultTable.setColumnWidths({ i: j for i, j in zip(range(3), [ self.width() / 3 * 1.25, self.width() / 3 * 1.25, self.width() / 3 * 0.5 ]) }) self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop | Qt.AlignCenter) self.centerLabelLayout = HBoxLayout() self.centerLabelLayout.addStretch(1) self.centerLabelLayout.addWidget(self.noSingsContentsLabel) self.centerLabelLayout.addStretch(1) self.singsFrameLayout.addLayout(self.centerLabelLayout) self.contentsTab.addTab(self.singsFrame, "单曲") # 功能。 def setText(self, text): self.text = text self.titleLabel.setText( "搜索<font color='#23518F'>“{0}”</font><br>".format(self.text))
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)