def setup_ui(self): self.setObjectName('playbackPage') #歌手信息页 self.artistHeadLabel = QLabel(self) self.artistHeadLabel.setFixedSize(QSize(90, 90)) self.artistHeadLabel.setScaledContents(True) self.artistName = NewLabel(self, True) self.artistName.setFixedSize(QSize(90, 30)) self.artistGender = QLabel("性别:未知", self) self.artistBirthday = QLabel("生日:未知", self) self.artistConstellation = QLabel("星座:未知", self) self.artistLanguage = QLabel("语言:未知", self) self.artistBirthplace = QLabel("出生地:未知", self) self.artistDetail = MyTextEdit(self) #刷新歌手信息缓存按键 self.refreshBtn = QPushButton(self) self.refreshBtn.setFocusPolicy(Qt.NoFocus) self.refreshBtn.setIcon(QIcon(IconsHub.Refresh)) self.refreshBtn.setText('刷新') self.refreshBtn.setToolTip("刷新歌手信息") self.refreshBtn.setFixedSize(QSize(70, 30)) vbox1 = QVBoxLayout() vbox1.setSpacing(10) vbox1.addWidget(self.artistHeadLabel) vbox1.addWidget(self.artistName) hbox1 = QHBoxLayout() hbox1.addWidget(self.artistGender) hbox1.addWidget(self.artistBirthday) hbox2 = QHBoxLayout() hbox2.addWidget(self.artistConstellation) hbox2.addWidget(self.artistLanguage) hbox3 = QHBoxLayout() hbox3.addWidget(self.artistBirthplace) hbox3.addWidget(self.refreshBtn) vbox2 = QVBoxLayout() vbox2.addLayout(hbox1) vbox2.addLayout(hbox2) vbox2.addLayout(hbox3) hbox4 = QHBoxLayout() hbox4.setSpacing(30) hbox4.addLayout(vbox1) hbox4.addLayout(vbox2) mainLayout = QVBoxLayout(self) mainLayout.addLayout(hbox4) mainLayout.addWidget(self.artistDetail)
class ArtistInfoPage(QWidget): def __init__(self, parent=None): super(ArtistInfoPage, self).__init__(parent) self.setup_ui() self.create_connections() def setup_ui(self): self.setObjectName('playbackPage') #歌手信息页 self.artistHeadLabel = QLabel(self) self.artistHeadLabel.setFixedSize(QSize(90, 90)) self.artistHeadLabel.setScaledContents(True) self.artistName = NewLabel(self, True) self.artistName.setFixedSize(QSize(90, 30)) self.artistGender = QLabel("性别:未知", self) self.artistBirthday = QLabel("生日:未知", self) self.artistConstellation = QLabel("星座:未知", self) self.artistLanguage = QLabel("语言:未知", self) self.artistBirthplace = QLabel("出生地:未知", self) self.artistDetail = MyTextEdit(self) #刷新歌手信息缓存按键 self.refreshBtn = QPushButton(self) self.refreshBtn.setFocusPolicy(Qt.NoFocus) self.refreshBtn.setIcon(QIcon(IconsHub.Refresh)) self.refreshBtn.setText('刷新') self.refreshBtn.setToolTip("刷新歌手信息") self.refreshBtn.setFixedSize(QSize(70, 30)) vbox1 = QVBoxLayout() vbox1.setSpacing(10) vbox1.addWidget(self.artistHeadLabel) vbox1.addWidget(self.artistName) hbox1 = QHBoxLayout() hbox1.addWidget(self.artistGender) hbox1.addWidget(self.artistBirthday) hbox2 = QHBoxLayout() hbox2.addWidget(self.artistConstellation) hbox2.addWidget(self.artistLanguage) hbox3 = QHBoxLayout() hbox3.addWidget(self.artistBirthplace) hbox3.addWidget(self.refreshBtn) vbox2 = QVBoxLayout() vbox2.addLayout(hbox1) vbox2.addLayout(hbox2) vbox2.addLayout(hbox3) hbox4 = QHBoxLayout() hbox4.setSpacing(30) hbox4.addLayout(vbox1) hbox4.addLayout(vbox2) mainLayout = QVBoxLayout(self) mainLayout.addLayout(hbox4) mainLayout.addWidget(self.artistDetail) def create_connections(self): self.refreshBtn.clicked.connect(self.update_infofile_cached) def set_artist_info(self, artist): if artist == 'Zheng-Yejian': self.ui_initial() elif artist != self.artistName.text(): infoPath = SearchOnline.get_artist_info_path(artist) infoDict = parse_artist_info(infoPath) self.artistName.setText(artist) self.artistBirthday.setText('生日:%s' % infoDict['birthday']) self.artistBirthplace.setText('出生地:%s' % infoDict['birthplace']) self.artistLanguage.setText('语言:%s' % infoDict['language']) self.artistGender.setText('性别:%s' % infoDict['gender']) self.artistConstellation.setText('星座:%s' % infoDict['constellation']) self.artistDetail.clear() self.artistDetail.setAlignment(Qt.AlignHCenter) self.artistDetail.setHtml( self.get_artist_detail_style_text(infoDict['info'])) imagePath = SearchOnline.get_artist_image_path(artist) if imagePath: pixmap = QPixmap(imagePath) else: pixmap = QPixmap(IconsHub.Anonymous) self.artistHeadLabel.setPixmap(pixmap) def update_artist_info(self, title): artist, musicName = get_artist_and_musicname_from_title(title) return self.set_artist_info(artist) def update_infofile_cached(self): artist = self.artistName.text() if artist != '未知': infoPath = SearchOnline.get_local_artist_info_path(artist) if os.path.exists(infoPath): os.remove(infoPath) self.set_artist_info(artist) def ui_initial(self): self.artistHeadLabel.setPixmap(QPixmap(IconsHub.Anonymous)) self.artistName.setText("Zheng-Yejian") self.artistBirthday.setText("生日:1992.10.18") self.artistBirthplace.setText("出生地:福建") self.artistLanguage.setText("语言:国语") self.artistGender.setText("性别:男") self.artistConstellation.setText("星座:天秤座") self.artistDetail.setHtml( self.get_artist_detail_style_text('大家好,我是作者!!!')) def get_artist_detail_style_text(self, text): return "<p style='color:black;font-size:16px;'>%s</p>" % text
class ArtistInfoPage(QWidget): def __init__(self, parent=None): super(ArtistInfoPage, self).__init__(parent) self.setup_ui() self.create_connections() def setup_ui(self): self.setObjectName('playbackPage') #歌手信息页 self.artistHeadLabel = QLabel(self) self.artistHeadLabel.setFixedSize(QSize(90, 90)) self.artistHeadLabel.setScaledContents(True) self.artistName = NewLabel(self, True) self.artistName.setFixedSize(QSize(90, 30)) self.artistGender = QLabel("性别:未知", self) self.artistBirthday = QLabel("生日:未知", self) self.artistConstellation = QLabel("星座:未知", self) self.artistLanguage = QLabel("语言:未知", self) self.artistBirthplace = QLabel("出生地:未知", self) self.artistDetail = MyTextEdit(self) #刷新歌手信息缓存按键 self.refreshBtn = QPushButton(self) self.refreshBtn.setFocusPolicy(Qt.NoFocus) self.refreshBtn.setIcon(QIcon(IconsHub.Refresh)) self.refreshBtn.setText('刷新') self.refreshBtn.setToolTip("刷新歌手信息") self.refreshBtn.setFixedSize(QSize(70, 30)) vbox1 = QVBoxLayout() vbox1.setSpacing(10) vbox1.addWidget(self.artistHeadLabel) vbox1.addWidget(self.artistName) hbox1 = QHBoxLayout() hbox1.addWidget(self.artistGender) hbox1.addWidget(self.artistBirthday) hbox2 = QHBoxLayout() hbox2.addWidget(self.artistConstellation) hbox2.addWidget(self.artistLanguage) hbox3 = QHBoxLayout() hbox3.addWidget(self.artistBirthplace) hbox3.addWidget(self.refreshBtn) vbox2 = QVBoxLayout() vbox2.addLayout(hbox1) vbox2.addLayout(hbox2) vbox2.addLayout(hbox3) hbox4 = QHBoxLayout() hbox4.setSpacing(30) hbox4.addLayout(vbox1) hbox4.addLayout(vbox2) mainLayout = QVBoxLayout(self) mainLayout.addLayout(hbox4) mainLayout.addWidget(self.artistDetail) def create_connections(self): self.refreshBtn.clicked.connect(self.update_infofile_cached) def set_artist_info(self, artist): if artist == 'Zheng-Yejian': self.ui_initial() elif artist != self.artistName.text(): infoPath = SearchOnline.get_artist_info_path(artist) infoDict = parse_artist_info(infoPath) self.artistName.setText(artist) self.artistBirthday.setText('生日:%s'%infoDict['birthday']) self.artistBirthplace.setText('出生地:%s'%infoDict['birthplace']) self.artistLanguage.setText('语言:%s'%infoDict['language']) self.artistGender.setText('性别:%s'%infoDict['gender']) self.artistConstellation.setText('星座:%s'%infoDict['constellation']) self.artistDetail.clear() self.artistDetail.setAlignment(Qt.AlignHCenter) self.artistDetail.setHtml(self.get_artist_detail_style_text(infoDict['info'])) imagePath = SearchOnline.get_artist_image_path(artist) if imagePath: pixmap = QPixmap(imagePath) else: pixmap = QPixmap(IconsHub.Anonymous) self.artistHeadLabel.setPixmap(pixmap) def update_artist_info(self, title): artist, musicName = get_artist_and_musicname_from_title(title) return self.set_artist_info(artist) def update_infofile_cached(self): artist = self.artistName.text() if artist != '未知': infoPath = SearchOnline.get_local_artist_info_path(artist) if os.path.exists(infoPath): os.remove(infoPath) self.set_artist_info(artist) def ui_initial(self): self.artistHeadLabel.setPixmap(QPixmap(IconsHub.Anonymous)) self.artistName.setText("Zheng-Yejian") self.artistBirthday.setText("生日:1992.10.18") self.artistBirthplace.setText("出生地:福建") self.artistLanguage.setText("语言:国语") self.artistGender.setText("性别:男") self.artistConstellation.setText("星座:天秤座") self.artistDetail.setHtml(self.get_artist_detail_style_text('大家好,我是作者!!!')) def get_artist_detail_style_text(self, text): return "<p style='color:black;font-size:16px;'>%s</p>"%text
def setup_ui(self): # self.setStyleSheet("QLabel{font-size:14px;color:white}") self.authorLabel = QLabel('作 者:<a style="color:green" href=https://github.com/Zheng-Yejian>Zheng-Yejian</a>') self.emailLabel = QLabel('邮 箱:<a style="color:green" href="mailto:[email protected]">[email protected]</a>') self.addressLabel = QLabel('链 接:' '<a style="color:green;" href=https://github.com/Zheng-Yejian/xyplayer>软件源码</a>' '<span> </span>' '<a style = "color:green;" href=https://github.com/Zheng-Yejian/xyplayer-package>deb包下载</a>' '<span> </span>' '<a style = "color:green;" href="http://forum.ubuntu.org.cn/viewtopic.php?f=74&t=465335">版本说明</a>') #使用说明 specText = MyTextEdit() specs = ("<p>xyplayer是一款简单的MP3播放器,支持本地音乐管理、在线音乐搜索试听、下载管理、在线升级等功能。</p>" "<p>当前版本: v%s</p>" "<p>软件协议:本软件使用GNU General Public License V3协议发布,详细内容请看”软件协议“一栏以及项目中的LICENSE文件。</p>" "<p>资源版权:本项目的网络资源获取功能是基于kwplayer修改的,获取到的资源(目前主要是图片和MP3文件)同样来自kuwo.cn这个网站," "因使用本程序引起的侵权问题由使用者自己承担。</p>"%app_version ) specText.setText(specs) #感谢页面 thanks = ("<p>谢谢<a style = 'color:green;' href=https://github.com/LiuLang/kwplayer>github.com/LiuLang/kwplayer</a>" "项目的作者,本程序中关于网络资源获取和歌词解码解析的功能是基于kwplayer的代码修改实现的,而且代码管理也是学着您的项目弄的。</p>" "<p>程序的图标有一部分是从网上下载来修改的,感谢这些素材的作者。</p>" "<p>感谢所有给我反馈BUG以及给我提供意见建议的朋友们。</p>") thanksText = MyTextEdit() thanksText.setText(thanks) #软件协议 licenseText = MyTextEdit() with open(Configures.LicenseFile, 'r') as f: licenseText.append(f.read()) cur = licenseText.textCursor() cur.setPosition(0, QTextCursor.MoveAnchor) licenseText.setTextCursor(cur) #tab页 self.tabWidget = QTabWidget() self.tabWidget.addTab(specText, '简介') self.tabWidget.addTab(thanksText, '鸣谢') self.tabWidget.addTab(licenseText, '软件协议') # self.tabWidget.setStyleSheet('QTabWidget::tab-bar{alignment:center}') mainLayout = QVBoxLayout(self) mainLayout.setSpacing(3) mainLayout.setContentsMargins(4, 4, 4, 4) mainLayout.addWidget(self.authorLabel) mainLayout.addWidget(self.emailLabel) mainLayout.addWidget(self.addressLabel) mainLayout.addWidget(self.tabWidget)