1 回答
TA贡献1866条经验 获得超5个赞
使用此代码:
class PageOne(tk.Frame):
def __init__(self, parent, controller):
self.controller = controller
tk.Frame.__init__(self, parent)
l2 = Label(text='Use the browse buttons to select the proper folder.')
l2.pack(side=TOP)
l3 = Label(text='PDF Directory: The location of the folder containing the PDFs you wish to convert')
l3.pack(side=TOP)
l4 = Label(text='Excel Directory: The location you wish to create the Excel file within')
l4.pack(side=TOP)
instructions1 = Label(self, text='PDF Directory: ')
instructions1.pack()
self.directory = StringVar()
e1 = Entry(self, textvariable=self.directory)
e1.pack()
b3 = Button(self, text='Browse', width=8, command=lambda: browsepath())
b3.pack()
instructions2 = Label(self, text='Excel Directory: ')
instructions2.pack()
self.excel_file = StringVar()
e2 = Entry(self, textvariable=self.excel_file)
e2.pack()
b4 = Button(self, text='Browse', width=8, command=lambda: browsespd())
b4.pack()
progress = Progressbar(self, orient=HORIZONTAL, length=500, mode='determinate')
progress.pack(side=BOTTOM)
b1 = Button(self, text='Start', width=12, command=lambda: self.start_command(self.excel_file.get(), self.directory.get()))
b1.pack(side=LEFT)
b2 = Button(self, text='Close', width=12, command=quit)
b2.pack(side=RIGHT)
def start_command(self, excel_file, directory):
converter.create_json(directory)
converter.create_xlsx(excel_file, directory)
converter.check_if_existing(directory)
converter.convert(new_list, directory)
def browsepath(self):
foldername = filedialog.askdirectory()
e1.delete(0, END)
e1.insert(END, foldername)
def browsespd(self):
filename = filedialog.askdirectory()
e2.delete(0, END)
e2.insert(END, filename)
通过进一步的调整,如果没有Progressbar和convertor.
我所做的是 Ive madestart_command和browsepathlocal browsespdmethods ofPageOne通过使它们不同,这意味着您不需要传递它们的self参数,但是您现在必须使用类似self.start_commandor的东西来调用它们pageOne_object.start_command。
希望这会有所帮助!
添加回答
举报