class history_record(object): def __init__(self): self.win = Tk() self.width = 250 self.height = 200 self.win.title('历史记录') self.win.iconbitmap(LOGO) screenwidth = self.win.winfo_screenwidth() screenheight = self.win.winfo_screenheight() aligner = '%dx%d+%d+%d' % (self.width, self.height, (screenwidth - self.width) / 2, (screenheight - self.height) / 2) self.win.geometry(aligner) self.db = Mongodb_server(mongo_host, mongo_port) def handle(self, *args): return self.db.search_one(f"record", self.comboxlist.get(), {"_id": 0, "destination": 1, "local": 1, "source": 1}) @staticmethod def _db_record(): return {"_id": 0, "destination": 1, "local": 1, "source": 1} def _exit_win(self): self.win.quit() def ok(self): Transmit().arg_down(self.handle()['destination'], self.handle()['source'], self.handle()['local']) showinfo('提示', '还原成功') self._exit_win() def del_data(self): self.db.del_key('record', self.comboxlist.get(), self._db_record()) exit() def _win(self): time_list = [] comvalue = StringVar() # 窗体自带的文本,新建一个值 self.comboxlist = Combobox(self.win, textvariable=comvalue, state='readonly') # 初始化 for get_time in get_db_table(): time_list.append( f"{get_time[0:4]}-{get_time[4:6]}-{get_time[6:8]} {get_time[8:10]}:{get_time[10:12]}:{get_time[12:14]}" ) self.comboxlist["values"] = tuple(time_list) self.comboxlist.current(0) # 选择第一个 self.comboxlist.bind("<<ComboboxSelected>>", self.handle) # 绑定事件,(下拉列表框被选中时,绑定handle()函数) self.comboxlist.place(relx=0.2, rely=0.25, width=150, height=40) # noinspection PyPep8Naming def main(self): self._win() self.win.mainloop()
class delete_tasks(object): def __init__(self): self.win = Tk() self.width = 250 self.height = 200 self.win.title('选择任务') self.win.iconbitmap(LOGO) screenwidth = self.win.winfo_screenwidth() screenheight = self.win.winfo_screenheight() aligner = '%dx%d+%d+%d' % (self.width, self.height, (screenwidth - self.width) / 2, (screenheight - self.height) / 2) self.win.geometry(aligner) self.db = Mongodb_server(mongo_host, mongo_port) def handle(self, *args): name = self.db.search_one(f"tasks", self.comboxlist.get(), { "_id": 0, 'begin': 1, 'end': 1, 'folder': 1 }) data = {"folder": name['folder']} return data def _exit_win(self): self.win.quit() def ok(self): self.db.del_key('tasks', self.comboxlist.get(), self.handle()) self._win() def _win(self): comvalue = StringVar() # 窗体自带的文本,新建一个值 self.comboxlist = Combobox(self.win, textvariable=comvalue, state='readonly') # 初始化 self.comboxlist["values"] = tuple(get_db_table()) try: self.comboxlist.current(0) # 选择第一个 except: showerror('运行错误', '没有任务') self.win.quit() self.comboxlist.bind("<<ComboboxSelected>>", self.handle) # 绑定事件,(下拉列表框被选中时,绑定handle()函数) self.comboxlist.place(relx=0.2, rely=0.25, width=140, height=35) # noinspection PyPep8Naming def main(self): self._win() Button(self.win, text='删除', command=self.ok).place(relx=0.05, rely=0.75, width=70, height=30) Button(self.win, text='取消', command=self._exit_win).place(relx=0.68, rely=0.75, width=70, height=30) self.win.mainloop()
from config.MongoDB_Config import * windll.shell32.SetCurrentProcessExplicitAppUserModelID('version') with open('version', 'r') as f: tk_title = f'OpenBackup{f.read()}' LOGO = r'./main.ico' BACKUP_PATH = r'.\backups' TEMP_PATH = r".\Temp" # 加载任务 mongodb = Mongodb_server(mongo_host, mongo_port) try: READ_DB = str( mongodb.search_one('tasks', mongodb.search_table('select')[0], {"_id": 0, 'folder': 1})['folder']).replace('/', '\\') except Exception: READ_DB = '/' def about_main(): showinfo(tk_title, ' 本程序使用GPL 3.0协议开源\n ' ' 软件的诞生离不开以下开源软件的支持\n ' ' @ Python3.7 \n ' ' 7z 压缩 \n ' ' SQLite \n' ' MongoDB \n' ' Tkinter GUI \n ' ' OpenSSH \n ' ' Notepad2 \n' ' https://github.com/zhaori/OpenBackup')