本文整理汇总了Python中PyQt5.QtWidgets.QProgressBar.setTextVisible方法的典型用法代码示例。如果您正苦于以下问题:Python QProgressBar.setTextVisible方法的具体用法?Python QProgressBar.setTextVisible怎么用?Python QProgressBar.setTextVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QProgressBar
的用法示例。
在下文中一共展示了QProgressBar.setTextVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LabeledProgressBar
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class LabeledProgressBar(QWidget):
def __init__(self,
label_text="Progress:",
label_font_size=10,
bar_width=100,
use_bar=None,
label_on_left=True,
show_bar_text=False,
*args, **kwargs):
super().__init__(*args, **kwargs)
if use_bar:
self.bar = use_bar
else:
self.bar = QProgressBar(self)
self.bar.reset()
self.bar.setFixedWidth(bar_width)
self.bar.setTextVisible(show_bar_text)
self.label = QLabel(label_text, self)
self.label.setAlignment(Qt.AlignRight)
self.setStyleSheet("QLabel {font-size: %dpt}" % label_font_size)
layout = QHBoxLayout()
layout.setContentsMargins(0,0,0,0)
if label_on_left:
layout.addWidget(self.label)
layout.addWidget(self.bar)
else:
layout.addWidget(self.bar)
layout.addWidget(self.label)
self.setLayout(layout)
@pyqtProperty(int)
def value(self):
return self.bar.value()
@value.setter
def value(self, val):
self.bar.setValue(val)
def setValue(self, progress_value):
self.bar.setValue(progress_value)
@pyqtProperty(str)
def label_text(self):
return self.label.text()
@label_text.setter
def label_text(self, text):
self.label.setText(text)
示例2: PowerIndicator
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class PowerIndicator():
parent = None
progressbar = None
text = None
maxVoltPerCell = 0
minVoltPerCell = 0
fullStyle = "QProgressBar::chunk { background-color: #00EE00; }"
halfStyle = "QProgressBar::chunk { background-color: #FFCC00; }"
emptyStyle = "QProgressBar::chunk { background-color: #FF5050; }"
def __init__(self, parent, minVoltPerCell = 3.2, maxVoltPerCell = 4.2):
self.minVoltPerCell = 3.2
self.maxVoltPerCell = 4.2
self.parent = parent
self.text = QLabel('', parent)
self.progressbar = QProgressBar(parent)
self.progressbar.setMaximumWidth(100)
self.progressbar.setMaximumHeight(10)
self.progressbar.setMaximum(100)
self.progressbar.setMinimum(0)
self.progressbar.setTextVisible(False)
parent.statusBar.addPermanentWidget(self.progressbar)
parent.statusBar.addPermanentWidget(self.text)
def updateProgressBar(self, voltage):
pct = ((voltage - self.minVoltPerCell) / (self.maxVoltPerCell-self.minVoltPerCell))*100
self.progressbar.setValue(pct)
if pct <= 20:
self.progressbar.setStyleSheet(self.emptyStyle)
elif pct <= 50:
self.progressbar.setStyleSheet(self.halfStyle)
else:
self.progressbar.setStyleSheet(self.fullStyle)
def newMessage(self, message, data):
if message == 'POW':
data = data.split()
if len(data) < 2:
return
volts = unpack('!f', bytes.fromhex(data[0]))[0]
amps = unpack('!f', bytes.fromhex(data[1]))[0]
self.text.setText("%.2f V/cell, %.3f A" % (volts/4, amps))
self.updateProgressBar(volts/4)
示例3: qualityWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class qualityWidget(QWidget):
def __init__(self,winParent, laser1, laser2, laser3):
super(qualityWidget, self).__init__()
self.winParent=winParent
self.laser1 = laser1
self.laser2 = laser2
self.laser3 = laser3
self.numCrash = 0
self.MAX_CRASH = 1000
vLayout = QVBoxLayout()
crashLabel = QLabel("Crash:")
self.bar = QProgressBar()
self.bar.setValue(self.numCrash)
st = "QProgressBar::chunk {background-color: #ff0000;}\n QProgressBar {border: 1px solid grey;border-radius: 2px;text-align: center;background: #eeeeee;}"
self.bar.setStyleSheet(st)
self.bar.setTextVisible(False)
vLayout.addWidget(crashLabel, 0)
vLayout.addWidget(self.bar, 0)
vSpacer = QSpacerItem(30, 80, QSizePolicy.Ignored, QSizePolicy.Ignored)
vLayout.addItem(vSpacer)
self.setLayout(vLayout)
def get_laser_distance(self, laser):
DIST = 15
maxAngle = 180
crash = False
for i in range(0, maxAngle+1):
# Distance in millimeters, we change to cm
laserI = float(laser.distanceData[i])/float(10)
if i != 0 and i != 180:
if laserI <= DIST:
crash = True
return crash
def updateG(self):
laser_data_Front = self.laser1.getLaserData()
laser_data_Rear = self.laser2.getLaserData()
laser_data_Right = self.laser3.getLaserData()
crashFront = self.get_laser_distance(laser_data_Front)
crashRear = self.get_laser_distance(laser_data_Rear)
crashRight = self.get_laser_distance(laser_data_Right)
if crashFront or crashRear or crashRight:
self.numCrash = self.numCrash + 1
percentajeCrash = self.numCrash * 100/self.MAX_CRASH
self.bar.setValue(self.numCrash)
self.update()
示例4: setupWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class setupWidget(QWidget):
def __init__(self,parent_):
super(setupWidget,self).__init__(parent_)
self.parent_=parent_
self.initUI()
def initUI(self):
self.pbar = QProgressBar(self)
self.pbar.setObjectName('pbar')
self.pbar.setTextVisible(True)
self.pbar.setFormat('Configuring...')
self.timer = QBasicTimer()
self.step = 0
pixmap=QPixmap(':/Assets/moodly.gif')
lbl=QLabel(self)
lbl.setPixmap(pixmap)
hbox1=QHBoxLayout()
hbox1.addStretch(1)
hbox1.addWidget(lbl)
hbox1.addStretch(1)
hbox2=QHBoxLayout()
hbox2.addStretch(1)
hbox2.addWidget(self.pbar)
hbox2.addStretch(1)
vbox=QVBoxLayout()
vbox.addStretch(8)
vbox.addLayout(hbox1)
vbox.addStretch(1)
vbox.addLayout(hbox2)
vbox.addStretch(8)
self.setLayout(vbox)
self.callTimer()
def timerEvent(self,e):
if self.step>=100:
self.step=0
self.step=self.step+1
self.pbar.setValue(self.step)
def callTimer(self):
self.timer.start(100, self)
示例5: __init__
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
def __init__(self, parent=None):
super().__init__(parent)
main_layout = QVBoxLayout()
info_lbl = QLabel(
"Hi there! Some big changes are about to occur!\n"
+ "Please wait.. This will take at most a few minutes.\n"
+ "If not then try restarting the application."
)
info_lbl.setAlignment(Qt.AlignCenter)
main_layout.addWidget(info_lbl)
prog = QProgressBar(self)
prog.setMinimum(0)
prog.setMaximum(0)
prog.setTextVisible(False)
main_layout.addWidget(prog)
main_layout.addWidget(QLabel("Note: This popup will close itself when everything is ready"))
self.main_widget.setLayout(main_layout)
示例6: BusyProgressDialog
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class BusyProgressDialog(QDialog):
"""
This class implements a dialog showing a busy progress bar.
"""
def __init__(self, title='', parent=None):
"""
Initialize the form dialog.
:type title: str
:type parent: QWidget
"""
super().__init__(parent)
self.progressBar = QProgressBar(self)
self.progressBar.setAlignment(Qt.AlignHCenter)
self.progressBar.setRange(0, 0)
self.progressBar.setFixedSize(300, 30)
self.progressBar.setTextVisible(True)
self.progressBar.setFormat(title or 'Busy ...')
self.mainLayout = QVBoxLayout(self)
self.mainLayout.addWidget(self.progressBar)
self.setWindowIcon(QIcon(':/images/eddy'))
self.setWindowTitle(title or 'Busy ...')
self.setFixedSize(self.sizeHint())
####################################################################################################################
# #
# CONTEXT MANAGER #
# #
####################################################################################################################
def __enter__(self):
"""
Draw the dialog.
"""
self.show()
def __exit__(self, exc_type, exc_value, traceback):
"""
Close the dialog.
"""
self.close()
示例7: CpSplashScreen
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class CpSplashScreen(QSplashScreen):
def __init__(self, parent = None, pixmap = None, maxSteps = 1):
super().__init__(parent, pixmap)
self.maxSteps = maxSteps
self.progress = QProgressBar(self)
#self.progress.setGeometry(15, 15, 100, 10)
self.progress.setTextVisible(False)
self.progress.setMinimum(0)
self.progress.setMaximum(self.maxSteps)
self.progress.setValue(0)
self.progress.hide()
def show(self):
super().show()
geo = self.geometry()
self.progress.setGeometry(5, geo.height() - 20, 100, 10)
self.progress.show()
def showMessage(self, msg, step = None, color = None):
if step is not None:
self.progress.setValue(step)
self.progress.update()
super().showMessage(msg, color=color)
示例8: CueWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class CueWidget(QWidget):
STOP = QIcon.fromTheme('led-off')
START = QIcon.fromTheme('led-running')
PAUSE = QIcon.fromTheme('led-pause')
ERROR = QIcon.fromTheme('led-error')
ICON_SIZE = 14
context_menu_request = pyqtSignal(object, QPoint)
edit_request = pyqtSignal(object)
cue_executed = pyqtSignal(object)
def __init__(self, cue, **kwargs):
super().__init__(**kwargs)
self.cue = None
self._selected = False
self._accurate_timing = False
self._show_dbmeter = False
self._countdown_mode = True
self._dbmeter_element = None
self._fade_element = None
self.setAttribute(Qt.WA_TranslucentBackground)
self.setLayout(QGridLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().setSpacing(2)
self.layout().setColumnStretch(0, 6)
self.layout().setRowStretch(0, 4)
self.nameButton = QClickLabel(self)
self.nameButton.setObjectName('ButtonCueWidget')
self.nameButton.setWordWrap(True)
self.nameButton.setAlignment(Qt.AlignCenter)
self.nameButton.setFocusPolicy(Qt.NoFocus)
self.nameButton.clicked.connect(self._clicked)
self.nameButton.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
self.layout().addWidget(self.nameButton, 0, 0)
self.statusIcon = QLabel(self.nameButton)
self.statusIcon.setStyleSheet('background-color: transparent')
self.statusIcon.setPixmap(CueWidget.STOP.pixmap(CueWidget.ICON_SIZE,
CueWidget.ICON_SIZE))
self.seekSlider = QClickSlider(self.nameButton)
self.seekSlider.setOrientation(Qt.Horizontal)
self.seekSlider.setFocusPolicy(Qt.NoFocus)
self.seekSlider.setVisible(False)
self.dbMeter = QDbMeter(self)
self.dbMeter.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
self.dbMeter.setVisible(False)
self.timeBar = QProgressBar(self)
self.timeBar.setTextVisible(False)
self.timeBar.setLayout(QHBoxLayout())
self.timeBar.layout().setContentsMargins(0, 0, 0, 0)
self.timeDisplay = QLCDNumber(self.timeBar)
self.timeDisplay.setStyleSheet('background-color: transparent')
self.timeDisplay.setSegmentStyle(QLCDNumber.Flat)
self.timeDisplay.setDigitCount(8)
self.timeDisplay.display('00:00:00')
self.timeBar.layout().addWidget(self.timeDisplay)
self.timeBar.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
self.timeBar.setVisible(False)
self._set_cue(cue)
@property
def selected(self):
return self._selected
@selected.setter
def selected(self, value):
self._selected = value
self._update_style(self.cue.stylesheet)
def contextMenuEvent(self, event):
self.context_menu_request.emit(self, event.globalPos())
def mouseMoveEvent(self, event):
if (event.buttons() == Qt.LeftButton and
(event.modifiers() == Qt.ControlModifier or
event.modifiers() == Qt.ShiftModifier)):
mime_data = QMimeData()
mime_data.setText(PageWidget.DRAG_MAGIC)
drag = QDrag(self)
drag.setMimeData(mime_data)
drag.setPixmap(self.grab(self.rect()))
if event.modifiers() == Qt.ControlModifier:
drag.exec_(Qt.MoveAction)
else:
drag.exec_(Qt.CopyAction)
event.accept()
#.........这里部分代码省略.........
示例9: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class MainWindow(QMainWindow, ui_window.Ui_Window):
emulator_found = QtCore.pyqtSignal(dict)
emulators_loaded = QtCore.pyqtSignal()
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
self.emulators = { }
self.settings = QSettings('SanderTheDragon', 'Qtendo')
self.ui_create()
self.ui_connect()
self.settings_load()
def showEvent(self, ev):
QMainWindow.showEvent(self, ev)
self.statusBar.showMsg('Searching for emulators', 1000)
Thread(target=self.find_emulators, daemon=True).start()
def closeEvent(self, ev):
QMainWindow.closeEvent(self, ev)
self.settings_save()
def ui_create(self):
#Add toolbar
self.toolBar = QToolBar()
self.toolBar.addAction(self.actionPageEmulation)
self.toolBar.setFloatable(False)
self.toolBar.setMovable(False)
self.toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.gridLayout.addWidget(self.toolBar, 1, 0)
#Add a second toolbar on emulation page
self.toolBarEmulation = QToolBar()
self.toolBarEmulation.setFloatable(False)
self.toolBarEmulation.setMovable(False)
self.toolBarEmulation.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.pageEmulationLayout.addWidget(self.toolBarEmulation, 0, 0)
#Add progress bar to status bar
self.taskProgress = QProgressBar()
self.taskProgress.setVal = lambda x: ( self.taskProgress.setVisible(True), self.taskProgress.setValue(x) )
self.taskProgress.setVal(0)
self.taskProgress.setTextVisible(False)
self.statusBar.addPermanentWidget(self.taskProgress)
#Also print messages to terminal
self.statusBar.showMsg = lambda msg, timeout: ( logging.info(msg), self.statusBar.showMessage(msg, timeout) )
#Styling
self.setStyleSheet('QToolButton { padding-right: -3px; }')
def ui_connect(self):
#Menu actions
self.actionQuit.triggered.connect(QCoreApplication.quit)
self.actionSettings.triggered.connect(lambda: settings.SettingsDialog(parent=self).exec_())
self.actionAbout.triggered.connect(lambda: about.AboutDialog(parent=self).exec_())
#Toolbar actions
self.actionPageEmulation.triggered.connect(lambda: self.stackedWidget.setCurrentIndex(0))
#Other signals
self.emulator_found.connect(self.add_emulator)
self.emulators_loaded.connect(self.reset_status)
def settings_load(self):
if self.settings.value('qtendo/window/restore', True, type=bool):
self.restoreGeometry(self.settings.value('qtendo/window/geometry', type=QByteArray))
def settings_save(self):
if self.settings.value('qtendo/window/restore', True, type=bool):
self.settings.setValue('qtendo/window/geometry', self.saveGeometry())
def change_emulator(self, index):
current = self.stackedWidgetEmulation.currentIndex()
if current != index:
emulator = self.emulators[list(self.emulators.keys())[current]]
emulator['action'].setIcon(QIcon(emulator['action'].icon().pixmap(QSize(24, 24), QIcon.Disabled)))
self.stackedWidgetEmulation.setCurrentIndex(index)
emulator = self.emulators[list(self.emulators.keys())[index]]
emulator['action'].setIcon(QIcon(':' + emulator['icon']))
def add_emulator(self, emulator):
#.........这里部分代码省略.........
示例10: SensorsWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
#.........这里部分代码省略.........
self.velLinX.setFixedSize(QtCore.QSize(150, 150))
# self.velLinX.move(60,270)
self.velXLabel = QLabel('Linear X (m/s)', self)
# self.velXLabel.move(95,420)
self.velLinY = qfi_SI.qfi_SI(self)
self.velLinY.setFixedSize(QtCore.QSize(150, 150))
# self.velLinY.move(240,270)
self.velYLabel = QLabel('Linear Y (m/s)', self)
# self.velYLabel.move(275,420)
self.velLinZ = qfi_SI.qfi_SI(self)
self.velLinZ.setFixedSize(QtCore.QSize(150, 150))
# self.velLinZ.setLabel("8 m/s")
# self.velLinZ.move(420,270)
self.velZLabel = QLabel('Linear Z (m/s)', self)
# self.velZLabel.move(455,420)
self.indLayout.addLayout(self.horizonLayout, 0, 0, Qt.AlignCenter)
self.indLayout.addLayout(self.compassLayout, 0, 1, Qt.AlignCenter)
self.indLayout.addLayout(self.altLayout, 0, 2, Qt.AlignCenter)
self.indLayout.addWidget(self.velLinX, 1, 0, Qt.AlignCenter)
self.indLayout.addWidget(self.velLinY, 1, 1, Qt.AlignCenter)
self.indLayout.addWidget(self.velLinZ, 1, 2, Qt.AlignCenter)
self.indLayout.addWidget(self.velXLabel, 2, 0, Qt.AlignCenter)
self.indLayout.addWidget(self.velYLabel, 2, 1, Qt.AlignCenter)
self.indLayout.addWidget(self.velZLabel, 2, 2, Qt.AlignCenter)
self.battery=QProgressBar(self)
self.battery.setValue(0)
self.battery.resize(56,241)
self.battery.setOrientation(Qt.Vertical)
self.battery.setTextVisible(False)
self.batteryLabel=QLabel('Battery (%)',self)
self.batteryValueLabel = QLabel('0', self)
self.batteryValueLabel.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.batteryData.addItem(hSpacer, 0, 0, 1, 1, Qt.AlignLeft)
self.batteryData.addWidget(self.batteryLabel, 0, 1, Qt.AlignCenter)
self.batteryData.addWidget(self.batteryValueLabel, 0, 2, Qt.AlignCenter)
self.batteryData.addItem(hSpacer, 0, 4, 1, 1, Qt.AlignLeft)
self.batteryLayout.addWidget(self.battery, 0, Qt.AlignHCenter)
self.batteryLayout.addLayout(self.batteryData)
self.mainLayout.addLayout(self.indLayout)
self.mainLayout.addLayout(self.batteryLayout)
self.setLayout(self.mainLayout);
def updateSensors(self):
pose = self.winParent.getPose3D().getPose3d()
if pose != None:
qw = pose.q[0]
qx = pose.q[1]
qy = pose.q[2]
qz = pose.q[3]
self.drawAltd(pose.z)
self.drawYawValues(self.quatToYaw(qw, qx, qy, qz) * 180 / math.pi)
self.drawPitchRollValues(self.quatToPitch(qw, qx, qy, qz) * 180 / math.pi,
self.quatToRoll(qw, qx, qy, qz) * 180 / math.pi)
navdata = self.winParent.getNavData().getNavData()
示例11: percentajeWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class percentajeWidget(QWidget):
def __init__(self,winParent, pose3d):
super(percentajeWidget, self).__init__()
self.winParent=winParent
self.map = cv2.imread("resources/images/mapgrannyannie.png", cv2.IMREAD_GRAYSCALE)
self.map = cv2.resize(self.map, (500, 500))
image = QtGui.QImage(self.map.data, self.map.shape[1], self.map.shape[0], self.map.shape[1], QtGui.QImage.Format_Indexed8);
self.pixmap = QtGui.QPixmap.fromImage(image)
self.pose3d = pose3d
self.percentajeHouse = 0
self.numPixels = self.calculatePixelsWhite()
self.numPixelsWalked = 0
vLayout = QVBoxLayout()
self.percentajeWalked()
self.Percentaje = QLabel("Percentaje: " + str(round(self.percentajeHouse, 3)) + ' %')
vLayout.addWidget(self.Percentaje, 0)
self.bar = QProgressBar()
self.bar.setValue(self.percentajeHouse)
st = "QProgressBar::chunk {background-color: #ff0000;}\n QProgressBar {border: 1px solid grey;border-radius: 2px;text-align: center;background: #eeeeee;}"
self.bar.setStyleSheet(st)
self.bar.setTextVisible(False)
vLayout.addWidget(self.Percentaje, 0)
vLayout.addWidget(self.bar, 0)
vSpacer = QSpacerItem(30, 80, QSizePolicy.Ignored, QSizePolicy.Ignored)
vLayout.addItem(vSpacer)
self.setLayout(vLayout)
def RTx(self, angle, tx, ty, tz):
RT = np.matrix([[1, 0, 0, tx], [0, math.cos(angle), -math.sin(angle), ty], [0, math.sin(angle), math.cos(angle), tz], [0,0,0,1]])
return RT
def RTy(self, angle, tx, ty, tz):
RT = np.matrix([[math.cos(angle), 0, math.sin(angle), tx], [0, 1, 0, ty], [-math.sin(angle), 0, math.cos(angle), tz], [0,0,0,1]])
return RT
def RTz(self, angle, tx, ty, tz):
RT = np.matrix([[math.cos(angle), -math.sin(angle), 0, tx], [math.sin(angle), math.cos(angle),0, ty], [0, 0, 1, tz], [0,0,0,1]])
return RT
def RTVacuum(self):
RTy = self.RTy(pi, 1, -1, 0)
return RTy
def calculatePixelsWhite(self):
# Calculating the 100% of the pixels that can be traversed
numPixels = 0
img = self.pixmap.toImage()
for i in range(0, self.map.shape[1]):
for j in range(0, self.map.shape[0]):
c = img.pixel(i,j)
color = QtGui.QColor(c).getRgbF()
if color == (1.0, 1.0, 1.0, 1.0):
numPixels = numPixels + 1
return numPixels
def calculatePercentaje(self):
percentaje = self.numPixelsWalked * 100 / self.numPixels
return percentaje
def percentajeWalked(self):
x = self.pose3d.getPose3d().x
y = self.pose3d.getPose3d().y
scale = 50
img = self.pixmap.toImage()
final_poses = self.RTVacuum() * np.matrix([[x], [y], [1], [1]]) * scale
i_init = int(-50/4+final_poses.flat[0] + self.map.shape[1]/2)
i_finish = int(50/4+final_poses.flat[0] + self.map.shape[1]/2)
j_init = int(-50/4+final_poses[1] + self.map.shape[0]/2)
j_finish = int(50/4+final_poses[1] + self.map.shape[0]/2)
for k in range(i_init, i_finish+1):
for l in range(j_init, j_finish+1):
c = img.pixel(k,l)
color = QtGui.QColor(c).getRgbF()
if color == (1.0, 1.0, 1.0, 1.0):
if self.map[k][l] != 128:
self.numPixelsWalked = self.numPixelsWalked + 1
self.map[k][l] = 128
self.percentajeHouse = self.calculatePercentaje()
def updateG(self):
self.percentajeWalked()
self.Percentaje.setText("Percentaje: " + str(round(self.percentajeHouse, 3)) + ' %')
self.bar.setValue(self.percentajeHouse)
self.update()
示例12: __init__
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class Qt4SysTrayIcon:
def __init__(self):
self.snapshots = snapshots.Snapshots()
self.config = self.snapshots.config
self.decode = None
if len(sys.argv) > 1:
if not self.config.setCurrentProfile(sys.argv[1]):
logger.warning("Failed to change Profile_ID %s"
%sys.argv[1], self)
self.qapp = qt4tools.createQApplication(self.config.APP_NAME)
translator = qt4tools.translator()
self.qapp.installTranslator(translator)
self.qapp.setQuitOnLastWindowClosed(False)
import icon
self.icon = icon
self.qapp.setWindowIcon(icon.BIT_LOGO)
self.status_icon = QSystemTrayIcon(icon.BIT_LOGO)
#self.status_icon.actionCollection().clear()
self.contextMenu = QMenu()
self.menuProfileName = self.contextMenu.addAction(_('Profile: "%s"') % self.config.profileName())
qt4tools.setFontBold(self.menuProfileName)
self.contextMenu.addSeparator()
self.menuStatusMessage = self.contextMenu.addAction(_('Done'))
self.menuProgress = self.contextMenu.addAction('')
self.menuProgress.setVisible(False)
self.contextMenu.addSeparator()
self.btnPause = self.contextMenu.addAction(icon.PAUSE, _('Pause snapshot process'))
action = lambda: os.kill(self.snapshots.pid(), signal.SIGSTOP)
self.btnPause.triggered.connect(action)
self.btnResume = self.contextMenu.addAction(icon.RESUME, _('Resume snapshot process'))
action = lambda: os.kill(self.snapshots.pid(), signal.SIGCONT)
self.btnResume.triggered.connect(action)
self.btnResume.setVisible(False)
self.btnStop = self.contextMenu.addAction(icon.STOP, _('Stop snapshot process'))
self.btnStop.triggered.connect(self.onBtnStop)
self.contextMenu.addSeparator()
self.btnDecode = self.contextMenu.addAction(icon.VIEW_SNAPSHOT_LOG, _('decode paths'))
self.btnDecode.setCheckable(True)
self.btnDecode.setVisible(self.config.snapshotsMode() == 'ssh_encfs')
self.btnDecode.toggled.connect(self.onBtnDecode)
self.openLog = self.contextMenu.addAction(icon.VIEW_LAST_LOG, _('View Last Log'))
self.openLog.triggered.connect(self.onOpenLog)
self.startBIT = self.contextMenu.addAction(icon.BIT_LOGO, _('Start BackInTime'))
self.startBIT.triggered.connect(self.onStartBIT)
self.status_icon.setContextMenu(self.contextMenu)
self.pixmap = icon.BIT_LOGO.pixmap(24)
self.progressBar = QProgressBar()
self.progressBar.setMinimum(0)
self.progressBar.setMaximum(100)
self.progressBar.setValue(0)
self.progressBar.setTextVisible(False)
self.progressBar.resize(24, 6)
self.progressBar.render(self.pixmap, sourceRegion = QRegion(0, -14, 24, 6), flags = QWidget.RenderFlags(QWidget.DrawChildren))
self.first_error = self.config.notify()
self.popup = None
self.last_message = None
self.timer = QTimer()
self.timer.timeout.connect(self.updateInfo)
self.ppid = os.getppid()
def prepairExit(self):
self.timer.stop()
if not self.status_icon is None:
self.status_icon.hide()
self.status_icon = None
if not self.popup is None:
self.popup.deleteLater()
self.popup = None
self.qapp.processEvents()
def run(self):
self.status_icon.show()
self.timer.start(500)
logger.info("[qt4systrayicon] begin loop", self)
self.qapp.exec_()
logger.info("[qt4systrayicon] end loop", self)
self.prepairExit()
#.........这里部分代码省略.........
示例13: ProgressBar
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class ProgressBar(vip_base):
def cb_initialize_plugin(self):
# ---------------------------
# Read configuration
# ---------------------------
# Note: this cfg items have to exist!
self.config = self.pl_get_current_config_ref()
self.progress_value = self.config['progress_value']['value']
self.trigger_value = self.config['trigger_value']['value']
self.reset_trigger_value = self.config['reset_trigger_value']['value']
self.show_percent = self.config['show_percent']['value'] == '1'
self.show_current_max = self.config['show_current_max']['value'] == '1'
self.round_digit = int(self.config['round_digit']['value'])
self.min_range = float(self.config['min_rage']['value'])
self.max_range = float(self.config['max_range']['value'])
# --------------------------------
# Create Widget
# --------------------------------
# Create Widget needed for this plugin
self.progressbar = QProgressBar()
self.progressbar.setRange(0, 100)
self.progressbar.setTextVisible(True)
self.progressbar.setValue(0)
self.progressbar.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.progressbar.customContextMenuRequested.connect(self.show_context_menu)
# This call is important, because the background structure needs to know the used widget!
# In the background the qmidiwindow will becreated and the widget will be added
self.set_value(self.min_range)
self.pl_set_widget_for_internal_usage(self.progressbar)
# ---------------------------
# Create Parameters
# ---------------------------
para_list = []
# create a parameter object
self.para_trigger = DParameter('trigger', default=0)
self.para_change_progress_value = DParameter('ProgressValue', default=self.progress_value)
self.para_change_reset_value = DParameter('ResetValue', default=self.reset_trigger_value)
self.para_change_trigger_value = DParameter('TriggerValue', default=self.trigger_value)
self.para_change_min_range = DParameter('MinRange', default=self.min_range, Regex=pc.REGEX_SIGNED_FLOAT_OR_INT)
self.para_change_max_range = DParameter('MaxRange', default=self.max_range, Regex=pc.REGEX_SIGNED_FLOAT_OR_INT)
self.para_show_percent = DParameter('ShowPercent', default=self.config['show_percent']['value'], Regex=pc.REGEX_BOOL_BIN)
self.para_show_current_max = DParameter('ShowCurrentMax', default=self.config['show_current_max']['value'], Regex=pc.REGEX_BOOL_BIN)
para_list.append(self.para_trigger)
para_list.append(self.para_change_progress_value)
para_list.append(self.para_change_reset_value)
para_list.append(self.para_change_trigger_value)
para_list.append(self.para_change_min_range)
para_list.append(self.para_change_max_range)
para_list.append(self.para_show_percent)
para_list.append(self.para_show_current_max)
# build parameter list to send to Core
self.pl_send_new_parameter_list(para_list)
return True
def show_context_menu(self, pos):
gloPos = self.progressbar.mapToGlobal(pos)
self.cmenu = self.pl_create_control_context_menu()
self.cmenu.exec_(gloPos)
def cb_pause(self):
# will be called, when plugin gets paused
# can be used to get plugin in a defined state before pause
# e.a. close communication ports, files etc.
pass
def cb_resume(self):
# will be called when plugin gets resumed
# can be used to wake up the plugin from defined pause state
# e.a. reopen communication ports, files etc.
pass
def cb_execute(self, Data=None, block_name = None, plugin_uname = None):
# Do main work here!
# If this plugin is an IOP plugin, then there will be no Data parameter because it wont get data
# If this plugin is a DPP, then it will get Data with data
# param: Data is a Data hash and block_name is the block_name of Data origin
# Data is a hash, so use ist like: Data[CORE_TIME_SIGNAL] = [t1, t2, ...] where CORE_TIME_SIGNAL is a signal_name
# hash signal_name: value
# Data could have multiple types stored in it e.a. Data['d1'] = int, Data['d2'] = []
if self.reset_trigger_value in Data:
self.reset()
#.........这里部分代码省略.........
示例14: Splash
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class Splash(QObject, LogMixin, EventMixin):
"""Splash screen class"""
def __init__(self, parent, msg = ""):
"""
Constructor of Splash screen
:param parent: ui parent
:param msg: initial message text
"""
super().__init__()
self._parent = parent
self.isHidden = True
self._progress = 0
self._progressBar = None
self.msg = msg
pixmap = QtGui.QPixmap(380, 100)
pixmap.fill(QtGui.QColor("darkgreen"))
self._splash = QSplashScreen(pixmap)
self._splash.setParent(self._parent)
self.add_progressbar()
def add_progressbar(self):
"""Add separate progress bar to splash screen"""
self._progressBar = QProgressBar(self._splash)
self._progressBar.setGeometry(self._splash.width() / 10, 8 * self._splash.height() / 10,
8 * self._splash.width() / 10, self._splash.height() / 10)
self._progressBar.hide()
def setProgress(self, val):
"""
Set progress bar to ``val``
If splash has no progressbar, it will be added dynamically.
Remove progressbar with ``val`` as None.
:param val: absolut percent value
:return:
"""
if val is not None:
self._progressBar.show()
self._progressBar.setTextVisible(True)
self.progress = val
try:
self._progressBar.setValue(self.progress)
except:
pass
else:
self._progressBar.setTextVisible(False)
self._progressBar.hide()
self._progressBar.reset()
if self.isHidden is True:
self.isHidden = False
self.show_()
def incProgress(self, val):
"""
Increase progressbar value by ``val``
If splash has no progressbar, it will be added dynamically.
Remove progressbar with ``val`` as None.
:param val: value to increase by
:return:
"""
if val is not None:
self._progressBar.show()
self._progressBar.setTextVisible(True)
self.progress = self.progress + val
try:
self._progressBar.setValue(self.progress)
qApp.processEvents()
except:
pass
else:
self._progressBar.setTextVisible(False)
self._progressBar.hide()
self._progressBar.reset()
if self.isHidden is True:
self.isHidden = False
self.show_()
def setParent(self, parent):
"""Set splash's parent"""
self._parent = parent
self._splash.setParent(parent)
@pyqtSlot()
@pyqtSlot(bool)
def close(self, dummy = True):
self.logger.debug("Hide splash")
self.isHidden = True
#.........这里部分代码省略.........
示例15: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setTextVisible [as 别名]
class MainWindow(QMainWindow, Ui_MainWindow):
# Maintain the list of browser windows so that they do not get garbage
# collected.
_window_list = []
def __init__(self):
super(MainWindow, self).__init__()
MainWindow._window_list.append(self)
self.setupUi(self)
# Qt Designer (at least to v4.2.1) can't handle arbitrary widgets in a
# QToolBar - even though uic can, and they are in the original .ui
# file. Therefore we manually add the problematic widgets.
self.lblAddress = QLabel("Address", self.tbAddress)
self.tbAddress.insertWidget(self.actionGo, self.lblAddress)
self.addressEdit = QLineEdit(self.tbAddress)
self.tbAddress.insertWidget(self.actionGo, self.addressEdit)
self.addressEdit.returnPressed.connect(self.actionGo.trigger)
self.actionBack.triggered.connect(self.WebBrowser.GoBack)
self.actionForward.triggered.connect(self.WebBrowser.GoForward)
self.actionStop.triggered.connect(self.WebBrowser.Stop)
self.actionRefresh.triggered.connect(self.WebBrowser.Refresh)
self.actionHome.triggered.connect(self.WebBrowser.GoHome)
self.actionSearch.triggered.connect(self.WebBrowser.GoSearch)
self.pb = QProgressBar(self.statusBar())
self.pb.setTextVisible(False)
self.pb.hide()
self.statusBar().addPermanentWidget(self.pb)
self.WebBrowser.dynamicCall('GoHome()')
def closeEvent(self, e):
MainWindow._window_list.remove(self)
e.accept()
def on_WebBrowser_TitleChange(self, title):
self.setWindowTitle("Qt WebBrowser - " + title)
def on_WebBrowser_ProgressChange(self, a, b):
if a <= 0 or b <= 0:
self.pb.hide()
return
self.pb.show()
self.pb.setRange(0, b)
self.pb.setValue(a)
def on_WebBrowser_CommandStateChange(self, cmd, on):
if cmd == 1:
self.actionForward.setEnabled(on)
elif cmd == 2:
self.actionBack.setEnabled(on)
def on_WebBrowser_BeforeNavigate(self):
self.actionStop.setEnabled(True)
def on_WebBrowser_NavigateComplete(self, _):
self.actionStop.setEnabled(False)
@pyqtSlot()
def on_actionGo_triggered(self):
self.WebBrowser.dynamicCall('Navigate(const QString&)',
self.addressEdit.text())
@pyqtSlot()
def on_actionNewWindow_triggered(self):
window = MainWindow()
window.show()
if self.addressEdit.text().isEmpty():
return;
window.addressEdit.setText(self.addressEdit.text())
window.actionStop.setEnabled(True)
window.on_actionGo_triggered()
@pyqtSlot()
def on_actionAbout_triggered(self):
QMessageBox.about(self, "About WebBrowser",
"This Example has been created using the ActiveQt integration into Qt Designer.\n"
"It demonstrates the use of QAxWidget to embed the Internet Explorer ActiveX\n"
"control into a Qt application.")
@pyqtSlot()
def on_actionAboutQt_triggered(self):
QMessageBox.aboutQt(self, "About Qt")