我已经在这上面呆了一段时间了。我基本上是想做一个应用程序,将允许我加载多个文件。目前,该应用程序有6个“浏览”按钮,旁边是相应的输入框。我试图让浏览按钮将文件位置字符串发送到它旁边的输入框。不幸的是,目前它只将文件名字符串附加到底部的输入框中。如何将其输出到相应行的框中?你知道吗
希望这个解决方案也能帮助我理解当我按下execute时如何返回正确的值!你知道吗
到目前为止,我所掌握的情况如下。你知道吗
提前谢谢
r=3
for i in range(6):
#CREATE A TEXTBOX
self.filelocation = Entry(self.master)
self.filelocation["width"] = 60
self.filelocation.focus_set()
self.filelocation.grid(row=r,column=1)
#CREATE A BUTTON WITH "ASK TO OPEN A FILE"
self.open_file = Button(self.master, text="Browse...", command=lambda i=i: self.browse_file(i))
self.open_file.grid(row=r, column=0) #put it beside the filelocation textbox
#CREATE A TEXT ENTRY FOR HELICOPTER ROUTE NAME
self.heliday = Entry(self.master)
self.heliday["width"] = 20
self.heliday.grid(row=r,column=2)
r = r+1
#now for a button
self.submit = Button(self.master, text="Execute!", command=self.start_processing, fg="red")
self.submit.grid(row=r+1, column=0)
def start_processing(self):
#more code here
print "processing"
def browse_file(self, i):
#put the result in self.filename
self.filename = tkFileDialog.askopenfilename(title="Open a file...")
#this will set the text of the self.filelocation
self.filelocation.insert(0,self.filename)
必须保留对所有
Entry
框的引用。为此,您可以将条目创建更改为:这样,就可以在列表中保留对所有
Entry
框的引用。然后,可以使用以下命令确保文件名位于正确的Entry
:相关问题 更多 >
编程相关推荐