class UI(object): def __init__(self, args): self.root = Tk() self.args = args # Make it invisible # - 0 size, top left corner, transparent. self.root.attributes('-alpha', 0.0) self.root.geometry('0x0+0+0') # "Show" window again and lift it to top so it can get focus, # otherwise dialogs will end up behind other windows self.root.deiconify() self.root.lift() self.root.focus_force() def selectFolder(self, **options): """ Show a folder selection window for the user to import an addon """ if self.args.addon_path is None: selected_addon_dir_path = tkFileDialog.askdirectory( parent=self.root, **options) else: selected_addon_dir_path = self.args.addon_path return selected_addon_dir_path def success(self, action): message = addon_import_success_message.format(action.lower()) print(message) if self.args.addon_path is None: tkMessageBox.showinfo(message=message) def cancel(self, action): message = addon_import_cancel_message.format(action.lower()) print(message) if self.args.addon_path is None: tkMessageBox.showinfo(message=message) sys.exit(0) def fail(self, msg): print(msg) if self.args.addon_path is None: tkMessageBox.showerror(message=msg) sys.exit(1) def confirmAction(self, addon_name): proceed = True info = addon_select_info_message.format(addon_name, self.args.project, self.args.workspace) print(info) if self.args.addon_path is None: proceed = tkMessageBox.askokcancel('Attention!', info) print(proceed) return proceed
class UI(object): def __init__(self, args): self.root = Tk() # Make it invisible # - 0 size, top left corner, transparent. self.root.attributes('-alpha', 0.0) self.root.geometry('0x0+0+0') try: qmde_icon = os.path.join(args.devkit, 'res', 'q_logo.ico') self.root.iconbitmap(bitmap=qmde_icon) except TclError: pass # "Show" window again and lift it to top so it can get focus, # otherwise dialogs will end up behind other windows self.root.deiconify() self.root.lift() self.root.focus_force() def selectFolder(self, **options): """ Show a folder selection window for the user to import/export private pre-built libraries """ return tkFileDialog.askdirectory(parent=self.root, **options) def selectFile(self, **options): """ Show a folder selection window for the user to import/export private pre-built libraries """ return tkFileDialog.askopenfilename(parent=self.root, **options) def success(self, action): message = 'Library {} operation succesful'.format(action.lower()) print(message) tkMessageBox.showinfo(message=message) def cancel(self, action): message = 'Library {} operation cancelled'.format(action.lower()) print(message) tkMessageBox.showinfo(message=message) sys.exit(0) def fail(self, msg): print(msg) tkMessageBox.showerror(message=msg) sys.exit(1) def confirmAction(self, action, header, archive): proceed = True header_base = os.path.basename(header) archive_base = os.path.basename(archive) info = "About to {} files:\n--{}\n--{}\n\n" \ .format(action.lower(), header_base, archive_base) question = "Proceed?" print(info + question) proceed = tkMessageBox.askokcancel('Attention!', info + question) print(proceed) return proceed def proceedDstFileExists(self, dst_dir, dst_file): dst_file = os.path.join(dst_dir, dst_file) proceed = True if os.path.isfile(dst_file): info = 'File: \n--{}\n\nalready exists at destination' \ .format(dst_file) question = "Proceed?" proceed = tkMessageBox.askokcancel('Attention!', info + question) return proceed