def getFilesToProcess(): root = tk.Tk() root.withdraw() root.update() d = Dialog(title="Select input for processing", text="Select file(s) or folder for processing", bitmap='question', strings=('Files', 'Folder', 'Cancel'), default=0) files = None if (d.num == 0): files = askopenfilename(title="Choose a set of file to process", multiple=1, filetypes=(("sqlite files", "*.sqlite"), ("all files", "*.*"))) if (d.num == 1): folder = askdirectory(title="Choose a directory to process") print("Folder: ", folder) folder = folder + "/**/*.sqlite" print("Fetching files...") files = [] for file in glob.glob(folder, recursive=True): print(file, "found.") files.append(file) d.destroy() root.destroy() return files
def show_dialog(self): dialog = Dialog(parent=self) if dialog.exec_(): # print dialog.name() + ' ' + dialog.sql_type() return_sql = self.create_sql(dialog.name(), dialog.sql_type()) if self.model.rowCount() > 0: self.model.removeRow(self.model.rowCount() - 1) self.model.appendRow(( QtGui.QStandardItem(return_sql) )) self.table.resizeColumnsToContents() # 将列调整到跟内容大小相匹配 dialog.destroy()
def getCsvFileToProcess(): root = tk.Tk() root.withdraw() root.update() d = Dialog(title="Select csv file for processing", text="Select csv file for processing", bitmap='question', strings=('File', 'Cancel'), default=0) root.focus_force() file = None if (d.num == 0): file = askopenfilename(title="Choose a csv file to process", multiple=0, filetypes=(("csv files", "*.csv"), ("all files", "*.*"))) d.destroy() root.destroy() return file
def destroy(self): self.entry = None Dialog.destroy(self)