本文整理汇总了Python中PyQt5.QtWidgets.QProgressBar.isVisible方法的典型用法代码示例。如果您正苦于以下问题:Python QProgressBar.isVisible方法的具体用法?Python QProgressBar.isVisible怎么用?Python QProgressBar.isVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QProgressBar
的用法示例。
在下文中一共展示了QProgressBar.isVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CueWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import isVisible [as 别名]
#.........这里部分代码省略.........
def _update_description(self, description):
self.nameButton.setToolTip(description)
def _clicked(self, event):
if not self.seekSlider.geometry().contains(event.pos()):
if event.button() != Qt.RightButton:
if event.modifiers() == Qt.ShiftModifier:
self.edit_request.emit(self.cue)
elif event.modifiers() == Qt.ControlModifier:
self.selected = not self.selected
else:
self.cue_executed.emit(self.cue)
self.cue.execute()
def _update_style(self, stylesheet):
stylesheet += 'text-decoration: underline;' if self.selected else ''
self.nameButton.setStyleSheet(stylesheet)
def _enter_fadein(self):
p = self.timeDisplay.palette()
p.setColor(p.WindowText, QColor(0, 255, 0))
self.timeDisplay.setPalette(p)
def _enter_fadeout(self):
p = self.timeDisplay.palette()
p.setColor(p.WindowText, QColor(255, 50, 50))
self.timeDisplay.setPalette(p)
def _exit_fade(self):
self.timeDisplay.setPalette(self.timeBar.palette())
def _status_stopped(self):
self.statusIcon.setPixmap(CueWidget.STOP.pixmap(CueWidget.ICON_SIZE,
CueWidget.ICON_SIZE))
self._update_time(0, True)
def _status_playing(self):
self.statusIcon.setPixmap(CueWidget.START.pixmap(CueWidget.ICON_SIZE,
CueWidget.ICON_SIZE))
def _status_paused(self):
self.statusIcon.setPixmap(CueWidget.PAUSE.pixmap(CueWidget.ICON_SIZE,
CueWidget.ICON_SIZE))
def _status_error(self, cue, error, details):
self.statusIcon.setPixmap(CueWidget.ERROR.pixmap(CueWidget.ICON_SIZE,
CueWidget.ICON_SIZE))
QDetailedMessageBox.dcritical(self.cue.name, error, details)
def _update_duration(self, duration):
# Update the maximum values of seek-slider and time progress-bar
if duration > 0:
if not self.timeBar.isVisible():
self.layout().addWidget(self.timeBar, 1, 0, 1, 2)
self.layout().setRowStretch(1, 1)
self.timeBar.show()
self.timeBar.setMaximum(duration)
self.seekSlider.setMaximum(duration)
else:
self.timeBar.hide()
self.layout().setRowStretch(1, 0)
# If not in playing or paused update the widget showed time
if self.cue.state != CueState.Running or self.cue.state != CueState.Running:
self._update_time(duration, True)
def _update_time(self, time, ignore_visibility=False):
if ignore_visibility or not self.visibleRegion().isEmpty():
# If the given value is the duration or < 0 set the time to 0
if time == self.cue.duration or time < 0:
time = 0
# Set the value the seek slider
self.seekSlider.setValue(time)
# If in count-down mode the widget will show the remaining time
if self._countdown_mode:
time = self.cue.duration - time
# Set the value of the timer progress-bar
if self.cue.duration > 0:
self.timeBar.setValue(time)
# Show the time in the widget
self.timeDisplay.display(strtime(time, accurate=self._accurate_timing))
def resizeEvent(self, event):
self.update()
def update(self):
super().update()
self.layout().activate()
xdim = self.nameButton.width()
ydim = self.nameButton.height() / 5
ypos = self.nameButton.height() - ydim
self.seekSlider.setGeometry(0, ypos, xdim, ydim)
self.statusIcon.setGeometry(4, 4, CueWidget.ICON_SIZE,
CueWidget.ICON_SIZE)
示例2: XNCStatusBar
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import isVisible [as 别名]
class XNCStatusBar(QStatusBar):
def __init__(self, parent=None):
super(XNCStatusBar, self).__init__(parent)
# state vars
self.world = XNovaWorld_instance()
# initialization
self.setSizeGripEnabled(True)
# sub-widgets
# progressbar
self._progressbar = QProgressBar(self)
self._progressbar.hide()
self._progressbar.setValue(0)
self._progressbar.setRange(0, 99)
# online players counter
self._lbl_online = QLabel(self.tr('Online') + ': 0', self)
# label with loading.gif
self._loading_gif = QMovie(':/i/loading.gif')
self._lbl_loading = QLabel(self)
self._lbl_loading.setMovie(self._loading_gif)
self._lbl_loading.hide()
# testing only
self._btn_runscript = QPushButton('Run script', self)
self._btn_runscript.clicked.connect(self.on_run_script)
self.addPermanentWidget(self._btn_runscript)
#
self.addPermanentWidget(self._lbl_loading)
self.addPermanentWidget(self._lbl_online) # should be las right widget
self.show()
def set_status(self, msg: str, timeout: int=0):
self.showMessage(msg, timeout)
def set_loading_status(self, loading: bool):
if loading:
self._lbl_loading.show()
self._loading_gif.start()
else:
self._loading_gif.stop()
self._lbl_loading.hide()
def set_world_load_progress(self, comment: str, progress: int):
"""
Display world load progress in status bar
:param comment: string comment of what is currently loading
:param progress: percent progress, or -1 to disable
"""
if progress != -1:
if not self._progressbar.isVisible():
self.insertPermanentWidget(0, self._progressbar)
self._progressbar.show()
msg = self.tr('Loading world') + ' ({0}%) {1}...'.format(progress, comment)
logger.debug(msg)
self._progressbar.setValue(progress)
self.set_status(msg)
else:
self.removeWidget(self._progressbar)
self._progressbar.hide()
self._progressbar.reset()
self.clearMessage()
def update_online_players_count(self):
op = self.world.get_online_players()
self._lbl_online.setText(self.tr('Online') + ': {0}'.format(op))
# some functions may be useful, documentation:
# void QStatusBar::clearMessage()
# void QStatusBar::addPermanentWidget(QWidget * widget, int stretch = 0)
# void QStatusBar::addWidget(QWidget * widget, int stretch = 0)
# void QStatusBar::removeWidget(QWidget * widget)
@pyqtSlot()
def on_run_script(self):
files = os.listdir('scripts')
files.sort()
script_files = [fn for fn in files if fn[0] != '.' and fn.endswith('.py')]
# print(script_files)
menu = QMenu(self)
for script_filename in script_files:
act = QAction(menu)
act.setText('Run "scripts/' + script_filename + '"...')
act.setData('scripts/' + script_filename)
menu.addAction(act)
act_ret = menu.exec(QCursor.pos())
if act_ret is None:
return
script_filename = str(act_ret.data())
s = ''
try:
with open(script_filename, 'rt', encoding='utf-8') as f:
s = f.read()
except IOError:
pass
if s != '':
exec(s)