当前位置: 首页>>代码示例>>Python>>正文


Python QProgressBar.value方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QProgressBar.value方法的典型用法代码示例。如果您正苦于以下问题:Python QProgressBar.value方法的具体用法?Python QProgressBar.value怎么用?Python QProgressBar.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QProgressBar的用法示例。


在下文中一共展示了QProgressBar.value方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LabeledProgressBar

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import value [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)
开发者ID:Kf4btg,项目名称:SkyModMan,代码行数:58,代码来源:labeled_progressbar.py

示例2: __init__

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import value [as 别名]

#.........这里部分代码省略.........
            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()

    def updateInfo(self):
        if not tools.processAlive(self.ppid):
            self.prepairExit()
            self.qapp.exit(0)
            return

        paused = tools.processPaused(self.snapshots.pid())
        self.btnPause.setVisible(not paused)
        self.btnResume.setVisible(paused)

        message = self.snapshots.takeSnapshotMessage()
        if message is None and self.last_message is None:
            message = (0, _('Working...'))

        if not message is None:
            if message != self.last_message:
                self.last_message = message
                if self.decode:
                    message = (message[0], self.decode.log(message[1]))
                self.menuStatusMessage.setText('\n'.join(tools.wrapLine(message[1],\
                                                                         size = 80,\
                                                                         delimiters = '',\
                                                                         new_line_indicator = '') \
                                                                       ))
                self.status_icon.setToolTip(message[1])

        pg = progress.ProgressFile(self.config)
        if pg.fileReadable():
            pg.load()
            percent = pg.intValue('percent')
            if percent != self.progressBar.value():
                self.progressBar.setValue(percent)
                self.progressBar.render(self.pixmap, sourceRegion = QRegion(0, -14, 24, 6), flags = QWidget.RenderFlags(QWidget.DrawChildren))
                self.status_icon.setIcon(QIcon(self.pixmap))

            self.menuProgress.setText(' | '.join(self.getMenuProgress(pg)))
            self.menuProgress.setVisible(True)
        else:
            self.status_icon.setIcon(self.icon.BIT_LOGO)
            self.menuProgress.setVisible(False)


    def getMenuProgress(self, pg):
        d = (('sent',   _('Sent:')), \
             ('speed',  _('Speed:')),\
             ('eta',    _('ETA:')))
        for key, txt in d:
            value = pg.strValue(key, '')
            if not value:
                continue
            yield txt + ' ' + value

    def onStartBIT(self):
        profileID = self.config.currentProfile()
        cmd = ['backintime-qt4',]
        if not profileID == '1':
            cmd += ['--profile-id', profileID]
        proc = subprocess.Popen(cmd)

    def onOpenLog(self):
        dlg = logviewdialog.LogViewDialog(self, systray = True)
        dlg.decode = self.decode
        dlg.cbDecode.setChecked(self.btnDecode.isChecked())
        dlg.exec_()

    def onBtnDecode(self, checked):
        if checked:
            self.decode = encfstools.Decode(self.config)
            self.last_message = None
            self.updateInfo()
        else:
            self.decode = None

    def onBtnStop(self):
        os.kill(self.snapshots.pid(), signal.SIGKILL)
        self.btnStop.setEnabled(False)
        self.btnPause.setEnabled(False)
        self.btnResume.setEnabled(False)
        self.snapshots.setTakeSnapshotMessage(0, 'Snapshot terminated')
开发者ID:jeffsilverm,项目名称:backintime,代码行数:104,代码来源:qt4systrayicon.py

示例3: TrackProgressDialog

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import value [as 别名]
class TrackProgressDialog(QDialog):
    finished = pyqtSignal()

    def __init__(self, parent=None, numStages=1):
        QDialog.__init__(self, parent)

        self.threadRouter = ThreadRouter(self)
        self.currentStep = 0
        self.progress = None

        l = QVBoxLayout()
        self.setLayout(l)

        self.overallProgress = QProgressBar()
        self.overallProgress.setRange(0, numStages)
        self.overallProgress.setFormat("step %v of "+str(numStages))

        self.currentStepProgress = QProgressBar()
        self.currentStepProgress.setRange(0, 100)
        self.currentStepProgress.setFormat("%p %")

        self.overallLabel = QLabel("Overall progress")
        self.currentStepLabel = QLabel("Current step")

        l.addWidget(self.overallLabel)
        l.addWidget(self.overallProgress)
        l.addWidget(self.currentStepLabel)
        l.addWidget(self.currentStepProgress)
        l.maximumSize()

        self.update()

    @threadRouted
    def __onNewStep(self, description):
        self.currentStep += 1
        self.currentStepProgress.setValue(0)
        self.overallProgress.setValue(self.currentStep)
        self.currentStepLabel.setText(description)
        self.update()

    @threadRouted
    def __onCurrentStepProgressChanged(self, progress):
        timesHundred = round(1000.0*progress)
        timesTen = round(100.0*progress)
        if ( not self.currentStepProgress.value() == timesTen ) and   (timesHundred - 10*timesTen)==0:
            self.currentStepProgress.setValue( timesTen )
            self.update()

    @threadRouted
    def run(self):
        self.trackProgress = TrackProgress(self)
        self.trackProgress.progress.connect(self.__onCurrentStepProgressChanged, Qt.BlockingQueuedConnection)
        self.trackProgress.newStep.connect(self.__onNewStep, Qt.BlockingQueuedConnection)
        self.trackProgress.done.connect(self.onTrackDone)
        self.trackProgress.start()

    @threadRouted
    def onTrackDone(self):
        self.trackProgress.wait() # Join the extractor thread so its safe to immediately destroy the window
        self.finished.emit()
        self.close()
开发者ID:DerThorsten,项目名称:ilastik,代码行数:63,代码来源:progress.py

示例4: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import value [as 别名]

#.........这里部分代码省略.........
        self.mail_row.addWidget(self.no_reply_label)
        self.mail_row.addWidget(self.no_reply)
        self.layout.addLayout(self.mail_row)

        self.password_row = QHBoxLayout()
        password_input_label = QLabel('Your UGCloud Password: ')
        self.password_input = QLineEdit()
        self.password_input.setEchoMode(QLineEdit.Password)
        self.password_row.addWidget(password_input_label)
        self.password_row.addWidget(self.password_input)
        self.layout.addLayout(self.password_row)

        self.subject_row = QHBoxLayout()
        subject_input_label = QLabel('Subject for Emails: ')
        self.subject_input = QLineEdit()
        self.subject_input.setText('Enjoy your new timetable!')
        self.subject_row.addWidget(subject_input_label)
        self.subject_row.addWidget(self.subject_input)
        self.layout.addLayout(self.subject_row)

        self.message_label_row = QHBoxLayout()
        self.message_input_label = QLabel('Message')
        self.message_label_row.addWidget(self.message_input_label)
        self.layout.addLayout(self.message_label_row)

        self.message_input_row = QHBoxLayout()
        self.message_input = QTextEdit()
        self.message_input.setText(' '.join(['Please find your timetable',
                                             'attached to this email']))
        self.message_input_row.addWidget(self.message_input)
        self.layout.addLayout(self.message_input_row)

        self.go_row = QHBoxLayout()
        go_button = QPushButton('Send Timetables')
        go_button.clicked.connect(self.mail_timetables)
        self.go_row.addWidget(go_button)
        self.layout.addLayout(self.go_row)

        self.setCentralWidget(main_widget)

    def open_file_browser(self, input_to_change):
        self.file_dialog = QFileDialog()
        file_name = self.file_dialog.getOpenFileName(self,
                                                     'Choose Timetables',
                                                     os.path.expanduser('~'),
                                                     'PDF Files (*.pdf)')
        if file_name:
            input_to_change.setText(file_name[0])

    def init_output_display(self, pdf_page_count):
        output_window = QDialog()
        output_window.setWindowTitle('Mail Progress')
        layout = QVBoxLayout()

        self.progress_bar = QProgressBar()
        self.progress_bar.setMinimum(0)
        self.progress_bar.setMaximum(pdf_page_count)
        self.progress_bar.setValue(0)
        layout.addWidget(self.progress_bar)

        self.output_text = QTextEdit()
        self.output_text.setMinimumHeight(300)
        self.output_text.setReadOnly(True)
        layout.addWidget(self.output_text)

        output_window.setLayout(layout)
        self.layout.addWidget(output_window)

    def update_output(self, address):
        self.output_text.insertPlainText('Sent email to {0}\n'.format(address))
        self.progress_bar.setValue(self.progress_bar.value() + 1)

    def finished(self):
        self.output_text.insertPlainText(' '.join(['Finished sending all',
                                                   'emails successfully\n']))

    def mail_timetables(self):

        pdf_file = self.file_input.text()
        email_user = self.email_input.text()
        email_pass = self.password_input.text()
        subject = self.subject_input.text()
        body = self.message_input.text()
        no_reply = self.no_reply.isChecked()
        with open(pdf_file, 'rb') as f:
            pdf_io = io.BytesIO(f.read())
            reader = PdfFileReader(pdf_io)
            self.init_output_display(reader.numPages)
            self.get_thread = MailTimetablesThread(reader,
                                                   email_user,
                                                   email_pass,
                                                   subject,
                                                   no_reply,
                                                   self.communicate,
                                                   body)
            self.communicate.mailed.connect(self.update_output)
            self.get_thread.finished.connect(self.finished)
            self.output_text.insertPlainText(
                'Mailing {0} timetables\n'.format(reader.numPages))
            self.get_thread.start()
开发者ID:gregorysenyshyn,项目名称:timetable-mailer,代码行数:104,代码来源:gui.py

示例5: ProgressBar

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import value [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()
#.........这里部分代码省略.........
开发者ID:TUB-Control,项目名称:PaPI,代码行数:103,代码来源:ProgressBar.py

示例6: progressTrack

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import value [as 别名]
class progressTrack( QFrame ):
  maxVal   = 150;
  prog     =  25;
  elapsed  = 0.0;
  progressUpdate = QtCore.pyqtSignal(int);
  artist         = QtCore.pyqtSignal(str);
  album          = QtCore.pyqtSignal(str);
  track          = QtCore.pyqtSignal(str);
  status         = QtCore.pyqtSignal(str);
  
  def __init__(self, root, orient = None, mode = None):
    QFrame.__init__(self);
    self.time    = None;                                                        # Initialize variable for computation time
    self.running = False;                                                       # Set running to False

    artist           = QLabel('Artist:');                                       # Set up label for track artist
    album            = QLabel('Album:');                                        # Set up label for track album
    track            = QLabel('Track:');                                        # Set up label for track name

    self.artistLabel = QLabel('');                                              # Set label to display track artist using the artist tkinter string var
    self.albumLabel  = QLabel('');                                              # Set label to display album artist using the album tkinter string var
    self.trackLabel  = QLabel('');                                              # Set label to display track name using the track tkinter string var

    self.artist.connect(self.artistLabel.setText)
    self.album.connect(self.albumLabel.setText)
    self.track.connect(self.trackLabel.setText);

    self.progress   = QProgressBar();                                                                          # Initialize track progress bar
    self.progress.setMaximum(self.maxVal);                                      # Set maximum value of the track progress bar
    self.progressUpdate.connect( self.progress.setValue );
    status = QLabel('');                        # Set up label for status
    self.status.connect(status.setText);
        
    layout = QGridLayout();
    layout.setColumnStretch(1, 1);
    layout.addWidget(artist,           0, 0, 1, 1);
    layout.addWidget(self.artistLabel, 0, 1, 1, 1);
    layout.addWidget(album,            1, 0, 1, 1);
    layout.addWidget(self.albumLabel,  1, 1, 1, 1);
    layout.addWidget(track,            2, 0, 1, 1);
    layout.addWidget(self.trackLabel,  2, 1, 1, 1);
    layout.addWidget(self.progress,    3, 0, 1, 2);
    layout.addWidget(status,           4, 0, 1, 2);    

    layout.setVerticalSpacing(2);
    self.setLayout( layout );
    self.show();
    self.__labelWidth = round( self.progress.width() * 0.75 );                  # Get width of progress bar after everything is packed
  ##############################################################################
  def updateInfo(self, info):
    '''
    Purpose:
       Method to update the artist/album/track information
    Inputs:
       info : Dictionary of track information
    '''
    track = '';                                                                 # Initialize track to empty string
    if ('Album Artist' in info):                                                # If 'Album Artist' is a key in the info dictionary
      txt = self.__truncateText( self.artistLabel, info['Album Artist'] );
      self.artist.emit( txt );                                                  # Update the artist tkinter string var
    elif ('Artist'     in info):                                                # Else, if 'Artist' is a key in the info dictionary
      txt = self.__truncateText( self.artistLabel, info['Artist'] );
      self.artist.emit( txt );                                                  # Update the artist tkinter string var
    else:                                                                       # Else
      self.artist.emit( '' );                                                   # Update the artist tkinter string var to empty string
    
    if ('Album'        in info):                                                # If 'Album' is a key in the info dictionary
      txt = self.__truncateText( self.albumLabel, info['Album'] );
      self.album.emit( txt );                                                   # Update the album tkinter string var
    else:                                                                       # Else
      self.album.emit( '' );                                                    # Update the album tkinter string var to empty string

    if ('Track Number' in info): track += '{:02} '.format(info['Track Number']);# If 'Track Number' is key in the info dictionary, append the track number (with formatting) to the track variable
    if ('Name'         in info): track += info['Name'];                         # if 'Name' is a key in the info dictionary, append track name to track variable
    txt =self.__truncateText( self.trackLabel, track);
    self.track.emit( txt );                                                     # Set the track tkinter string var using the track variable
    self.status.emit( '' );                                                     # Set status to empty
    self.progressUpdate.emit( 0 );                                              # Set the progress bar to zero (0) progress

  ##############################################################################
  def updateStatus(self, text, prog = False, finish = False):
    '''
    Purpose:
      Method to update status text
    Inputs:
      text   : Text to update status to
    Keywords:
      prog   : If set to True, will increment the progress bar
      finish : If set to True, will set progress bar to done
    '''
    self.status.emit( text );                                                   # Update the status text
    if prog:                                                                    # If prog is True
      self.progressUpdate.emit( self.progress.value() + self.prog );            # Update the progress bar
    if finish:
      self.progressUpdate.emit( self.maxVal )                                   # Update the progress bar
      self.time  = time.time() - self.time;                                     # Set time to processing time
  ##############################################################################
  def reset(self):
    '''
    Method to reset all values in the frame
#.........这里部分代码省略.........
开发者ID:kwodzicki,项目名称:iTunes_Music_Converter,代码行数:103,代码来源:progressFrame.py


注:本文中的PyQt5.QtWidgets.QProgressBar.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。