def test_tasks(self): self.progress.set_header("Testing Tasks") self.progress.tasks.reset() self.progress.show_tasks() self.progress.tasks.run_current() # task1 is now running for i in xrange(0,len(self.progress.tasks)): self.progress.set_header("%s" % self.progress.tasks.get_task_label()) self.test_bar() self.progress.tasks.next() doGtkEvents() time.sleep(1) self.progress.hide_tasks()
def __init__(self): ''' Init the signal callback Controller ''' # init the Controller Class to connect signals etc. Controller.__init__(self, BUILDER_FILE , 'main', domain='yumex', connect=False) self.status_icon = None self.window.set_title("Testing Progress") self.window.show() self.progress = Progress(self) self.progress.show() doGtkEvents() self.run_tests()
def run(self): ''' run the dialog ''' self.hidden = (self.progress.progress_hidden, self.progress.task_hidden) self.progress.set_header(_("Transaction Result")) self.progress.show_extra() self.view.expand_all() self._active = True self.confirmation = None while self.confirmation == None: doGtkEvents() time.sleep(0.01) return self.confirmation
def test_bar(self, task_id=None): frac = 0.0 while True: if frac > 0.99: percent = 100 frac = 1.0 else: percent = int(frac * 100) self.progress.set_fraction(frac, "%i %%" % percent) self.progress.set_action("Processed %i %% of the action" % percent) if task_id: self.progress.tasks.set_extra_label(task_id, "%i %%" % percent) doGtkEvents() frac += 0.01 time.sleep(0.01) if frac > 1.0: break self.progress.set_action("Action Completed") doGtkEvents()
def run_tests(self): w, h = self.ui.Progress.get_size() # get the default size self.progress.set_title("Testing Progress - Title") doGtkEvents() time.sleep(1) self.progress.set_header("Testing Progress - Header") doGtkEvents() time.sleep(1) self.progress.set_action("Testing Progress - Action") doGtkEvents() time.sleep(1) self.test_bar() self.test_tasks() doGtkEvents() self.ui.Progress.resize(w, h) # shrink to the default size again self.progress.set_action("Testing Progress - Action") self.test_bar() self.test_show_hide() self.test_bar() time.sleep(3) self.main_quit()
def delay(self, time_to_sleep=5.0): steps = int(time_to_sleep / 0.1) for x in xrange(0,steps): doGtkEvents() time.sleep(0.1)