def _done(): location = selectdir.get() do = msgbox.askyesno("确认?", "重命名操作不可逆,请确认是否继续?") if not do: return False functions.done(location, _file) location = location.replace("/", "\\") functions.openDir(location) functions.cleanTree(_file) functions.cleanTree(_operation) selectdir.set("") do = msgbox.askyesno("退出软件?", "成功重命名,退出软件?") if do: _exit()
def _restore(): if strarting: return None location = selectdir.get() restore, ret = True, True if not location: return _shownodir() if functions.isBig(location): restore = _askbig() if not restore: return None _toolmenu.entryconfig(0, state=DISABLED) _toolmenu.entryconfig(1, label="正在恢复中", state=DISABLED) try: ret = functions.restoreFilename(location) except FileNotFoundError: try: functions.restoreFilename(location, _askfile()) except: ret = False except: ret = False _toolmenu.entryconfig(0, state=NORMAL) _toolmenu.entryconfig(1, label="恢复文件名", state=NORMAL) if not ret: return _fail("恢复") functions.cleanTree(_file) functions.setFiletree(selectdir.get(), _file) return _success("恢复")
def _cleandir(): if not msgbox.askyesno("确认", "清除路径吗?"): return None selectdir.set("") functions.cleanTree(_file)
def _askdir(): newdir = filedialog.askdirectory() if not newdir: return None selectdir.set(newdir) functions.cleanTree(_file) functions.setFiletree(newdir, _file)
text="移除规则", image=_iconMinus, width=10, command=lambda: functions.removeSelect(_operation)) _infoRuleButton = Button(_rubtnFrame, compound=LEFT, text="规则预览", image=_iconInfo, width=10, command=_showPreview) _clearRuleButton = Button(_rubtnFrame, compound=LEFT, text="清空规则", image=_iconClear, width=10, command=lambda: functions.cleanTree(_operation)) _addRuleButton.pack(side=LEFT, padx=10) _removeRuleButton.pack(side=LEFT, padx=10) _infoRuleButton.pack(side=LEFT, padx=10) _clearRuleButton.pack(side=LEFT, padx=10) # 文件 Treeview _fileTitle = ("原文件名", "更改后文件名") _file = Treeview(_fileFrameS, height=8, columns=_fileTitle, show="headings", selectmode="extended") _fileScorllY = Scrollbar(_fileFrameS, orient=VERTICAL, command=_file.yview) _fileScorllX = Scrollbar(_fileFrame, orient=HORIZONTAL, command=_file.xview) _file.configure(yscrollcommand=_fileScorllY.set,