我正在使用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