バックグラウンド
私は現在、Tkinterの基本的な理解を得ることを期待して、基本的なテキストエディタを作成中です。をno.mydoc
に変更しようとしたfiletype
という独自のファイル形式を作成したいと思います。.mydoc
これは私が現在持っているコードです:
コード
def openMe(self):
#import the Tk file dialogue
import tkFileDialog as tkF
myFormat = [('Example Format', '*.mydoc')]
direct = tkF.askopenfilename(initialdir='D:\\', filetypes = myFormat, title = "Open a .mydoc")
try:
#open the text file
txt_file = open(direct,"r")
except UnboundLocalError, IOError:
print "You either did not select a file, or the filetype was incorrect.\nPlease try again."
#Read the data
currentTEXT = txt_file.read()
#Delete current text
self.write.delete(0.0, END)
#insert new text
self.write.insert(0.0, currentTEXT)
質問
- コンピューターに拡張機能を自動的に追加するにはどうすればよいですか?
hide extensions
(はい、オプションをオフにしました。
技術仕様
言語:Python 2.7.3
OS:Windows 7