def __init__(self): clear() name1=Label(inputFrame,text="Xlsx folder:") name2=Label(inputFrame,text="Dbs folder:") name1.grid(row=0,padx=2,sticky='w') name2.grid(row=2,padx=2,sticky='w') value1.set("dbsData") value2.set("") entry1=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value1) entry2=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value2) entry1.grid(row=1,column=0,padx=2) entry2.grid(row=3,column=0,padx=2) button1=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFolder(value1)) button2=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFolder(value2)) button1.grid(row=1,column=1,padx=2) button2.grid(row=3,column=1,padx=2) windnd.hook_dropfiles(entry1,dropValue1) windnd.hook_dropfiles(entry2,dropValue2) valueB.set(True) buttonB=Frame(inputFrame) buttonB.grid(row=6,column=0,padx=2,pady=4,sticky='e') buttonB1=Radiobutton(buttonB,text="ANSI(GBK)",variable=valueB,value=False) buttonB2=Radiobutton(buttonB,text="Unicode",variable=valueB,value=True) buttonB1.grid(row=8,column=1,sticky='w') buttonB2.grid(row=8,column=2,sticky='w') valueC.set('17') nameC=Label(inputFrame,text="Compression Level(2-17, 0 for Fake Compression): ") nameC.grid(row=7,padx=2,pady=4,sticky='e') entryC=Entry(inputFrame,width=4,textvariable=valueC) entryC.grid(row=7,column=1,padx=2,pady=4)
def initView(self): # py self.text = tk.Text(self.win, bd=5) self.text.place(x=0, y=0, width=400, height=100) windnd.hook_dropfiles(self.text, func=self.OnDragFile) self.btn = tk.Button(self.win, text="将py文件拖入上框或者点我选择文件", command=self.OnBtnClick) self.btn.place(x=0, y=100, width=400, height=40) # ico self.iconText = tk.Text(self.win, bd=5) self.iconText.place(x=0, y=200, width=400, height=100) windnd.hook_dropfiles(self.iconText, func=self.OnDragIconFile) self.iconBtn = tk.Button(self.win, text="将图标拖入上框或者点我选择文件\n没有则使用默认图标", command=self.OnIconBtnClick) self.iconBtn.place(x=0, y=300, width=400, height=40) #save self.saveEntry = tk.Entry(self.win, bd=5) self.saveEntry.place(x=0, y=400, width=400, height=50) self.saveBtn = tk.Button(self.win, text="点我选择保存地址\n没有则保存本exe相同目录", command=self.OnSaveBtnClick) self.saveBtn.place(x=0, y=450, width=400) # do self.doBtn = tk.Button(self.win, text="生成exe", command=self.OnDoBtnClick) self.doBtn.place(x=0, y=500)
def __init__(self): clear() name1 = Label(inputFrame, text="Dbs.out file:") name2 = Label(inputFrame, text="Dbs.txt file:") name1.grid(row=0, padx=2, sticky='w') name2.grid(row=2, padx=2, sticky='w') value1.set("*.dbs.out") value2.set("") entry1 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value1) entry2 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value2) entry1.grid(row=1, column=0, padx=2) entry2.grid(row=3, column=0, padx=2) button1 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: selectFile(value1)) button2 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: selectFile(value2)) button1.grid(row=1, column=1, padx=2) button2.grid(row=3, column=1, padx=2) windnd.hook_dropfiles(entry1, dropValue1) windnd.hook_dropfiles(entry2, dropValue2) valueC.set('17') nameC = Label(inputFrame, text="Compression Level(2-17, 0 for Fake Compression): ") nameC.grid(row=7, padx=2, pady=4, sticky='e') entryC = Entry(inputFrame, width=4, textvariable=valueC) entryC.grid(row=7, column=1, padx=2, pady=4)
def init_work(self): """ 初始化工作区域 """ self.work.pack() self.work_input_cv.create_text(self.width / 2, self.height / 2, text='拖拽图片到此处', fill='grey', anchor='center') self.work_input_cv.pack(side='left') # 点击并移动鼠标, 测量距离 self.work_input_cv.bind('<Button-1>', lambda event: self.line.click(event, self)) self.work_input_cv.bind("<B1-Motion>", lambda event: self.line.move(event, self)) self.work_input_cv.bind("<ButtonRelease-1>", lambda event: self.line.release(event, self)) windnd.hook_dropfiles(self.work_input_cv, func=self.drag_input) # 将拖拽图片与wa_input_cv组件挂钩 self.work_output_cv.pack(side='right')
def __init__(self): clear() name1 = Label(inputFrame, text="Gameexe:") name2 = Label(inputFrame, text="Output file:") name1.grid(row=0, padx=2, sticky='w') name2.grid(row=2, padx=2, sticky='w') value1.set("Gameexe.ini") value2.set("Gameexe.dat2") entry1 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value1) entry2 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value2) entry1.grid(row=1, column=0, padx=2) entry2.grid(row=3, column=0, padx=2) button1 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: selectFile(value1)) button2 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: setFile(value2)) button1.grid(row=1, column=1, padx=2) button2.grid(row=3, column=1, padx=2) windnd.hook_dropfiles(entry1, self.dropValue1) windnd.hook_dropfiles(entry2, dropValue2) valueC.set('17') nameC = Label(inputFrame, text="Compression Level(2-17, 0 for Fake Compression): ") nameC.grid(row=7, padx=2, pady=4, sticky='e') entryC = Entry(inputFrame, width=4, textvariable=valueC) entryC.grid(row=7, column=1, padx=2, pady=4) valueB.set(False) buttonB = Checkbutton(inputFrame, text="Double Encryption(Useless)", variable=valueB) buttonB.grid(row=8, padx=2, pady=4, sticky='e')
def __init__(self): def checkEnable(): if valueB2.get(): valueB1.set(True) buttonB1['state'] = 'disabled' else: buttonB1['state'] = 'normal' clear() name1 = Label(inputFrame, text="Dbs file:") name1.grid(row=0, padx=2, sticky='w') value1.set("*.dbs") entry1 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value1) entry1.grid(row=1, column=0, padx=2) button1 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: selectFile(value1)) button1.grid(row=1, column=1, padx=2) windnd.hook_dropfiles(entry1, dropValue1) valueB1.set(False) valueB2.set(False) buttonB = Frame(inputFrame) buttonB.grid(row=6, column=0, padx=2, pady=4, sticky='e') buttonB1 = Checkbutton(buttonB, text="Export all data", variable=valueB1) buttonB2 = Checkbutton(buttonB, text="Export as xlsx", command=checkEnable, variable=valueB2) buttonB1.grid(row=0, column=0, sticky='w') buttonB2.grid(row=0, column=1, sticky='e')
def __init__(self): clear() name1=Label(inputFrame,text="OMV file:") name1.grid(row=0,padx=2,sticky='w') value1.set("*.omv") entry1=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value1) entry1.grid(row=1,column=0,padx=2) button1=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFile(value1)) button1.grid(row=1,column=1,padx=2) windnd.hook_dropfiles(entry1,dropValue1)
def set_init_window(self): screen_width = self.init_window_name.winfo_screenwidth() screen_height = self.init_window_name.winfo_screenheight() window_width = 1000 window_height = 680 posX = int((screen_width - window_width) * .5) posY = int((screen_height - window_height) * .5) self.init_window_name.title("ass->srt转换工具") self.init_window_name.geometry( str(window_width) + 'x' + str(window_height) + '+' + str(posX) + '+' + str(posY)) frame1 = Frame(width=800, height=100, bd=1, relief="sunken") frame1.pack(fill=BOTH, padx=50, pady=40, expand=False) frame2 = Frame(width=800, height=100, bd=0, relief="sunken") frame2.pack(fill=BOTH, padx=50, pady=0, expand=False) windnd.hook_dropfiles(frame1, func=dragged_files) global labelInfo labelInfo = Label(frame1, text="将文件或文件夹拖入此处", width=50, height=15) labelInfo.pack(expand=FALSE, fill=BOTH) curPath = os.path.dirname(__file__) finalPath = os.path.join(curPath, "img/btn_start.png") global image image = PhotoImage(file=finalPath) global icon iconPath = os.path.join(curPath, "img/icon.ico") icon = PhotoImage(iconPath) self.init_window_name.iconbitmap(icon) #窗口名 global btnStart btnStart = Button(frame2, text="转换", image=image, bd=0, relief=FLAT, command=btnConvertCBK) btnStart.pack(side=LEFT, pady=2) btnStart["state"] = DISABLED finalPath = os.path.join(curPath, "img/btn_clear.png") global image2 image2 = PhotoImage(file=finalPath) btnClear = Button(frame2, text="清除", image=image2, bd=0, relief=FLAT, command=btnClearCBK) btnClear.pack(side=LEFT, pady=2, padx=10) btnClear["state"] = NORMAL
def __init__(self): def checkEnable(): if valueB1.get(): buttonB2['state']='normal' else: valueB2.set(False) checkName() buttonB2['state']='disabled' def checkName(): if valueB2.get(): name2['text']='Output file:' else: name2['text']="Output folder:" def outSelect(): if valueB2.get(): setFile(value2) else: selectFolder(value2) clear() name1=Label(inputFrame,text="Ss folder:") name2=Label(inputFrame,text="Output folder:") name1.grid(row=0,padx=2,sticky='w') name2.grid(row=2,padx=2,sticky='w') value1.set("Scene") value2.set("Text") entry1=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value1) entry2=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value2) entry1.grid(row=1,column=0,padx=2) entry2.grid(row=3,column=0,padx=2) button1=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFolder(value1)) button2=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=outSelect) button1.grid(row=1,column=1,padx=2) button2.grid(row=3,column=1,padx=2) windnd.hook_dropfiles(entry1,self.dropValue1) windnd.hook_dropfiles(entry2,dropValue2) valueB.set(False) valueB1.set(False) valueB2.set(False) valueB3.set(True) buttonB=Frame(inputFrame) buttonB.grid(row=6,column=0,padx=2,pady=4,sticky='w') buttonB3=Checkbutton(buttonB,text="Copy text",variable=valueB3) buttonB0=Checkbutton(buttonB,text="Export all data",variable=valueB) buttonB1=Checkbutton(buttonB,text="Export as xlsx",command=checkEnable,variable=valueB1) buttonB2=Checkbutton(buttonB,text="Use single xlsx",state='disabled',command=checkName,variable=valueB2) buttonB3.grid(row=0,column=0,sticky='w') buttonB0.grid(row=0,column=1,sticky='w') buttonB1.grid(row=0,column=2,sticky='e') buttonB2.grid(row=0,column=3,sticky='e')
def setVirtualDrive(): root = tk.Tk() root.title("Set Virtual Drive") root.resizable(0, 0) label1 = tk.Label(root, text="Paste or Drag the address into:") entry1 = tk.Entry(root, width=50) frame1 = tk.Frame(root) label2 = tk.Label(frame1, text="Drive:") entry2 = tk.Entry(frame1, width=3) def dragFunc(ls): entry1.delete(0, tk.END) for i in ls: entry1.insert("end", i.decode("gbk") + '\n') def cmdCall(): # print (entry1.get()) os.popen("start cmd /c \"subst " + entry2.get() + ": " + entry1.get() + "&&subst\"") entry1.delete(0, tk.END) entry2.delete(0, tk.END) entry1.insert(0, "E:\Code\GoPath") entry2.insert(0, "G") def cmdCalloff(): # print (entry1.get()) os.popen("start cmd /c \"subst " + entry2.get()\ + ": /D\"") windnd.hook_dropfiles(entry1.winfo_id(), dragFunc) label1.pack(padx=10, pady=6, anchor='w') entry1.pack(padx=13, pady=5, anchor='w') frame1.pack(padx=10, pady=5) entry1.insert(0, "E:\Code\EAP") entry2.insert(0, "N") label2.grid(row=0, column=0, padx=0, pady=6) entry2.grid(row=0, column=1, padx=10, pady=6) button1 = tk.Button(frame1, width = 12, text = "Load",\ command = cmdCall) button2 = tk.Button(frame1, width = 12, text = "Unload",\ command = cmdCalloff) button1.grid(row=0, column=2, padx=40, pady=6) button2.grid(row=0, column=3, padx=7, pady=6) root.mainloop()
def __init__(self): clear() name1=Label(inputFrame,text="ogv file(Must be YUV444p):") name2=Label(inputFrame,text="OMV file:") name1.grid(row=0,padx=2,sticky='w') name2.grid(row=2,padx=2,sticky='w') value1.set("*.ogv") value2.set("") entry1=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value1) entry2=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value2) entry1.grid(row=1,column=0,padx=2) entry2.grid(row=3,column=0,padx=2) button1=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFile(value1)) button2=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFile(value2)) button1.grid(row=1,column=1,padx=2) button2.grid(row=3,column=1,padx=2) windnd.hook_dropfiles(entry1,self.dropValue1) windnd.hook_dropfiles(entry2,dropValue2)
def __init__(self): clear() name1=Label(inputFrame,text="Scene file:") name2=Label(inputFrame,text="Scene folder:") name3=Label(inputFrame,text="Output file:") name1.grid(row=0,padx=2,sticky='w') name2.grid(row=2,padx=2,sticky='w') name3.grid(row=4,padx=2,sticky='w') value1.set("Scene.pck") value2.set("Scene") value3.set("Scene.pck2") entry1=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value1) entry2=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value2) entry3=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value3) entry1.grid(row=1,column=0,padx=2) entry2.grid(row=3,column=0,padx=2) entry3.grid(row=5,column=0,padx=2) button1=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFile(value1)) button2=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFolder(value2)) button3=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:setFile(value3)) button1.grid(row=1,column=1,padx=2) button2.grid(row=3,column=1,padx=2) button3.grid(row=5,column=1,padx=2) windnd.hook_dropfiles(entry1,self.dropValue1) windnd.hook_dropfiles(entry2,dropValue2) windnd.hook_dropfiles(entry3,dropValue3) valueC.set('17') nameC=Label(inputFrame,text="Compression Level(2-17, 0 for Fake Compression): ") nameC.grid(row=7,padx=2,pady=4,sticky='e') entryC=Entry(inputFrame,width=4,textvariable=valueC) entryC.grid(row=7,column=1,padx=2,pady=4)
def __init__(self): clear() name1=Label(inputFrame,text="Ss folder:") name2=Label(inputFrame,text="Text folder:") name3=Label(inputFrame,text="Output folder:") name1.grid(row=0,padx=2,sticky='w') name2.grid(row=2,padx=2,sticky='w') name3.grid(row=4,padx=2,sticky='w') value1.set("Scene") value2.set("Text") value3.set("Output") entry1=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value1) entry2=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value2) entry3=Entry(inputFrame,width=ENTRY_WIDTH,textvariable=value3) entry1.grid(row=1,column=0,padx=2) entry2.grid(row=3,column=0,padx=2) entry3.grid(row=5,column=0,padx=2) button1=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFolder(value1)) button2=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFolder(value2)) button3=Button(inputFrame,text="Select",width=BUTTON_WIDTH,command=lambda:selectFolder(value3)) button1.grid(row=1,column=1,padx=2) button2.grid(row=3,column=1,padx=2) button3.grid(row=5,column=1,padx=2) windnd.hook_dropfiles(entry1,self.dropValue1) windnd.hook_dropfiles(entry2,dropValue2) windnd.hook_dropfiles(entry3,dropValue3) valueB.set(True) buttonB=Checkbutton(inputFrame,text="Have Excel text file",variable=valueB) buttonB.grid(row=8,padx=2,pady=4,sticky='e')
def __init__(self): def checkEnable(): if valueB.get(): buttonB1['state'] = 'normal' else: valueB1.set(False) buttonB1['state'] = 'disabled' clear() name1 = Label(inputFrame, text="Ss folder:") name2 = Label(inputFrame, text="Text folder:") name3 = Label(inputFrame, text="Output folder:") name1.grid(row=0, padx=2, sticky='w') name2.grid(row=2, padx=2, sticky='w') name3.grid(row=4, padx=2, sticky='w') value1.set("Scene") value2.set("Text") value3.set("Output") entry1 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value1) entry2 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value2) entry3 = Entry(inputFrame, width=ENTRY_WIDTH, textvariable=value3) entry1.grid(row=1, column=0, padx=2) entry2.grid(row=3, column=0, padx=2) entry3.grid(row=5, column=0, padx=2) button1 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: selectFolder(value1)) button2 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: selectFolder(value2)) button3 = Button(inputFrame, text="Select", width=BUTTON_WIDTH, command=lambda: selectFolder(value3)) button1.grid(row=1, column=1, padx=2) button2.grid(row=3, column=1, padx=2) button3.grid(row=5, column=1, padx=2) windnd.hook_dropfiles(entry1, self.dropValue1) windnd.hook_dropfiles(entry2, dropValue2) windnd.hook_dropfiles(entry3, dropValue3) valueB.set(True) valueB1.set(False) valueB2.set(False) buttonB = Frame(inputFrame) buttonB.grid(row=8, padx=2, pady=4, sticky='w') buttonB0 = Checkbutton(buttonB, text="Have Excel text", command=checkEnable, variable=valueB) buttonB1 = Checkbutton(buttonB, text="Bilingual display (For mobile only)", variable=valueB1) buttonB2 = Checkbutton(buttonB, text="Change quotation marks", variable=valueB2) buttonB0.grid(row=0, column=0, sticky='w') buttonB1.grid(row=0, column=1, sticky='w') buttonB2.grid(row=1, column=0, sticky='e')
filesFilters = [i for i in files if os.path.isfile(i)] filesList = '; '.join((i for i in filesFilters)) videoFilesVar.set(filesList) def outputPathEntry_MouseDrag(path): if os.path.isdir(path[0]): outputPathVar.set(path[0]) def ffParam_MouseDrag(files): with open(files[0], "r", encoding='utf-8') as r: try: text = r.read() except: text = '' ffParam.delete(1.0, END) ffParam.insert(1.0, text) windnd.hook_dropfiles(ffmpegInstallPath, func=ffmpegInstallPath_MouseDrag, force_unicode=1) windnd.hook_dropfiles(videoFilesEntry, func=videoFilesEntry_MouseDrag, force_unicode=1) windnd.hook_dropfiles(outputPathEntry, func=outputPathEntry_MouseDrag, force_unicode=1) windnd.hook_dropfiles(ffParam, func=ffParam_MouseDrag, force_unicode=1) tkGUIPosition(tk, 20, 20) tk.mainloop()
def __init__(self, funcFrame, dispatcher, name, color): self.name = name self.color = color self.frame = tk.Frame(funcFrame, bg=self.color) self.frame.place(relx=0, rely=0, relwidth=1, relheight=1) #----------------------------- # Parameter #----------------------------- filePath = tk.StringVar() minScale = tk.StringVar() minScale.set("0.7") maxScale = tk.StringVar() maxScale.set("1.3") minHoriAverage = tk.StringVar() minHoriAverage.set("4") signal = td.Event() signal.set() fa = tk.IntVar() mo = tk.IntVar() candidateList = ttk.Combobox(self.frame, value=()) candidateFa = tk.Checkbutton(self.frame, text='father', variable=fa) candidateMo = tk.Checkbutton(self.frame, text='mother', variable=mo) processBar = ttk.Progressbar(self.frame, mode="determinate", orient="horizontal") reportBoard = tk.Label(self.frame, bg='Ivory', anchor='nw', justify='left') def setFilePath(path): filePath.set(path[0].decode()) def openFile(): if not signal.isSet(): return fileTypeList = [('XLSX', '.xlsx'), ('XLS', '.xls')] filePath.set(tkf.askopenfilename(filetypes=fileTypeList)) def parseFile(): if not signal.isSet(): return path = filePath.get() if not path: dispatcher.warning( "There is no selected file.Please input the file path!\n") elif path[-4:] != '.xls' and path[-5:] != '.xlsx': dispatcher.error("The file type is not supported!\n") else: signal.clear() processBar["value"] = 0 reportBoard["text"] = "" dispatcher.information("Parsing the file:%s\n" % path) dispatcher.openDataFile(path, candidateList, signal, processBar, self.frame) def analyzeData(): if not signal.isSet(): return id = candidateList.get() min = minScale.get() max = maxScale.get() minHori = minHoriAverage.get() if not id: dispatcher.warning("Please select the candidate id\n") elif not min: dispatcher.warning("Please fill the min scale\n") elif not max: dispatcher.warning("Please fill the max scale\n") elif not minHori: dispatcher.warning("Please fill the hori average\n") else: try: min = float(min) max = float(max) minHori = float(minHori) flagFa = fa.get() flagMo = mo.get() except ValueError: dispatcher.error( "Please check the minScale, maxScale or horiAverage value\n" ) return dispatcher.information( "Analyzing the Ge data of id:%s fa:%s mo:%s minScale:%s maxScale:%s minHoriAverage:%s\n" % (id, flagFa, flagMo, str(min), str(max), str(minHori))) signal.clear() processBar["value"] = 0 reportBoard["text"] = "" dispatcher.analyzeData(id, max, min, minHori, reportBoard, signal, processBar, self.frame, flagFa, flagMo) def generateReport(): if not signal.isSet(): return if not reportBoard['text']: dispatcher.warning( "There is no any report have been generated\n") return filePath = tkf.asksaveasfilename( filetypes=[('TXT', '.txt'), ('All Type', '.*')]) fileHandle = open(filePath, 'w', encoding='utf-8') signal.clear() dispatcher.generateReport(fileHandle, signal, processBar, self.frame) #----------------------------- # Layout #----------------------------- tk.Label(self.frame, text='File:').place(relx=0.01, rely=0.05, relwidth=0.06, relheight=0.06) pathInputObject = tk.Entry(self.frame, textvariable=filePath) pathInputObject.place(relx=0.07, rely=0.05, relwidth=0.66, relheight=0.06) # support drop files into entry wd.hook_dropfiles(pathInputObject.winfo_id(), func=setFilePath) tk.Button(self.frame, text='open', command=openFile).place(relx=0.75, rely=0.05, relwidth=0.12, relheight=0.06) tk.Button(self.frame, text='parse', command=parseFile).place(relx=0.88, rely=0.05, relwidth=0.12, relheight=0.06) tk.Label(self.frame, text='Candidate:').place(relx=0.01, rely=0.15, relwidth=0.1, relheight=0.06) candidateList.place(relx=0.11, rely=0.15, relwidth=0.12, relheight=0.06) candidateFa.place(relx=0.23, rely=0.15, relwidth=0.08, relheight=0.06) candidateMo.place(relx=0.31, rely=0.15, relwidth=0.09, relheight=0.06) tk.Label(self.frame, text='Min Scale:').place(relx=0.41, rely=0.15, relwidth=0.1, relheight=0.06) tk.Entry(self.frame, textvariable=minScale).place(relx=0.51, rely=0.15, relwidth=0.05, relheight=0.06) tk.Label(self.frame, text='Max Scale:').place(relx=0.56, rely=0.15, relwidth=0.1, relheight=0.06) tk.Entry(self.frame, textvariable=maxScale).place(relx=0.66, rely=0.15, relwidth=0.05, relheight=0.06) tk.Label(self.frame, text='Hori Average:').place(relx=0.71, rely=0.15, relwidth=0.12, relheight=0.06) tk.Entry(self.frame, textvariable=minHoriAverage).place(relx=0.83, rely=0.15, relwidth=0.05, relheight=0.06) tk.Button(self.frame, text='analyze', command=analyzeData).place(relx=0.88, rely=0.15, relwidth=0.12, relheight=0.06) processBar.place(relx=0.01, rely=0.22, relwidth=0.98, relheight=0.03) reportBoard.place(relx=0.01, rely=0.26, relwidth=0.98, relheight=0.73) tk.Button(self.frame, text='generate report', command=generateReport).place(relx=0.84, rely=0.93, relwidth=0.15, relheight=0.06)
record_index = 1 def show_input(file): global filepath, image_in for item in file: filepath = ''.join(item.decode('gbk')) image_open = Image.open(filepath) image_resize = image_open.resize((width, height)) image = ImageTk.PhotoImage(image_resize) canvas_in.create_image(0, 0, anchor='nw', image=image) canvas_in.image = image image_in = image_open windnd.hook_dropfiles(window, func=show_input) def show_output(): model = askopenfilename() global filepath, depth, max_dep_dis if para.get() == 'A': # predict.predict(model_data_path='FCRN_master/NYU_FCRN.ckpt', image_path=filepath) predict.predict(model_data_path=model, image_path=filepath) elif para.get() == 'B': image_in_path = 'MiDaS_master/input/' + filepath.split('\\')[ -1] # 将图片保存到MiDas_master/input文件夹 image_in.save(image_in_path) # depth, image_result = run.new_run(image_in_path, 'MiDaS_master/output', 'MiDaS_master/model.pt') depth, image_result = run.new_run(image_in_path, 'MiDaS_master/output',
def dragfiles(component, cbFn): import windnd windnd.hook_dropfiles(component, func=cbFn)
def __init__(self, window): self.win = window self.widget_data = {} self.font_1 = tkFont.Font(font="TkDefaultFont") # {'family': 'Microsoft YaHei UI', 'size': 9, 'weight': 'normal', 'slant': 'roman', 'underline': 0, 'overstrike': 0} self.font_1.config(size=-17) self.font_2 = tkFont.Font(font="TkDefaultFont") self.font_2.config(size=-12, slant=tkFont.ITALIC) self.font_3 = tkFont.Font(font="TkDefaultFont") self.font_3.config(size=-15) self.style = ttk.Style() self.style.configure("1.TButton", font=self.font_3) #foreground background self.title = "BW editor" self.version = 'dev' #'v0.1' self.size = 350, 270 sw = window.winfo_screenwidth() sh = window.winfo_screenheight() x = (sw - self.size[0]) / 2 y = (sh - self.size[1]) / 2 window.title(self.title) window.iconbitmap("./bw.ico") window.geometry("{}x{}+{:.0f}+{:.0f}".format(self.size[0], self.size[1], x, y)) window.resizable(width=False, height=False) window.attributes("-topmost", True) window.grid_columnconfigure(0, weight=1) window.grid_rowconfigure(0, weight=1) # self.start = start = Button(window, text="Drag to open the bw file", relief=GROOVE, font=self.font_1) start["state"] = DISABLED start.place(relx=0.5, rely=0.5, anchor=CENTER) # window.update_idletasks() # start.place( # x=(self.size[0] - start.winfo_width()) / 2, # y=(self.size[1] - start.winfo_height()) / 2) # self.main_frame = main_frame = Frame(window, width=self.size[0], height=self.size[1]) # main_frame.grid() main_frame.grid_propagate(0) main_frame.grid_columnconfigure(0, weight=1) # main_frame.grid_columnconfigure(1, weight=1) # main_frame.grid_rowconfigure(0, weight=1) main_frame.grid_rowconfigure(2, weight=1) # h = 30 self.frame_1 = frame_1 = Frame(main_frame, width=self.size[0], height=h) self.frame_2 = frame_2 = LabelFrame( main_frame, text="Atmospheres: 0", fg="#808080", labelanchor=SW, width=self.size[0], height=self.size[1] - h - 60, borderwidth=2, relief=GROOVE, ) self.frame_3 = frame_3 = Frame(main_frame, width=280, height=35) self.apply = apply = ttk.Button( frame_3, # width=30, text="Apply", # font=self.font_3, takefocus=False, state=DISABLED, # bg="#E6E6E6", # disabledforeground="#B4B4B4", # relief=GROOVE, style="1.TButton", command=self.applyCMD) self.canvas = canvas = Canvas(frame_2, highlightthickness=0) self.sbar = sbar = Scrollbar(frame_2) frame_1.grid_propagate(0) frame_2.grid_propagate(0) frame_3.pack_propagate(0) frame_1.grid_columnconfigure(0, weight=1) frame_1.grid_columnconfigure(2, weight=1) frame_2.grid_rowconfigure(0, weight=1) frame_2.grid_columnconfigure(0, weight=1) frame_1.grid(row=0, column=0) frame_2.grid(row=1, column=0, padx=15) frame_3.grid(row=2) #pady=8 apply.pack(fill=BOTH, expand=1) canvas.grid(row=0, column=0, columnspan=2, sticky=NSEW) sbar.grid(row=0, column=1, sticky=NS) sbar.config(command=canvas.yview) canvas.config(yscrollcommand=sbar.set) window.update_idletasks() self.frame_in_canvas = frame_in_canvas = Frame( canvas, # borderwidth=0, width=self.size[0], height=frame_2.winfo_height(), relief=FLAT) canvas.create_window((-20, 1), anchor=NW, window=frame_in_canvas) # frame_in_canvas.grid_propagate(0) frame_in_canvas.grid_columnconfigure(0, weight=1, pad=79) frame_in_canvas.grid_columnconfigure(1, weight=1, pad=13) frame_in_canvas.grid_columnconfigure(2, weight=1, pad=79) # sbar.bind("<MouseWheel>", self.processWheel) frame_in_canvas.bind("<MouseWheel>", self.processWheel) frame_in_canvas.bind("<ButtonPress-1>", self.focus_set) canvas.bind("<ButtonPress-1>", self.focus_set) # frame_in_canvas.bind("<B1-Motion>", self.scroll_move) self.line_1 = line_1 = Frame(frame_1, width=self.size[0], height=2, borderwidth=2, relief=SUNKEN) # line_1.pack(fill=X, padx=5, pady=5) line_1.grid(row=0, columnspan=3, padx=15) text = ("name", "color", "density") for i in range(3): frame = Frame( frame_1, height=26, width=47, borderwidth=0, # relief=GROOVE ) if i == 2: frame['width'] = 49 label = Label( frame, text=text[i], fg="#747474", # fg="#%02X%02X%02X" % (116, 116, 116), font=self.font_2, ) frame.pack_propagate(0) frame.grid(row=0, column=i) label.pack(fill=BOTH, expand=1) # menubar = Menu(window) # filemenu = Menu(menubar, tearoff=0) # menubar.add_cascade(label="About", menu=filemenu, command=self.foo) menubar.add_command(label="About", command=self.about) window.config(menu=menubar) self.validateCMD = window.register(self.validate_fn) windnd.hook_dropfiles(window, func=self.dragged_files, force_unicode=True)
def __init__(self, funcFrame, dispatcher, name, color): self.name = name self.color = color self.frame = tk.Frame(funcFrame, bg = self.color) self.frame.place(relx = 0, rely = 0, relwidth = 1, relheight = 1) #----------------------------- # Parameter #----------------------------- filePath = tk.StringVar() processBar = ttk.Progressbar(self.frame, mode = "determinate", orient = "horizontal") geneList = ttk.Combobox(self.frame, value = ()) showResult = tk.Label(self.frame, wraplength = 680, anchor = 'nw', justify = 'left') #Automatic line wrap signal = td.Event() signal.set() databaseDescription = tk.Label(self.frame) dispatcher.initializeDatabase(self.frame, databaseDescription, geneList) def setFilePath(path): filePath.set(path[0].decode()) def openFile(): if not signal.isSet(): return fileTypeList = [('XLSX','.xlsx'), ('XLS','.xls')] filePath.set(tkf.askopenfilename(filetypes = fileTypeList)) def updateDB(): if not signal.isSet(): return path = filePath.get() if not path: dispatcher.warning("There is no selected file.Please input the file path!\n") elif path[-4:] != '.xls' and path[-5:] != '.xlsx': dispatcher.error("The file type is not supported!\n") else: signal.clear() processBar["value"] = 0 dispatcher.updateDatabase(path, signal, processBar, self.frame, databaseDescription, geneList) def showDetail(): if not signal.isSet(): return checkGene = geneList.get() if not checkGene: dispatcher.warning("There is no selected gene name.\n") else: dispatcher.checkDescriptionByGeneName(checkGene, showResult) #----------------------------- # Layout #----------------------------- databaseDescription.place(relx = 0.01, rely = 0.01, relwidth = 0.98, relheight = 0.35) processBar.place(relx = 0.01, rely = 0.38, relwidth = 0.98, relheight = 0.03) tk.Label(self.frame, text = 'File:').place(relx = 0.01, rely = 0.43, relwidth = 0.06, relheight = 0.06) pathInputObject = tk.Entry(self.frame, textvariable = filePath) pathInputObject.place(relx = 0.07, rely = 0.43, relwidth = 0.66, relheight = 0.06) # support drop files into entry wd.hook_dropfiles(pathInputObject.winfo_id(), func = setFilePath) tk.Button(self.frame, text = 'open', command = openFile).place(relx = 0.74, rely = 0.43, relwidth = 0.12, relheight = 0.06) tk.Button(self.frame, text = 'update', command = updateDB).place(relx = 0.87, rely = 0.43, relwidth = 0.12, relheight = 0.06) tk.Label(self.frame, text = 'Check Gene Description', anchor = 'w').place(relx = 0.01, rely = 0.50, relwidth = 0.98, relheight = 0.1) geneList.place(relx = 0.01, rely = 0.61, relwidth = 0.15, relheight = 0.06) tk.Button(self.frame, text = 'check', command = showDetail).place(relx = 0.18, rely = 0.61, relwidth = 0.12, relheight = 0.06) showResult.place(relx = 0.01, rely = 0.68, relwidth = 0.98, relheight = 0.31)
def windndGet(self): windnd.hook_dropfiles(self.root, func=self.dragged_files)
tStringVar1 = StringVar() tStringVar1.set('请输入料单文件的路径或拖动料单文件进此框') e1 = Entry(root, textvariable=tStringVar1, width=40) e1.grid(row=0, column=1) e1.bind('<Triple-Button-1>', entry1_clear) l2 = Label(root, text='领取数量') l2.grid(row=1, column=0) tStringVar2 = StringVar() tStringVar2.set('15') e2 = Entry(root, textvariable=tStringVar2, width=40) e2.grid(row=1, column=1) e2.bind('<Triple-Button-1>', entry2_clear) windnd.hook_dropfiles(e1, func=get_file_path) # 拖拽文件 recoil_of_material_path = Path(Path.cwd()) / 'Lib' / '物料库.xlsx' rom = openpyxl.load_workbook(recoil_of_material_path) rom_sheet = rom[rom.sheetnames[0]] def create(): file_path = e1.get().replace("/", "\\") if_file_path_changed = False num = int(e2.get()) if Path(file_path).is_file(): wb = openpyxl.Workbook() ws = wb.active if file_path.endswith("xls"): if_file_path_changed = True
if os.path.exists(tmppath+'/iimm'): shutil.rmtree(tmppath+'/iimm') exit() if len(resarr)>0: showinfo('@柳涤尘','处理成功:\n'+'\n'.join(resarr)) exit() n_ts=time.time() dead_time=4093456027 #2099-09-19 if n_ts>dead_time: showinfo('超出使用期限:2099-09-19') exit() else: # print(sys.version) tk=tkinter.Tk() tk.title('Word解除保护@柳涤尘') tk.geometry('300x150') tk.resizable(0,0) l=tkinter.Label(tk,text="将word文档拖拽到此窗口解除保护\n(python写的,运行较慢)") l.pack() #打包资源时,打包的资源路径需要这样获取: if getattr(sys, 'frozen', None): basedir = sys._MEIPASS else: basedir = os.path.dirname(__file__) imagepath=os.path.join(basedir, 'qflyg.gif') canvas=tkinter.Canvas(tk,height=150,width=300) image_file=tkinter.PhotoImage(file=imagepath) image=canvas.create_image(250,40,image=image_file) canvas.pack() windnd.hook_dropfiles(tk,func=just_do_it) tk.mainloop()
command=deleteImgUrl) # createArticle_btn.place(relx=0.1,rely=0.1) copy_btn.grid(row=1, column=4, padx=8, pady=8) # 文本框 - 选中的文件 global translate_Text1 translate_Text1 = scrolledtext.ScrolledText(file_btn_bottom_frame, bg="#FFEDDA") translate_Text1.place(relx=0, rely=0, relheight=1, relwidth=1) button_frame.place(relx=0, rely=0, relheight=0.1, relwidth=1) # 显示 button_frame2.place(relx=0, rely=0.1, relheight=0.35, relwidth=1) button_frame3.place(relx=0, rely=0.4, relheight=1, relwidth=1) # 选择文件 def selectFile(files): # 仅仅上传一个文件 file = files[0].decode("gbk") tkinter.messagebox.showinfo('上传提示', file) translate_Text1.insert("end", file) translate_Text1.insert('end', '\n') translate_Text1.update() uploadFile(file) if __name__ == '__main__': createButton() #创建按钮 # root.iconbitmap("logo.ico") windnd.hook_dropfiles(file_frame, func=selectFile) root.mainloop()
mayaFilesVar.set(filesList) def outputPathEntry_MouseDrag(files): if os.path.isdir(files[0]): outputPathVar.set(files[0]) def melCommandScrolledText_MouseDrag(files): with open(files[0], "r", encoding='utf-8') as r: try: text = r.read() except: text = '' melCommandScrolledText.delete(1.0, END) melCommandScrolledText.insert(1.0, text) windnd.hook_dropfiles(mayaInstallPathEntry, func=mayaInstallPathEntry_MouseDrag, force_unicode=1) windnd.hook_dropfiles(deadlineInstallPathEntry, func=deadlineInstallPathEntry_MouseDrag, force_unicode=1) windnd.hook_dropfiles(mayaFilesEntry, func=mayaFilesEntry_MouseDrag, force_unicode=1) windnd.hook_dropfiles(outputPathEntry, func=outputPathEntry_MouseDrag, force_unicode=1) windnd.hook_dropfiles(melCommandScrolledText, func=melCommandScrolledText_MouseDrag, force_unicode=1) # Button 颜色事件
lbAssetIDTip = tk.Label(window, text = ('0~10,-1代表默认图集'), font=('Arial', 12), # 字体和字体大小 width=400, height=1 # 标签长宽 ) btn_delete = tk.Button(window,text="删除项目",width=15,height=2,command=delete_selection) #删除按钮 btn_pack = tk.Button(window,text="分配到图集中",width=15,height=2,command=packAsset) #分配图集按钮 btn_clearList = tk.Button(window,text="清空列表",width=15,height=2,command=clear_list) #清空列表按钮 btn_alterAssetId = tk.Button(window,text="修改当前操作的图集",width=15,height=2,command=alterAssetId) #修改当前操作的图集按钮 entry = tk.Entry(window,show = None) listBox = tk.Listbox(window,width = 80,height = 30) #列表 windnd.hook_dropfiles(window,dropFileFunc) updateList() lbPath.pack() lbAssetID.pack() lbAssetIDTip.pack() listBox.pack() btn_delete.pack() btn_pack.pack() btn_clearList.pack() entry.pack() btn_alterAssetId.pack() window.mainloop()
def createPage(self): # 计算hash值 self.f_hash = ttk.Frame(self) # hash模块 self.f_check = ttk.Frame(self) # 校对字符串模块 self.f_algo = ttk.Frame(self.f_hash) # 算法 self.f_option = ttk.Frame(self.f_hash) # 选项 self.f_content = ttk.Frame(self.f_hash) # 显示内容 self.f_bottom = ttk.Frame(self.f_hash) # 查找/校对字符串 self.f_hash.pack() # self.f_check.pack() # self.f_algo.pack() # self.f_option.pack() # self.f_content.pack() self.f_algo.grid(row=0, stick=tk.EW) self.f_option.grid(row=2, stick=tk.EW) self.f_content.grid(row=3, stick=tk.EW) self.f_bottom.grid(row=4, stick=tk.EW) ttk.Label(self.f_algo, text='算法: ').grid(row=1, stick=tk.W) col = 1 row = 1 for index, item in enumerate(self.vars): value = self.algors[index] if index < 3: item.set(value) else: item.set('') cb = ttk.Checkbutton(self.f_algo, text=value, variable=item, onvalue=value, offvalue='') cb.grid(column=col, row=row, stick=tk.W, ipadx=5) col += 1 ttk.Label(self.f_option, text='显示: ').grid(row=4, stick=tk.W) ttk.Radiobutton(self.f_option, text="大写", variable=self.upper, value=True, command=self.changeCase).grid(row=4, column=1, sticky=tk.EW) ttk.Radiobutton(self.f_option, text="小写", variable=self.upper, value=False, command=self.changeCase).grid(row=4, column=2, sticky=tk.W) self.upper.set(False) ttk.Label(self.f_option, text="", width=34).grid(row=4, column=3, sticky=tk.EW) # 用于调整布局,空标签,无意义 ttk.Button(self.f_option, text='浏览', command=self.selectPath).grid(row=4, column=4, stick=tk.E, pady=10) ttk.Button(self.f_option, text='清除', command=self.clear).grid(row=4, column=5, stick=tk.E, pady=10) ttk.Button(self.f_option, text='保存', command=self.writehash).grid(row=4, column=6, stick=tk.E, pady=10) ttk.Label(self.f_content, text='进度: ').grid(row=0, stick=tk.W) ttk.Label(self.f_content, text='完成: ').grid(row=1, stick=tk.W, pady=5) self.pb1 = ttk.Progressbar(self.f_content, orient="horizontal", length=600, value=0, mode="determinate") self.pb1.grid(row=0, column=1, stick=tk.EW) self.pb2 = ttk.Progressbar(self.f_content, orient="horizontal", length=600, value=0, mode="determinate") self.pb2.grid(row=1, column=1, stick=tk.EW, pady=5) scrolW = 80 scrolH = 25 self.scr = scrolledtext.ScrolledText(self.f_content, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=2, columnspan=2, sticky='WE') ttk.Entry(self.f_bottom, textvariable=self.search_str, width=65).grid(row=2, column=0, stick=tk.EW) ttk.Button(self.f_bottom, text="查找", command=self.search).grid(row=2, column=1, sticky='E') self.btn_check = ttk.Button(self.f_bottom, text="校对字符串", command=self.show_check) self.btn_check.grid(row=2, column=2, sticky='E', pady=5) windnd.hook_dropfiles(self.root, func=self.dragged_files) # 监听文件拖拽操作 # 校对字符串 ttk.Label(self.f_check, text='字符串1: ').grid(row=1, stick=tk.W, pady=5) ttk.Entry(self.f_check, textvariable=self.str1, width=80).grid(row=1, column=1, columnspan=9, stick=tk.EW) ttk.Label(self.f_check, text='字符串2: ').grid(row=2, stick=tk.W, pady=5) ttk.Entry(self.f_check, textvariable=self.str2, width=80).grid(row=2, column=1, columnspan=9, stick=tk.EW) ttk.Label(self.f_check, text='设置模式: ').grid(row=3, stick=tk.W, pady=5) ttk.Checkbutton(self.f_check, text="忽略大小写差异", variable=self.ignore_case_flag, onvalue=True, offvalue=False).grid(column=1, row=3, sticky=tk.W) ttk.Checkbutton(self.f_check, text="忽略字符串前后空格", variable=self.ignore_space_flag, onvalue=True, offvalue=False).grid(column=2, row=3, sticky=tk.W) ttk.Checkbutton(self.f_check, text="忽略所有空格", variable=self.only_char_flag, onvalue=True, offvalue=False).grid(column=3, row=3, sticky=tk.W) self.ignore_case_flag.set(True) # 默认忽略大小写 self.ignore_space_flag.set(True) # 默认忽略前后空格 self.only_char_flag.set(False) ttk.Button(self.f_check, text='清除', command=self.clear_check).grid(row=3, column=8, stick=tk.E, pady=5) ttk.Button(self.f_check, text='比对', command=self.run_check).grid(row=3, column=9, stick=tk.E, pady=5) tk.Label(self.f_check, text='比对结果:').grid(row=4, stick=tk.W, pady=10) # 用于展示比对结果 self.l_result = tk.Label(self.f_check, text='待比对!', background="white") # 用于展示比对结果 self.l_result.grid(row=4, column=1, columnspan=9, stick=tk.EW, pady=10)
def set_win(self): self.init_win.title('图片传送 V1.0 (By: 芯光)') self.init_win.geometry('900x480+480+270') # 默认位置为(480, 270) self.init_win.resizable(0, 0) # 防止用户调整尺寸 # self.init_win["bg"] = "grey" # self.init_win.attributes("-alpha",0.9) # 虚化,值越小虚化程度越高 # image area self.img_ui = ttk.LabelFrame(self.init_win, text='图片输入', labelanchor="n") self.img_ui.place(relx=0.02, rely=0.01, relheight=0.84, relwidth=0.47) self.display = tk.Label(self.img_ui, text='将 图 片 拖 动\n\n到 此 处 打 开', font=('宋体', 20), fg='grey') self.display.place(relx=0.5, rely=0.49, anchor='center') self.init_path = './' # output area self.hex_ui = ttk.LabelFrame(self.init_win, text='数据输出', labelanchor="n") self.hex_ui.place(relx=0.51, rely=0.01, relheight=0.84, relwidth=0.47) # self.hex_plot = scrolledtext.ScrolledText(self.hex_ui, width=56, height=28, wrap=tk.WORD) self.hex_plot = tk.Text(self.hex_ui, width=56, height=28, wrap=tk.WORD) self.hex_plot.config(state='disabled') self.hex_plot.place(relx=0.5, rely=0.49, anchor='center') # serial configure self.port = tk.StringVar() self.com = ttk.Combobox(self.init_win, width=16, textvariable=self.port) self.com['values'] = self.__uart() self.com.place(relx=0.13, rely=0.89, anchor='w') self.com.current(0) self.com.config(state='readonly') # 设为只读模式 self.speed_v = tk.IntVar() self.speed = ttk.Combobox(self.init_win, width=7, textvariable=self.speed_v) self.speed['values'] = (9600, 14400, 19200, 38400, 57600, 115200, 128000, 256000, 512000, 1000000) self.speed.place(relx=0.36, rely=0.89, anchor='w') self.speed.current(5) tk.Label(self.init_win, text='端口: ').place(relx=0.13, rely=0.89, anchor='e') tk.Label(self.init_win, text='波特率: ').place(relx=0.36, rely=0.89, anchor='e') # button self.reflash = tk.Button(self.init_win, text='刷新', width=4, command=self.__reflash) self.reflash.place(relx=0.02, rely=0.89, anchor='w') self.ser_open = tk.Button(self.init_win, text='打开串口', width=12, command=self.__open_uart) self.ser_open.place(relx=0.51, rely=0.89, anchor='w') self.img_open = tk.Button(self.init_win, text='打开图片', width=12, command=self.__click_file) self.img_open.place(relx=0.745, rely=0.89, anchor='center') self.start = tk.Button(self.init_win, text='开始传送', width=12, command=self.__start) self.start.place(relx=0.98, rely=0.89, anchor='e') self.org_img = [] # statusbar self.statusbar = tk.Label(self.init_win, text=" Tips: 打开或拖放一张图片", bd=1, relief=tk.SUNKEN, anchor=tk.W) self.statusbar.place(relx=0, rely=0.94, relheight=0.06, relwidth=1) windnd.hook_dropfiles(self.img_ui, self.__drag_file) # 拖拽文件
print(file_name) file_name = file_name.replace('\\', '/') file = file_name.split('/')[-1] path = file_name.replace(file, '') #.encode('utf-8') file = file #.encode('utf-8') decrypt_pdf(file, '') result.insert(END, file_name + '解密完成\n') if __name__ == '__main__': root = Tk() root.title("PDF解密小工具(仅针对可打开不可复制类的)") root.geometry('600x350+00+200') # 位置设置 dnd = windnd.hook_dropfiles(root, func=drop) # lb = Listbox(root, height=7, width=60, selectmode=SINGLE) lb = Listbox(root, height=7, width=60) #, selectmode=MULTIPLE) result = Text(root, width=60, height=9) # 处理结果展示 button = Button(root, text="开始转换", width=10, command=open_file) Label(root, text='拖动文件到此:').grid(row=0, column=0) Label(root, text='信息输出:').grid(row=7, column=0) lb.grid(row=0, rowspan=5, column=1, columnspan=5, padx=20) button.grid(row=6, column=5, padx=10, ipadx=10, pady=10) result.grid(row=7, rowspan=5, column=1, columnspan=5, padx=20) root.mainloop()
def __init__(self): tkinter.Tk.__init__(self, 'lsx') try: self.ss = self.clipboard_get() except: self.ss = '' self.cnt = 0 self.slices = paragraph(self.ss, qrlen) self.string = None if not os.path.exists('config.ini'): x = - 100 + 0.2 * self.winfo_screenwidth() # 100: 补偿初始Tk界面为200x200 y = - 100 + 0.7 * self.winfo_screenheight() xy = '+%d+%d'%(x,y) with open('config.ini','w') as f: f.write(xy) with open('config.ini','r') as f: xy = f.read() self.geometry(xy) self.minsize(450,206) self.qrc = tkinter.Label(self) self.ent = ScrolledText(self, width=1, height=15) self.ent.insert(1.0, self.ss) self.ent.mark_set('insert','0.0') # 程序首次运行时不使用see函数,否则会有未知原因半行内容沉没在Text窗体上面一点点 self.ent.focus() text = self.slices[self.cnt] basic = (len(self.slices),len(self.ss)) info = 'Page: %s, Length: %s'%basic if zh_cn: info = '共%s页, %s字'%basic self.withdraw() # withdraw/deiconify 阻止页面闪烁 self.update_idletasks() self.ent.pack(padx=2, pady=2, fill='both', expand=True, side='right') # RIGHT为了在Label隐藏再显示后所在位置一致 self.qrc.pack() self.setQrcode(text, info) self.deiconify() self.qrc.bind('<Button-2>',self.onExit) self.qrc.bind('<Button-1>',self.fliping) self.qrc.bind('<Button-3>',self.fliping) self.qrc.bind('<Double-Button-1>',self.setting) self.qrc.bind('<Double-ButtonRelease-3>',self.openFile) # 没有Release会在窗口打开之后的鼠标抬起时唤起右键菜单 self.ent.bind('<Escape>',self.onExit) self.ent.bind('<F1>',self.openFile) self.ent.bind('<F2>',self.fliping) self.ent.bind('<F3>',self.fliping) self.ent.bind('<F4>',self.setting) self.ent.bind('<KeyRelease>',self.refresh) self.ent.bind('<ButtonRelease-1>',self.selected) self.bind('<Destroy>',lambda evt:self.onExit(evt,close=True)) try: import windnd windnd.hook_dropfiles(self, func=self.openFile) except: pass