我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用PyQt5.QtGui.QMovie()。
def initVLC(self, config): self.instance = vlc.Instance() self.mediaplayer = self.instance.media_player_new() # self.mediaplayer_list = self.instance.media_list_player_new() self.mediaplayer.audio_set_volume(config['default_volume']) self.media_event = self.mediaplayer.event_manager() self.media_event.event_attach(vlc.EventType.MediaPlayerEndReached, self.SongFinished, 1) self.media_event.event_attach(vlc.EventType.MediaPlayerMediaChanged, self.nextItemSet, 1) # self.media_event.event_attach(vlc.EventType.MediaPlayerTimeChanged, self.vlc_time_changed, self.mediaplayer) logging.getLogger("vlc").setLevel(logging.NOTSET) logging.getLogger("mpgatofixed32").setLevel(logging.NOTSET) logging.getLogger("core vout").setLevel(logging.NOTSET) gifpath = os.path.join("app", "images", "player", "animation.gif") self.labelframe = QLabel(self.parent) self.labelframe.setScaledContents(True) self.labelframe.setFrameStyle(QFrame.Panel | QFrame.Sunken) self.anim = QMovie(gifpath) self.labelframe.setMovie(self.anim) self.parent.framelayout.addWidget(self.labelframe) self.labelframe.hide() self.musicplayed = False
def __init__(self, text="Loading..."): super(MessageBox, self).__init__() self.setWindowTitle("Messages") self.setLayout(QtWidgets.QHBoxLayout()) self._layout = self.layout() self._gif = QtWidgets.QLabel() movie = QtGui.QMovie("loading.gif") self._gif.setMovie(movie) movie.start() self._layout.addWidget(self._gif) self._message = QtWidgets.QLabel() self._message.setText(text) self._layout.addWidget(self._message) self.setObjectName('Message_Window')
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) # Layout self.runmenulayout = QtWidgets.QVBoxLayout() # Widget self.runmenuLabel = QtWidgets.QLabel() self.runmenuLabel.setText("Task is running\nPlease wait...") # self.runmenuMovieLabel = QtWidgets.QLabel() # self.runmenuMovie = QtGui.QMovie(":/resources/runmenu.gif") # self.runmenuMovieLabel.setMovie(self.runmenuMovie) # self.runmenuMovieLabel.show() # Add Widget self.runmenulayout.addWidget(self.runmenuLabel) # self.runmenulayout.addWidget(self.runmenuMovieLabel) # Set layout self.runmenulayout.setAlignment(QtCore.Qt.AlignCenter) self.runmenulayout.setSpacing(0) self.runmenulayout.setContentsMargins(10, 0, 10, 0) self.setLayout(self.runmenulayout) # Stylesheet self.setStyleSheet("QLabel{background:transparent; color:#3d5159; font-family:'Segoe UI'; font-size:13pt; border:none;}")
def initNoVideo(self) -> None: self.novideoWidget = QWidget(self) self.novideoWidget.setObjectName('novideoWidget') self.novideoWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) self.novideoLabel = QLabel(self) self.novideoLabel.setAlignment(Qt.AlignCenter) self.novideoMovie = QMovie(':/images/novideotext.gif', b'GIF', self) self.novideoMovie.setScaledSize(QSize(250, 30)) self.novideoMovie.frameChanged.connect(lambda: self.novideoLabel.setPixmap(self.novideoMovie.currentPixmap())) self.novideoMovie.start() novideoLayout = QVBoxLayout() novideoLayout.addStretch(3) novideoLayout.addWidget(self.novideoLabel) novideoLayout.addStretch(1) self.novideoWidget.setLayout(novideoLayout)
def images_loaded(self, result): self.midLabel.setText("Last submitted pack:") for (card, filename), label in zip(result, self.cardLabels): label.card = card if card.golden: res = QtGui.QMovie(filename) label.card_data = res label.setMovie(res) res.start() else: res = QtGui.QPixmap(filename) label.card_data = res label.setPixmap(res) label.show()
def __init__(self, parent=None, *args, **kwargs): super(WaitDialog, self).__init__(parent) self.label = QLabel(self) self.label.setAlignment(Qt.AlignCenter) self.setFixedSize(551, 401) self.setWindowOpacity(0.5) # set transparent self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) # background transparent self.setContentsMargins(0, 0, 0, 0) config = Config() self.movie = QMovie(os.path.join(config.images, 'wait.gif')) self.label.setMovie(self.movie) self.movie.start()
def setup_loading_gif(self): """Creates the loading gear as QMovie and its label.""" self.movie = QtGui.QMovie(self) self.movie.setFileName("ui/res/loading.gif") self.movie.setCacheMode(QtGui.QMovie.CacheAll) self.movie.start() self.loading = QtWidgets.QLabel(self) self.loading.setAlignment(QtCore.Qt.AlignCenter) self.loading.setMovie(self.movie) self.loading.hide()