def suppress_gimp_progress(): """ Prevent the default progress bar in GIMP from updating by installing dummy progress callbacks. """ gimp.progress_install( pgutils.empty_func, pgutils.empty_func, pgutils.empty_func, pgutils.empty_func)
def install_progress_for_status( self, progress_set_value=None, progress_reset_value=None): """ Initialize the progress bar for the current item status to update according to GIMP PDB calls. """ if gimp.version >= (2, 9): return if progress_set_value is not None: self._progress_set_fraction_func = progress_set_value else: self._progress_set_fraction_func = self._progress_set_fraction if progress_reset_value is None: def progress_reset_value_default(*args): self._progress_set_fraction(0.0) progress_reset_value = progress_reset_value_default self._progress_callback = gimp.progress_install( progress_reset_value, progress_reset_value, pg.utils.empty_func, self._progress_set_value_for_status)
def suppress_gimp_progress(): """ Prevent the default progress bar in GIMP from updating by installing a dummy progress callback. Subsequent calls to this function without a matching call to `unsuppress_gimp_progress()` have no effect. """ global _dummy_progress_callback if _dummy_progress_callback: return _dummy_progress_callback = gimp.progress_install( pgutils.empty_func, pgutils.empty_func, pgutils.empty_func, pgutils.empty_func)
def suppress_gimp_progress(): """ Prevent the default progress bar in GIMP from updating by installing a dummy progress callback. Subsequent calls to this function without a matching call to `unsuppress_gimp_progress()` have no effect. """ global _dummy_progress_callback if _dummy_progress_callback: return _dummy_progress_callback = gimp.progress_install(pgutils.empty_func, pgutils.empty_func, pgutils.empty_func, pgutils.empty_func)
def install_progress_for_status(self, progress_set_value=None, progress_reset_value=None): """ Initialize the progress bar for the current item status to update according to GIMP PDB calls. """ if progress_set_value is None: progress_set_value = self._progress_set_value if progress_reset_value is None: def progress_reset_value_default(*args): progress_set_value(0.0) progress_reset_value = progress_reset_value_default self._progress_callback = gimp.progress_install( progress_reset_value, progress_reset_value, pgutils.empty_func, progress_set_value)
def showDialog(self): self.dialog = gimpui.Dialog("Multi export", "multi_export_dialog") self.table = gtk.Table(2, 4, True) self.table.set_homogeneous(True) self.table.set_row_spacings(5) self.table.set_col_spacings(5) self.table.show() #Config File label = gtk.Label(' '+_('Config File :')+' ') label.set_use_underline(True) label.show() self.table.attach(label, 0, 1, 0, 1) config_chooser_dialog = gtk.FileChooserDialog(title=_("Open a Yaml config file"), action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) config_chooser_dialog.set_default_response(gtk.RESPONSE_OK) filtre = gtk.FileFilter() filtre.set_name(_('Yaml config file')) #TODO : find the real(s) mime-type format filtre.add_mime_type('text/yaml') filtre.add_pattern("*.yaml") filtre.add_pattern("*.yml") config_chooser_dialog.add_filter(filtre) self.config_chooser = gtk.FileChooserButton(config_chooser_dialog) self.yaml_file = os.path.splitext(self.img.filename)[0]+'.yaml' #select yaml file on the same image directory if os.path.exists(self.yaml_file): self.config_chooser.set_filename(self.yaml_file) #else choose the path on image directory else: self.config_chooser.set_filename(os.path.dirname(self.img.filename)+'/*') self.config_chooser.show() self.table.attach(self.config_chooser, 1, 4, 0, 1) #Save Directory label = gtk.Label(' '+_('Save Directory :')+' ') label.set_use_underline(True) label.show() self.table.attach(label, 0, 1, 1, 2) chooser_dialog = gtk.FileChooserDialog(title=_('Open the destination directory'), action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) chooser_dialog.set_default_response(gtk.RESPONSE_OK) self.chooser = gtk.FileChooserButton(chooser_dialog) self.chooser.set_current_folder(os.path.dirname(self.img.filename)) self.chooser.show() self.table.attach(self.chooser, 1, 4, 1, 2) self.bar_progress = gimpui.ProgressBar() self.bar_progress.set_text(_('Processing ...')) self.dialog.vbox.hbox1 = gtk.HBox(False, 5) self.dialog.vbox.hbox1.show() self.dialog.vbox.pack_start(self.dialog.vbox.hbox1, False, False, 5) self.dialog.vbox.hbox1.pack_start(self.table, True, True, 5) self.dialog.vbox.hbox2 = gtk.HBox(False, 5) self.dialog.vbox.hbox2.show() self.dialog.vbox.pack_end(self.dialog.vbox.hbox2, False, False, 5) self.dialog.vbox.hbox2.pack_end(self.bar_progress, True, True, 5) self.bar_progress.show() cancel_button = self.dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) ok_button = self.dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) cancel_button.connect("clicked", self.cancel) ok_button.connect("clicked", self.validate) #progress self.process = gimp.progress_install(self.start_progress, self.end_progress,\ self.text_progress, self.value_progress) self.dialog.show() gtk.main()
def _suppress_gimp_progress(self): gimp.progress_install(lambda *args: None, lambda *args: None, lambda *args: None, lambda *args: None)
def _install_gimp_progress(self, progress_set_value, progress_reset_value): self._progress_callback = gimp.progress_install( progress_reset_value, progress_reset_value, lambda *args: None, progress_set_value)