我正在使用Windows XP和Python 2.7.2 & Tkinter GUI工具包。我想构建一个简单的图形用户界面,它具有文本字段和“浏览”按钮,可以通过C:\等目录选择文件(就像Windows资源管理器一样)。所选文件将显示在GUI的文本字段中。希望这是足够描述性的。使用Python 2.7浏览Windows目录GUI使用Python 2.7
4
A
回答
0
看看这个(未经测试):http://www.java2s.com/Code/Python/GUI-Tk/SimpleEditor.htm您可能只需添加'打开'对话框,但使用Tkinter文档应该很简单。
0
我建议你不要使用tkinter,但你使用wxwindows。我之前都用过不同程度的成功(我只是在搞基础)。如果你决定在这里使用了wxWindows是一个网站,是非常有用的:http://www.wxpython.org/onlinedocs.php
8
我有别的东西可以帮助你:
## {{{ http://code.activestate.com/recipes/438123/ (r1)
# ======== Select a directory:
import Tkinter, tkFileDialog
root = Tkinter.Tk()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select a directory')
if len(dirname) > 0:
print "You chose %s" % dirname
# ======== Select a file for opening:
import Tkinter,tkFileDialog
root = Tkinter.Tk()
file = tkFileDialog.askopenfile(parent=root,mode='rb',title='Choose a file')
if file != None:
data = file.read()
file.close()
print "I got %d bytes from this file." % len(data)
# ======== "Save as" dialog:
import Tkinter,tkFileDialog
myFormats = [
('Windows Bitmap','*.bmp'),
('Portable Network Graphics','*.png'),
('JPEG/JFIF','*.jpg'),
('CompuServer GIF','*.gif'),
]
root = Tkinter.Tk()
fileName = tkFileDialog.asksaveasfilename(parent=root,filetypes=myFormats ,title="Save the image as...")
if len(fileName) > 0:
print "Now saving under %s" % nomFichier
## end of http://code.activestate.com/recipes/438123/ }}}
这里是我得到了它从网站:http://code.activestate.com/recipes/438123-file-tkinter-dialogs/
相关问题
- 1. 使用Python 2.7
- 2. 使用matplotlib,python 2.7
- 3. python使用scapy 2.7
- 4. 在Python 2.7中使用unicode的re.sub 2.7
- 5. 使用urllib2登录到网站 - Python 2.7
- 6. 在Mac上使用Python 2.7
- 7. python 2.7 xml.etree.cElementTree内存使用
- 8. 提取使用Python 2.7
- 9. 如何使用Python 2.7
- 10. 如何使用Python 2.7
- 11. Python 2.7使用FOR循环
- 12. matplotlib帮助使用Python 2.7
- 13. UnicodeDecodeError使用TextBlob和Python 2.7
- 14. 使用ffmpeg和Python 2.7
- 15. 在python中使用defaultdict 2.7
- 16. NMEA数据使用python 2.7
- 17. 使用deferred.defer与Python 2.7
- 18. Autotools - Python 3可用时使用Python 2.7
- 19. 在windows的Python 2.7
- 20. Windows 7和Python 2.7
- 21. Python 2.7仍然访问Python 3.4目录
- 22. 如何在Anaconda python 2.7环境中使用python 2.7包
- 23. 用gui打印到txt python 2.7
- 24. python 2.7
- 25. python 2.7
- 26. 使用Python 2.7和Python 3在Windows 10环境中运行scons
- 27. python 2.7的Pydub [windows 7]
- 28. Kivy安装python 2.7 windows 10
- 29. Pip安装 - Python 2.7 - Windows 7
- 30. python 2.7 scapy安装windows