我正在使用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. python使用scapy 2.7
- 3. 在Python 2.7中使用unicode的re.sub 2.7
- 4. python 2.7 xml.etree.cElementTree內存使用
- 5. matplotlib幫助使用Python 2.7
- 6. Python 2.7使用FOR循環
- 7. 如何使用Python 2.7
- 8. 使用ffmpeg和Python 2.7
- 9. 提取使用Python 2.7
- 10. Windows 7和Python 2.7
- 11. 如何在Anaconda python 2.7環境中使用python 2.7包
- 12. 使用Python 2.7和Python 3在Windows 10環境中運行scons
- 13. python 2.7 scapy安裝windows
- 14. Pip安裝 - Python 2.7 - Windows 7
- 15. Kivy安裝python 2.7 windows 10
- 16. python 2.7的Pydub [windows 7]
- 17. python 2.7上的Ttk 2.7
- 18. Homebrew python 2.7 vs OS X python 2.7
- 19. Python 2.7按鈕單擊後使用tkinter GUI的結構
- 20. 在Windows上用於Python 2.7的bitarray包?
- 21. 使用python 2.7編寫包含unicode的csv文件2.7
- 22. 爲什麼我必須在Python 2.7中使用Qt Designer 2.7?
- 23. 從Windows或Linux設備使用Python 2.7查詢Windows Active Directory
- 24. Python 3.5 to_bytes Python 2.7
- 25. python 2.7 vs python 3.1
- 26. 在Windows 7上的Python-Sybase Python 2.7 32bit
- 27. 使用pycrypto AppEngine上與Python 2.7
- 28. 如何使用Python 2.7安裝aggdraw
- 29. 解碼HTML字符串使用python 2.7
- 30. 谷歌App Engine的使用Python 2.7 - CouldNotFindModuleError