def on_make_files(self, widget): """Callback for make files button""" file_count = self.file_count.get_value_as_int() output_dir = self.choose_folder_button.get_filename() delete_when_finished = self.when_finished_combo.get_active() == 0 inspiration = self.inspiration_combo.get_active() if not output_dir: dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CANCEL, _("Select destination folder")) dialog.run() dialog.destroy() return from bleachbit import options_dir if not have_models(): if not self.download_models_dialog(): return def _on_progress(fraction, msg, is_done): """Update progress bar from GLib main loop""" if msg: self.progressbar.set_text(msg) self.progressbar.set_fraction(fraction) if is_done: self.progressbar.hide() self.make_button.set_sensitive(True) def on_progress(fraction, msg=None, is_done=False): """Callback for progress bar""" # Use idle_add() because threads cannot make GDK calls. GLib.idle_add(_on_progress, fraction, msg, is_done) msg = _('Generating files') logger.info(msg) self.progressbar.show() self.progressbar.set_text(msg) self.progressbar.set_show_text(True) self.progressbar.set_fraction(0.0) self.make_button.set_sensitive(False) import threading args = (file_count, inspiration, output_dir, delete_when_finished, on_progress) t = threading.Thread(target=make_files_thread, args=args) t.start()
def test_have_models(self): rc = have_models() self.assertIsInstance(rc, bool)