[Python-checkins] CVS: python/dist/src/Lib/lib-tk tkFileDialog.py,1.6,1.7
Martin v. L?wis
loewis@users.sourceforge.net
Mon, 08 Apr 2002 07:51:33 -0700
Update of /cvsroot/python/python/dist/src/Lib/lib-tk
In directory usw-pr-cvs1:/tmp/cvs-serv30702
Modified Files:
tkFileDialog.py
Log Message:
Patch #539392: Invoke setlocale, try opening the file in demo mode.
Index: tkFileDialog.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkFileDialog.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** tkFileDialog.py 2 Jan 2002 16:38:19 -0000 1.6
--- tkFileDialog.py 8 Apr 2002 14:51:31 -0000 1.7
***************
*** 131,143 ****
# Start off with UTF-8
enc = "utf-8"
# See whether CODESET is defined
try:
import locale
enc = locale.nl_langinfo(locale.CODESET)
except (ImportError, AttributeError):
pass
! print "open", askopenfilename(filetypes=[("all files", "*")]).encode(enc)
! print "saveas", asksaveasfilename().encode(enc)
--- 131,159 ----
# Start off with UTF-8
enc = "utf-8"
+ import sys
# See whether CODESET is defined
try:
import locale
+ locale.setlocale(locale.LC_ALL,'')
enc = locale.nl_langinfo(locale.CODESET)
except (ImportError, AttributeError):
pass
! # dialog for openening files
!
! openfilename=askopenfilename(filetypes=[("all files", "*")])
! try:
! fp=open(openfilename,"r")
! fp.close()
! except:
! print "Could not open File: "
! print sys.exc_info()[1]
!
! print "open", openfilename.encode(enc)
!
! # dialog for saving files
!
! saveasfilename=asksaveasfilename()
! print "saveas", saveasfilename.encode(enc)