用python Tkinter制作一个包含文件的框,就像打开‘我的电脑’差不多的感觉,求高手指教,不要太复杂
1个回答
展开全部
# encoding: UTF-8
from Tkinter import *
from FileDialog import *
class App:
def __init__(self,master):
frame=Frame(master)
frame.pack()
self.button1=Button(frame,text="open",fg="red",command=self.inputnumber).grid(row=0,column=0)
def inputnumber(self):
fd = LoadFileDialog(root)
filename = fd.go()
print filename
root=Tk()
app=App(root)
root.mainloop()
from Tkinter import *
from FileDialog import *
class App:
def __init__(self,master):
frame=Frame(master)
frame.pack()
self.button1=Button(frame,text="open",fg="red",command=self.inputnumber).grid(row=0,column=0)
def inputnumber(self):
fd = LoadFileDialog(root)
filename = fd.go()
print filename
root=Tk()
app=App(root)
root.mainloop()
追问
我希望它能够后退,能让我选择任意途径
追答
import tkFileDialog
filename = tkFileDialog.askopenfilename(initialdir = 'E:/Python')
print filename
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询