我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用gi.repository.Gtk.ProgressBar()。
def __init__(self,title,parent,max_value): # Gtk.Dialog.__init__(self,title,parent) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_size_request(330, 40) self.set_resizable(False) self.connect('destroy', self.close) # vbox1 = Gtk.VBox(spacing = 5) vbox1.set_border_width(5) self.get_content_area().add(vbox1) # self.progressbar = Gtk.ProgressBar() vbox1.pack_start(self.progressbar,True,True,0) # self.show_all() # self.max_value=max_value self.value=0.0 self.map() while Gtk.events_pending(): Gtk.main_iteration()
def __init__(self, title): Gtk.Window.__init__(self, title=title) self.set_border_width(10) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) self.add(vbox) self.progressbar = Gtk.ProgressBar() self.progressbar.pulse() self.progressbar.set_show_text(True) vbox.pack_start(self.progressbar, True, True, 0) self.timeout_id = GObject.timeout_add(50, self.on_timeout, None) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_deletable(False) self.set_decorated(False) self.set_resizable(False) self.set_keep_above(True) self.fraction = 0.0 self.pulse = True
def on_finished(self, download): for i in self.dlview: for a in i: if a.get_name() == download.get_destination(): if type(a) == Gtk.ModelButton: name = get_filename(download.get_destination()) a.get_child().set_markup("<span size='small'>{}: {}</span>".\ format(_("Download complete for"), minify(html.escape(name), 25))) if not self.downloads_menu.get_visible(): for i, item in enumerate(self.tabs): self.tabs[i][0].download_button.\ set_image(make_icon("notification.svg")) if type(a) == Gtk.ProgressBar: a.set_fraction(1.0) a.set_name("")
def create_progressbar_window(self): self.progressbar_window = Gtk.Window( title = "Planescape: Torment", type = Gtk.WindowType.TOPLEVEL, window_position = Gtk.WindowPosition.CENTER_ALWAYS, resizable = False, default_width = 360 ) self.progressbar = Gtk.ProgressBar( hexpand = True, show_text = True, text = _("Patching..."), pulse_step = 0.1, margin_top = 10, margin_bottom = 10, margin_left = 10, margin_right = 10 ) self.progressbar_window.add(self.progressbar)
def _build_vumeter(self): """ """ # TODO: True stereo feed has to be implemented. self.vumeter_left = Gtk.ProgressBar() self.vumeter_left.set_orientation(Gtk.Orientation.VERTICAL) self.vumeter_left.set_inverted(True) self.vumeter_right = Gtk.ProgressBar() self.vumeter_right.set_orientation(Gtk.Orientation.VERTICAL) self.vumeter_right.set_inverted(True) vumeter_hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL) vumeter_hbox.set_halign(Gtk.Align.END) vumeter_hbox.set_margin_top(6) vumeter_hbox.set_margin_bottom(6) _pack_widgets(vumeter_hbox, self.vumeter_left, self.vumeter_right) return vumeter_hbox
def get_file(self, widget): import re import ui.gtk3.common # Disable all the interface and Ok button. self.hbox.set_sensitive(False) self.options_hbox.set_sensitive(False) self.butt_ok.set_sensitive(False) # Progress bar self.progress_box = Gtk.VBox(False, 0) self.hseparator4 = Gtk.HSeparator() self.progress_bar = Gtk.ProgressBar() self.progress_box.pack_start(self.hseparator4, False, False, 0) self.progress_box.pack_start(self.progress_bar, False, False, 0) self.main_vbox.pack_start(self.progress_box, False, False, 2) self.progress_box.show_all() ui.gtk3.common.repaint() self.file = self.input_entry.get_child().get_text() if not re.match('^[a-z]+://', self.file): # It's a local file. self.manager.add_item('file://' + self.file) self.get_options() self.response(0)
def __init__(self, core: ApartCore, on_finish: Callable[[Dict], None]): """:param on_finish: called when job has received it's final message, with the this message as an arg""" self.core = core self.on_finish = on_finish self.last_message = None # Dict self.fail_message = None # Dict self.tenant = None # GridRowTenant self.start = None # datetime self.cancelling = False self.syncing = None # Gtk.Box # row 1 self.title_source = Gtk.Label('', xalign=0, visible=True) self.title_name = Gtk.Label('', xalign=0, visible=True) self.title_dest = Gtk.Label('', xalign=0, visible=True) self.title_box = Gtk.Box(visible=True) self.title_box.add(self.title_source) self.title_box.add(self.title_name) self.title_box.add(self.title_dest) self.cancel_btn = Gtk.Button('Cancel', visible=True, halign=Gtk.Align.END) self.cancel_btn.get_style_context().add_class('job-cancel-btn') self.cancel_btn.connect('clicked', self.cancel) # row 2 self.rate = key_and_val('Rate', '') self.rate.show_all() self.elapsed = key_and_val('Elapsed', '') self.elapsed.show_all() self.estimated_completion = key_and_val('Remaining', '') self.stats = Gtk.Box(visible=True) self.stats.add(self.elapsed) self.stats.add(self.rate) self.stats.add(self.estimated_completion) self.stats.get_style_context().add_class('job-stats') # row 3 self.progress_bar = Gtk.ProgressBar(hexpand=True, visible=True)
def on_created_destination(self, download, destination): name = get_filename(destination) unname = unparse(destination) item = Gtk.ModelButton(name=unname) item.set_alignment(0.0, 0.5) item.set_label("<span size='small'>{}: {}</span>\r<span size='x-small'>{}: {}</span>"\ .format(_("Downloading"), minify(html.escape(name), 50),\ _("In"), minify(html.escape(destination.replace("file://", "")), 50))) item.get_child().set_use_markup(True) item.get_child().set_padding(5, 5) item.connect("clicked", lambda x: subprocess.Popen\ ([app_launcher, os.path.dirname(destination)])) canc = make_button(make_icon("edit-delete.svg"), None, False) canc.connect("clicked", lambda x: [download.cancel(),\ self.dlview.remove(grid), self.on_cancel_download()]) rest = make_button(make_icon("refresh.svg"), None, False) rest.connect("clicked", lambda x: [download.cancel(),\ self.dlview.remove(grid), self.on_cancel_download(),\ self.on_restart_download(download)]) pbar = Gtk.ProgressBar(name=unname) grid = Gtk.Grid() grid.set_column_spacing(0) grid.attach(canc, 0, 0, 1, 1) grid.attach(rest, 1, 0, 1, 1) grid.attach(item, 2, 0, 1, 1) grid.attach(pbar, 2, 1, 1, 1) grid.set_column_homogeneous(False) self.dlview.add(grid) self.dlview.reorder_child(grid, 0) self.on_download_menu()
def get_progress_bar(self, download): for i in self.dlview: for a in i: if a.get_name() == download.get_destination(): if type(a) == Gtk.ProgressBar: return a
def __init__(self, view): StatusBar.__init__(self, view) self.installed_icon = Gtk.Image.new_from_icon_name( Icons.INSTALLED_OVERLAY, Gtk.IconSize.DIALOG) self.label = Gtk.Label() self.label.set_line_wrap(True) self.button = Gtk.Button() self.combo_multiple_versions = Gtk.ComboBoxText.new() model = Gtk.ListStore(str, str) self.combo_multiple_versions.set_model(model) self.combo_multiple_versions.connect( "changed", self._on_combo_multiple_versions_changed) self.progress = Gtk.ProgressBar() self.pkg_state = None self.hbox.pack_start(self.installed_icon, False, False, 0) self.hbox.pack_start(self.label, False, False, 0) self.hbox.pack_end(self.button, False, False, 0) self.hbox.pack_end(self.combo_multiple_versions, False, False, 0) self.hbox.pack_end(self.progress, False, False, 0) self.show_all() self.app_manager = get_appmanager() self.button.connect('clicked', self._on_button_clicked) GObject.timeout_add(500, self._pulse_helper)
def on_export(self, widget): iter = self.g_liststore.get_iter_first() all_files_ok = True while iter: if self.g_liststore.get(iter, self.STORE_FILENAME) == (None,): all_files_ok = False iter = self.g_liststore.iter_next(iter) if not all_files_ok: gu.dialog_ok("Can not run because some exercises are not found.") return export_to = \ self.select_empty_directory(_("Select where to export the files")) if not export_to: return progress_dialog = Gtk.Dialog(_("Exporting training set"), self, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) progress_dialog.show() label = Gtk.Label() label.set_markup('<span weight="bold">%s</span>' % gu.escape(_("Export training set"))) label.show() progress_dialog.vbox.pack_start(label, False, False, 0) def _cancel(widget, response): solfege.app.m_abort_export = True progress_dialog.connect('response', _cancel) progress_bar = Gtk.ProgressBar() progress_bar.show() progress_dialog.vbox.pack_start(progress_bar, True, True, 0) # We have to make a version of the data without gtk widgets v = [] iter = self.g_liststore.get_iter_first() while iter: v.append({ 'filename': \ unicode(self.g_liststore.get_value(iter, self.STORE_FILENAME)), 'count': self.g_liststore.get_value(iter, self.STORE_COUNT), 'repeat': self.g_liststore.get_value(iter, self.STORE_REPEAT), 'delay': self.g_liststore.get_value(iter, self.STORE_DELAY), }) iter = self.g_liststore.iter_next(iter) output_format = [k for k in self.g_output if self.g_output[k].get_active()][0] progress_dialog.queue_draw() while Gtk.events_pending(): Gtk.main_iteration() time.sleep(0.1) while Gtk.events_pending(): Gtk.main_iteration() try: for prog in solfege.app.export_training_set(v, export_to, output_format, self.g_named_tracks.get_active()): progress_bar.set_fraction(prog) while Gtk.events_pending(): Gtk.main_iteration() progress_dialog.destroy() except osutils.BinaryBaseException, e: progress_dialog.destroy() solfege.win.display_error_message2(e.msg1, e.msg2)
def create_co8_std_window(self): self.co8_std_window = Gtk.Window( title = _("The Temple of Elemental Evil"), type = Gtk.WindowType.TOPLEVEL, window_position = Gtk.WindowPosition.CENTER_ALWAYS, resizable = False, default_width = 480 ) self.co8_std_window.connect('delete-event', self.hide_co8_std_window) box = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, margin_top = 10, margin_bottom = 10, margin_left = 10, margin_right = 10, spacing = 10 ) linkbutton_download = Gtk.LinkButton( label = _("Download 'Circle of Eight Mopdack Standard Edition'"), uri = link_co8_modpack_std, ) linkbutton_put = Gtk.LinkButton( label = _("Put it here"), uri = 'file://' + download_dir + '/_distr/the_temple_of_elemental_evil', ) button_install = Gtk.Button(label=_("Install")) button_install.connect('clicked', self.cb_button_install_std) self.box_std = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, spacing = 10 ) self.box_std.pack_start(linkbutton_download, True, True, 0) self.box_std.pack_start(linkbutton_put, True, True, 0) self.box_std.pack_start(button_install, True, True, 0) self.progressbar_std = Gtk.ProgressBar( hexpand = True, show_text = True, text = _("Processing..."), pulse_step = 0.1, no_show_all = True ) box.pack_start(self.box_std, True, True, 0) box.pack_start(self.progressbar_std, True, True, 0) self.co8_std_window.add(box)
def create_co8_nc_window(self): self.co8_nc_window = Gtk.Window( title = _("The Temple of Elemental Evil"), type = Gtk.WindowType.TOPLEVEL, window_position = Gtk.WindowPosition.CENTER_ALWAYS, resizable = False, default_width = 480 ) self.co8_nc_window.connect('delete-event', self.hide_co8_nc_window) box = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, margin_top = 10, margin_bottom = 10, margin_left = 10, margin_right = 10, spacing = 10 ) linkbutton_download = Gtk.LinkButton( label = _("Download 'Circle of Eight Mopdack New Content Edition'"), uri = link_co8_modpack_nc, ) linkbutton_put = Gtk.LinkButton( label = _("Put it here"), uri = 'file://' + download_dir + '/_distr/the_temple_of_elemental_evil', ) button_install = Gtk.Button(label=_("Install")) button_install.connect('clicked', self.cb_button_install_nc) self.box_nc = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, spacing = 10 ) self.box_nc.pack_start(linkbutton_download, True, True, 0) self.box_nc.pack_start(linkbutton_put, True, True, 0) self.box_nc.pack_start(button_install, True, True, 0) self.progressbar_nc = Gtk.ProgressBar( hexpand = True, show_text = True, text = _("Processing..."), pulse_step = 0.1, no_show_all = True ) box.pack_start(self.box_nc, True, True, 0) box.pack_start(self.progressbar_nc, True, True, 0) self.co8_nc_window.add(box)
def create_co8_kob_window(self): self.co8_kob_window = Gtk.Window( title = _("The Temple of Elemental Evil"), type = Gtk.WindowType.TOPLEVEL, window_position = Gtk.WindowPosition.CENTER_ALWAYS, resizable = False, default_width = 480 ) self.co8_kob_window.connect('delete-event', self.hide_co8_kob_window) box = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, margin_top = 10, margin_bottom = 10, margin_left = 10, margin_right = 10, spacing = 10 ) linkbutton_download = Gtk.LinkButton( label = _("Download 'The Keep on the Borderlands'"), uri = link_co8_kob, ) linkbutton_put = Gtk.LinkButton( label = _("Put it here"), uri = 'file://' + download_dir + '/_distr/the_temple_of_elemental_evil', ) button_install = Gtk.Button(label=_("Install")) button_install.connect('clicked', self.cb_button_install_kob) self.box_kob = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, spacing = 10 ) self.box_kob.pack_start(linkbutton_download, True, True, 0) self.box_kob.pack_start(linkbutton_put, True, True, 0) self.box_kob.pack_start(button_install, True, True, 0) self.progressbar_kob = Gtk.ProgressBar( hexpand = True, show_text = True, text = _("Processing..."), pulse_step = 0.1, no_show_all = True ) box.pack_start(self.box_kob, True, True, 0) box.pack_start(self.progressbar_kob, True, True, 0) self.co8_kob_window.add(box)
def create_main_window(self): self.main_window = Gtk.Window( title = _("Pathologic Classic HD"), type = Gtk.WindowType.TOPLEVEL, window_position = Gtk.WindowPosition.CENTER_ALWAYS, resizable = False, default_width = 360 ) self.main_window.connect('delete-event', self.quit_app) frame_crop = Gtk.Frame( label = _("Crop videos (FFmpeg)"), label_xalign = 0.5, margin_left = 10, margin_right = 10, margin_top = 10, margin_bottom = 10 ) box_frame_crop = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, margin_left = 10, margin_right = 10, margin_top = 10, margin_bottom = 10, spacing = 10 ) self.combobox_crop = Gtk.ComboBoxText() self.combobox_crop.append_text(_("4:3 (no cropping)")) self.combobox_crop.append_text('16:9') self.combobox_crop.append_text('16:10') self.combobox_crop.set_active(self.crop) self.button_crop = Gtk.Button(label=_("Crop and quit")) self.button_crop.connect('clicked', self.cb_button_crop) self.progressbar = Gtk.ProgressBar( hexpand = True, show_text = True, text = _("Processing..."), pulse_step = 0.1, no_show_all = True ) box_frame_crop.pack_start(self.combobox_crop, True, True, 0) box_frame_crop.pack_start(self.button_crop, True, True, 0) box_frame_crop.pack_start(self.progressbar, True, True, 0) frame_crop.add(box_frame_crop) self.main_window.add(frame_crop) self.main_window.show_all()