def setListViews(self): """定义承载功能的ListView""" self.navigationList = QListWidget() self.navigationList.setMaximumHeight(110) self.navigationList.setObjectName("navigationList") self.navigationList.addItem(QListWidgetItem(QIcon('resource/music.png'), " 发现音乐")) self.navigationList.addItem(QListWidgetItem(QIcon('resource/signal.png'), " 私人FM")) self.navigationList.addItem(QListWidgetItem(QIcon('resource/movie.png'), " MV")) self.navigationList.setCurrentRow(0) self.nativeList = QListWidget() self.nativeList.setObjectName("nativeList") self.nativeList.setMaximumHeight(80) self.nativeList.addItem(QListWidgetItem(QIcon('resource/notes.png')," 本地音乐")) self.nativeList.addItem(QListWidgetItem(QIcon('resource/download_icon.png'), " 我的下载"))
def setListViews(self): """定义承载功能的ListView""" self.navigationList = QListWidget() self.navigationList.setMaximumHeight(110) self.navigationList.setObjectName("navigationList") self.navigationList.addItem(QListWidgetItem(QIcon('resource/music.png'), " 发现音乐")) self.navigationList.addItem(QListWidgetItem(QIcon('resource/signal.png'), " 私人FM")) self.navigationList.addItem(QListWidgetItem(QIcon('resource/movie.png'), " MV")) self.navigationList.setCurrentRow(0) self.nativeList = QListWidget() self.nativeList.setObjectName("nativeList") self.nativeList.setMaximumHeight(100) self.nativeList.addItem(QListWidgetItem(QIcon('resource/notes.png')," 本地音乐")) self.nativeList.addItem(QListWidgetItem(QIcon('resource/download_icon.png'), " 我的下载")) self.nativeList.addItem(QListWidgetItem(QIcon('resource/recommend_icon.png'), " 专属推荐"))
class Navigation(QScrollArea): def __init__(self, parent=None): """包括发现音乐,MV,我的音乐, 歌单等导航信息。""" super(Navigation, self).__init__(parent) self.parent = parent self.frame = QFrame() # self.setMaximumHeight(576) self.setMaximumWidth(200) self.setWidget(self.frame) self.setWidgetResizable(True) # self.frame.setMaximumWidth(200) self.frame.setMinimumWidth(200) # 定义3个事件函数,方便扩展。 self.navigationListFunction = self.none self.nativeListFunction = self.none self.singsFunction = self.none with open('QSS/navigation.qss', 'r') as f: style = f.read() self.setStyleSheet(style) self.frame.setStyleSheet(style) # 包括显示信息: 推荐 我的音乐 歌单。 self.setLabels() # 包括详细的内容:发现音乐,FM,MV等。 self.setListViews() self.setLayouts() # 布局。 def setLabels(self): """定义所有的标签。""" self.recommendLabel = QLabel(" 推荐") self.recommendLabel.setObjectName("recommendLabel") self.recommendLabel.setMaximumHeight(27) self.myMusic = QLabel(" 我的音乐") self.myMusic.setObjectName("myMusic") self.myMusic.setMaximumHeight(27) self.singsListLabel = QLabel(" 收藏与创建的歌单") self.singsListLabel.setObjectName("singsListLabel") self.singsListLabel.setMaximumHeight(27) def setListViews(self): """定义承载功能的ListView""" self.navigationList = QListWidget() # self.navigationList.setMinimumHeight(110) self.navigationList.setMaximumHeight(110) self.navigationList.setObjectName("navigationList") self.navigationList.addItem( QListWidgetItem(QIcon('resource/music.png'), " 发现音乐")) self.navigationList.addItem( QListWidgetItem(QIcon('resource/signal.png'), " 私人FM")) self.navigationList.addItem( QListWidgetItem(QIcon('resource/movie.png'), " MV")) self.navigationList.setCurrentRow(0) self.nativeList = QListWidget() self.nativeList.setObjectName("nativeList") # self.nativeList.setMinimumHeight(50) self.nativeList.setMaximumHeight(50) self.nativeList.addItem( QListWidgetItem(QIcon('resource/notes.png'), " 本地音乐")) def setLayouts(self): """定义布局。""" self.mainLayout = VBoxLayout(self.frame) self.mainLayout.addSpacing(10) self.mainLayout.addWidget(self.recommendLabel) self.mainLayout.addSpacing(3) self.mainLayout.addWidget(self.navigationList) self.mainLayout.addSpacing(1) self.mainLayout.addWidget(self.myMusic) self.mainLayout.addSpacing(3) self.mainLayout.addWidget(self.nativeList) self.mainLayout.addSpacing(1) self.mainLayout.addWidget(self.singsListLabel) self.mainLayout.addSpacing(1) self.mainLayout.addStretch(1) self.setContentsMargins(0, 0, 0, 0) # just a test. def setSingsList(self): pass # 功能。 def none(self): # 没有用的空函数。 pass
class Navigation(QScrollArea): def __init__(self, parent=None): """包括发现音乐,MV,我的音乐, 歌单等导航信息。""" super(Navigation, self).__init__(parent) self.parent = parent self.frame = QFrame() self.setMaximumWidth(200) self.setWidget(self.frame) self.setWidgetResizable(True) self.frame.setMinimumWidth(200) # 定义3个事件函数,方便扩展。 self.navigationListFunction = self.none self.nativeListFunction = self.none self.singsFunction = self.none with open('QSS/navigation.qss', 'r') as f: style = f.read() self.setStyleSheet(style) self.frame.setStyleSheet(style) # 包括显示信息: 推荐 我的音乐 歌单。 self.setLabels() # 包括详细的内容:发现音乐,FM,MV等。 self.setListViews() self.setLayouts() # 布局。 def setLabels(self): """定义所有的标签。""" self.recommendLabel = QLabel(" 推荐") self.recommendLabel.setObjectName("recommendLabel") self.recommendLabel.setMaximumHeight(27) self.myMusic = QLabel(" 我的音乐") self.myMusic.setObjectName("myMusic") self.myMusic.setMaximumHeight(27) # self.myMusic.setMaximumHeight(54) self.singsListLabel = QLabel(" 收藏与创建的歌单") self.singsListLabel.setObjectName("singsListLabel") self.singsListLabel.setMaximumHeight(27) def setListViews(self): """定义承载功能的ListView""" self.navigationList = QListWidget() self.navigationList.setMaximumHeight(110) self.navigationList.setObjectName("navigationList") self.navigationList.addItem(QListWidgetItem(QIcon('resource/music.png'), " 发现音乐")) self.navigationList.addItem(QListWidgetItem(QIcon('resource/signal.png'), " 私人FM")) self.navigationList.addItem(QListWidgetItem(QIcon('resource/movie.png'), " MV")) self.navigationList.setCurrentRow(0) self.nativeList = QListWidget() self.nativeList.setObjectName("nativeList") self.nativeList.setMaximumHeight(100) self.nativeList.addItem(QListWidgetItem(QIcon('resource/notes.png')," 本地音乐")) self.nativeList.addItem(QListWidgetItem(QIcon('resource/download_icon.png'), " 我的下载")) self.nativeList.addItem(QListWidgetItem(QIcon('resource/recommend_icon.png'), " 专属推荐")) def setLayouts(self): """定义布局。""" self.mainLayout = VBoxLayout(self.frame) self.mainLayout.addSpacing(10) self.mainLayout.addWidget(self.recommendLabel) self.mainLayout.addSpacing(3) self.mainLayout.addWidget(self.navigationList) self.mainLayout.addSpacing(1) self.mainLayout.addWidget(self.myMusic) self.mainLayout.addSpacing(3) self.mainLayout.addWidget(self.nativeList) self.mainLayout.addSpacing(1) self.mainLayout.addWidget(self.singsListLabel) self.mainLayout.addSpacing(1) self.mainLayout.addStretch(1) self.setContentsMargins(0, 0, 0, 0) # just a test. def setSingsList(self): pass # 功能。 def none(self): # 没有用的空函数。 pass