本文整理汇总了Python中PyQt5.QtWidgets.QDockWidget.width方法的典型用法代码示例。如果您正苦于以下问题:Python QDockWidget.width方法的具体用法?Python QDockWidget.width怎么用?Python QDockWidget.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QDockWidget
的用法示例。
在下文中一共展示了QDockWidget.width方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MusicPlayer
# 需要导入模块: from PyQt5.QtWidgets import QDockWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QDockWidget import width [as 别名]
#.........这里部分代码省略.........
elif self.playlist.playbackMode() == QMediaPlaylist.Loop:
self.playlist.setPlaybackMode(QMediaPlaylist.CurrentItemInLoop)
repeat_on_icon = utilities.resource_filename('mosaic.images', 'md_repeat_once.png')
self.repeat_action.setIcon(QIcon(repeat_on_icon))
elif self.playlist.playbackMode() == QMediaPlaylist.CurrentItemInLoop:
self.playlist.setPlaybackMode(QMediaPlaylist.Random)
repeat_icon = utilities.resource_filename('mosaic.images', 'md_shuffle.png')
self.repeat_action.setIcon(QIcon(repeat_icon))
elif self.playlist.playbackMode() == QMediaPlaylist.Random:
self.playlist.setPlaybackMode(QMediaPlaylist.Sequential)
repeat_icon = utilities.resource_filename('mosaic.images', 'md_repeat_none.png')
self.repeat_action.setIcon(QIcon(repeat_icon))
def activate_playlist_item(self, item):
"""Set the active media to the playlist item dobule-clicked on by the user."""
current_index = self.playlist_view.row(item)
if self.playlist.currentIndex() != current_index:
self.playlist.setCurrentIndex(current_index)
if self.player.state() != QMediaPlayer.PlayingState:
self.player.play()
def change_index(self, row):
"""Highlight the row in the playlist of the active media."""
self.playlist_view.setCurrentRow(row)
def minimalist_view(self):
"""Resize the window to only show the menu bar and audio controls."""
if self.minimalist_view_action.isChecked():
if self.playlist_dock.isVisible():
self.playlist_dock_state = True
if self.library_dock.isVisible():
self.library_dock_state = True
self.library_dock.close()
self.playlist_dock.close()
QTimer.singleShot(10, lambda: self.resize(500, 0))
else:
self.resize(defaults.Settings().window_size, defaults.Settings().window_size + 63)
if self.library_dock_state:
self.library_dock.setVisible(True)
if self.playlist_dock_state:
self.playlist_dock.setVisible(True)
def dock_visiblity_change(self, visible):
"""Change the size of the main window when the docks are toggled."""
if visible and self.playlist_dock.isVisible() and not self.library_dock.isVisible():
self.resize(defaults.Settings().window_size + self.playlist_dock.width() + 6,
self.height())
elif visible and not self.playlist_dock.isVisible() and self.library_dock.isVisible():
self.resize(defaults.Settings().window_size + self.library_dock.width() + 6,
self.height())
elif visible and self.playlist_dock.isVisible() and self.library_dock.isVisible():
self.resize(defaults.Settings().window_size + self.library_dock.width() + 6,
self.height())
elif (not visible and not self.playlist_dock.isVisible() and not
self.library_dock.isVisible()):
self.resize(defaults.Settings().window_size, defaults.Settings().window_size + 63)
def media_information_dialog(self):
"""Show a dialog of the current song's metadata."""
if self.player.isMetaDataAvailable():
file_path = self.player.currentMedia().canonicalUrl().toLocalFile()
else:
file_path = None
dialog = information.InformationDialog(file_path)
dialog.exec_()
def change_window_size(self):
"""Change the window size of the music player."""
self.playlist_dock.close()
self.library_dock.close()
self.resize(defaults.Settings().window_size, defaults.Settings().window_size + 63)
def change_media_library_path(self, path):
"""Change the media library path to the new path selected in the preferences dialog."""
self.library_model.setRootPath(path)
self.library_view.setModel(self.library_model)
self.library_view.setRootIndex(self.library_model.index(path))
def closeEvent(self, event):
"""Override the PyQt close event in order to handle save playlist on close."""
playlist = "{}/.m3u" .format(self.playlist_location)
if defaults.Settings().save_playlist_on_close:
self.playlist.save(QUrl().fromLocalFile(playlist), "m3u")
else:
if os.path.exists(playlist):
os.remove(playlist)
QApplication.quit()