def open_load_file_dialog(browser): nids = browser.selectedNotes() if nids: try: ext = ".csv" default_path = QStandardPaths.writableLocation( QStandardPaths.DocumentsLocation) path = os.path.join(default_path, f"changes{ext}") options = QFileDialog.Options() # native doesn't seem to works options |= QFileDialog.DontUseNativeDialog result = QFileDialog.getOpenFileName(browser, "Import CSV for Batch Update", path, f"CSV (*{ext})", options=options) if not isinstance(result, tuple): raise Exception("Expected a tuple from save dialog") file = result[0] if file: BatchUpdateDialog(browser, nids, file).exec_() except Exception as e: tooltip("Failed: {}".format(e)) else: tooltip("You must select some cards first")
def promot_choose_css(): for local_service in service_manager.local_services: try: missed_css = local_service.missed_css.pop() showInfo(Template.miss_css.format( dict=local_service.title, css=missed_css)) filepath = QFileDialog.getOpenFileName( caption=u'Choose css file', filter=u'CSS (*.css)')[0] if filepath: shutil.copy(filepath, u'_' + missed_css) wrap_css(u'_' + missed_css) local_service.missed_css.clear() except KeyError as e: pass
def promot_choose_css(): for local_service in service_manager.local_services: try: missed_css = local_service.missed_css.pop() showInfo( u'MDX dictonary <b>{dict}</b> misses css file <b>{css}</b>. <br />Please choose the file.'.format(dict=local_service.title, css=missed_css)) filepath = QFileDialog.getOpenFileName( caption=u'Choose css file', filter=u'CSS (*.css)') if filepath: shutil.copy(filepath, u'_' + missed_css) wrap_css(u'_' + missed_css) local_service.missed_css.clear() except KeyError as e: pass