我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用gtk.ProgressBar()。
def __init__(self, title, parent=None): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_modal(True) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_title(title) if parent: self.set_transient_for(parent) self.set_resizable(False) vbox = gtk.VBox(False, 2) self.label = gtk.Label("") self.label.set_size_request(100, 50) self.label.show() self.pbar = gtk.ProgressBar() self.pbar.show() vbox.pack_start(self.label, 0, 0, 0) vbox.pack_start(self.pbar, 0, 0, 0) vbox.show() self.add(vbox)
def __init__(self, msg, parent=None): gtk.Window.__init__(self) self.set_title("Please Wait") self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) if parent: self.set_transient_for(parent) self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) else: self.set_position(gtk.WIN_POS_CENTER) vbox = gtk.VBox(False, 2) l = gtk.Label(msg) l.show() vbox.pack_start(l) self.prog = gtk.ProgressBar() self.prog.show() vbox.pack_start(self.prog) vbox.show() self.add(vbox)
def __init__(self, rthread, parent=None): gtk.Dialog.__init__(self, title=_("Shift"), buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_OK)) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.rthread = rthread self.__prog = gtk.ProgressBar() self.__prog.show() self.__labl = gtk.Label("") self.__labl.show() self.vbox.pack_start(self.__prog, 1, 1, 1) self.vbox.pack_start(self.__labl, 0, 0, 0) self.quiet = False self.thread = None
def __init__(self): super(ProgressBarDetails, self).__init__() #Configure the Window self.set_resizable(False) self.connect("destroy", self.destroy_progress) self.set_title("Progress Bar") self.set_position(gtk.WIN_POS_CENTER) self.set_size_request(460, 150) self.set_border_width(0) #Create the VBox in case we want to add additional items later self.vbox = gtk.VBox(False, 5) self.vbox.set_border_width(10) self.add(self.vbox) self.vbox.show() #create the scrolled window self.scrolled_window =gtk.ScrolledWindow() self.scrolled_window.set_usize(460, 100) self.vbox.add(self.scrolled_window) self.scrolled_window.show() self.text_view = gtk.TextView() self.msg_i = 0 self.text_buffer = self.text_view.get_buffer() self.scrolled_window.add_with_viewport(self.text_view) self.text_view.connect("size-allocate", self.autoscroll) self.text_view.show() # Create the ProgressBar self.pbar = gtk.ProgressBar() #self.pbar.set_usize(460, 40) self.pbar.set_fraction(0.0) self.vbox.add(self.pbar) self.pbar.show() #Display the Window self.show()
def __init__(self): super(ProgressBar, self).__init__() #Configure the Window self.set_resizable(False) self.connect("destroy", self.destroy_progress) self.set_title("Progress Bar") self.set_position(gtk.WIN_POS_CENTER) self.set_size_request(460, 50) self.set_border_width(0) #Create the VBox in case we want to add additional items later vbox = gtk.VBox(False, 5) vbox.set_border_width(10) self.add(vbox) vbox.show() # Create the ProgressBar self.pbar = gtk.ProgressBar() self.pbar.set_fraction(0.0) self.pbar.set_text("Starting") vbox.add(self.pbar) self.pbar.show() #Display the Window self.show()
def __init__(self, window, title='', message=''): self.status = False self.dialog = gtk.Dialog(title, window, gtk.DIALOG_MODAL, ()) self.dialog.set_urgency_hint(False) self.label = gtk.Label() self.label.set_markup(message) self.dialog.vbox.pack_start(self.label) self.progress = gtk.ProgressBar() self.progress.set_pulse_step(0.01) self.dialog.vbox.pack_start(self.progress, False, False) self.button = gtk.Button(_("Cancel"), gtk.STOCK_CANCEL) self.button.connect("clicked", self.callback) self.dialog.vbox.pack_start(self.button, False, False) self.dialog.show_all()
def __init__(self, parser, max_tree_depth): self.parser = parser self._max_tree_depth = max_tree_depth self.search_thread = None self.search_lock = threading.Lock() self.name_entry = name_entry = gtk.Entry() name_entry.connect('activate', self.on_name_entry_activate) search_button = self.search_button = gtk.Button(stock=gtk.STOCK_FIND) search_button.connect('clicked', self.on_search) search_button.set_no_show_all(True) search_button.show() stop_button = self.stop_button = gtk.Button(stock=gtk.STOCK_STOP) stop_button.connect('clicked', self.stop_search) stop_button.set_no_show_all(True) self.progress = progress = gtk.ProgressBar() progress.set_size_request(-1, 8) name_box = gtk.HBox(spacing=8) name_box.set_border_width(8) name_box.pack_start(name_entry, True, True) name_box.pack_start(search_button, False) name_box.pack_start(stop_button, False) self.store = gtk.TreeStore(str, str, str, str) # name, icon, fnstyle, info self.treeview = treeview = self._create_treeview(self.store) scroller = gtk.ScrolledWindow() scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroller.add(treeview) settings_view = SettingsView(max_depth_value=max_tree_depth) settings_view.on_max_depth_changed = self.on_max_depth_changed extension = gtk.expander_new_with_mnemonic('_Settings') extension.add(settings_view.view) vbox = gtk.VBox() vbox.pack_start(name_box, False) vbox.pack_start(progress, False) vbox.pack_start(scroller, True, True) vbox.pack_start(extension, False) self.window = window = gtk.Window() window.set_title(Application.title) window.set_default_size(800, 600) window.set_icon(Application.get_icon()) window.add(vbox)
def __init__(self): progress = self.progress = gtk.ProgressBar() progress.set_text('Loading...') align = gtk.Alignment(0.5, 0.5, xscale=1.0) align.add(progress) window = self.window = gtk.Window() window.set_title(Application.title) window.set_border_width(8) window.add(align) window.set_default_size(400, 120) self._last_update_progress = 0.0
def __init__(self, **args): if "parent" in args: parent = args["parent"] del args["parent"] else: parent = None if "cancel" in args: cancel = args["cancel"] del args["cancel"] else: cancel = None gtk.Window.__init__(self, **args) self.set_transient_for(parent) self.set_modal(True) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) vbox = gtk.VBox(False, 2) vbox.show() self.add(vbox) self.set_title(_("Clone Progress")) self.set_resizable(False) self.infolabel = gtk.Label(_("Cloning")) self.infolabel.show() vbox.pack_start(self.infolabel, 1, 1, 1) self.progbar = gtk.ProgressBar() self.progbar.set_fraction(0.0) self.progbar.show() vbox.pack_start(self.progbar, 0, 0, 0) cancel_b = gtk.Button(_("Cancel")) cancel_b.connect("clicked", lambda b: cancel()) cancel_b.show() vbox.pack_start(cancel_b, 0, 0, 0)
def show_splash_screen(self, height=None, width=None, progress_bar=False, image=None, message=None, now=False): def show(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) vbox = gtk.VBox(False, 1) if message: lbl = gtk.Label() lbl.set_markup(message or '') lbl.set_alignment(0.5, 0.5) vbox.pack_start(lbl, True, True) else: lbl = None if image: self._set_background_image(vbox, image) if progress_bar: pbar = gtk.ProgressBar() pbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT) vbox.pack_end(pbar, False, True) else: pbar = None window.set_title(self.config.get('app_name', 'gui-o-matic')) window.set_decorated(False) window.set_position(gtk.WIN_POS_CENTER) window.set_size_request(width or 240, height or 320) window.add(vbox) window.show_all() self.hide_splash_screen(now=True) self.splash = { 'window': window, 'vbox': vbox, 'message': lbl, 'progress': pbar} if now: show(self) else: gobject.idle_add(show, self)