2004年03月17日 星期三 14:31
以下这段程序在运行时出现一个对话框,点击上面唯一的按钮,就弹出一个打开文件对话框,此时如果选择英文文件名,程序运行完全正常;如果选择中文文件名,程序就提示出错;如果选择“取消”,程序不是正常退出,而是出现死机。
名位帮我分析一下虫子在哪里?如何改进?
# MyScript.py
from Tkinter import *
import tkFileDialog
import sys
def chg():
MyFile=tkFileDialog.Open(root)
MyFileName=MyFile.show()
print MyFileName # Both Chinese and English?
print MyFileName<'0' # When choose "Cancle"
if MyFileName<'0':
sys.exit()
root=Tk()
Button(root,text='Open File
Dialog',command=chg).pack()
root.mainloop()
_________________________________________________________
Do You Yahoo!?
完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间
http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com
2004年03月17日 星期三 14:47
Hello CHEN,
txt2tages 的脚本中使用的是类似:
"""
from tkFileDialog import askopenfilename
...
def _get_outfile_name(self, conf):
"dirname is the same for {in,out}file"
infile = conf['infile']
if not infile: return ''
if infile == STDIN or conf['outfile'] == STDOUT:
outfile = STDOUT
else:
basename = re.sub('\.(txt|t2t)$','',infile)
outfile = "%s.%s"%(basename, conf['type'])
self.dft_options['outfile'] = outfile # save for self.compose()
Debug(" infile: '%s'"%infile , 1)
Debug("outfile: '%s'"%outfile, 1)
return outfile
"""
控件用错了??
http://txt2tags.sourceforge.net/gui.html
=== [ 14:31 ; 04-03-17 ] you wrote:
CGO> 以下这段程序在运行时出现一个对话框,点击上面唯一的按钮,就弹出一个打开文件对话框,此时如果选择英文文件名,程序运行完全正常;如果选择中文文件名,程序就提示出错;如果选择“取消”,程序不是正常退出,而是出现死机。
CGO> 名位帮我分析一下虫子在哪里?如何改进?
CGO> # MyScript.py
CGO> from Tkinter import *
CGO> import tkFileDialog
CGO> import sys
CGO> def chg():
CGO> MyFile=tkFileDialog.Open(root)
CGO> MyFileName=MyFile.show()
CGO> print MyFileName # Both Chinese and English?
CGO> print MyFileName<'0' # When choose "Cancle"
CGO> if MyFileName<'0':
CGO> sys.exit()
CGO> root=Tk()
CGO> Button(root,text='Open File
CGO> Dialog',command=chg).pack()
CGO> root.mainloop()
CGO> _________________________________________________________
CGO> Do You Yahoo!?
CGO> 完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间
CGO> http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com
CGO> _______________________________________________
CGO> python-chinese list
CGO> python-chinese at lists.python.cn
CGO> http://python.cn/mailman/listinfo/python-chinese
=== === === === === === === === === ===
--
Best regards,
Zoom.Quiet
/=======================================\
]Time is unimportant, only life important![
\=======================================/
2004年03月17日 星期三 14:56
我认为这是Tk本身对中文支持不好所造成的。我也在使用txt2tags,不知Zoom.Quiet在 用txt2tags有没有遇到这种情况:用txt2tags打开一个t2t文件,它的路径中包含中文 ,一convert就报错。把t2t放到不含中文的路径下,就没有错误了。 >From: "Zoom.Quiet" <zoomq at infopro.cn> >Reply-To: "Zoom.Quiet" <zoomq at itcase.com>, zoomq at infopro.cn, ,python-chinese at lists.python.cn >To: python-chinese at lists.python.cn >Subject: Re: [python-chinese] Debug a Python script >Date: Wed, 17 Mar 2004 14:47:46 +0800 > >Hello CHEN, > >txt2tages 的脚本中使用的是类似: >""" >from tkFileDialog import askopenfilename >... > > def _get_outfile_name(self, conf): > "dirname is the same for {in,out}file" > infile = conf['infile'] > if not infile: return '' > if infile == STDIN or conf['outfile'] == STDOUT: > outfile = STDOUT > else: > basename = re.sub('\.(txt|t2t)$','',infile) > outfile = "%s.%s"%(basename, conf['type']) > self.dft_options['outfile'] = outfile # save for self.compose() > Debug(" infile: '%s'"%infile , 1) > Debug("outfile: '%s'"%outfile, 1) > return outfile >""" > >控件用错了?? >http://txt2tags.sourceforge.net/gui.html > >=== [ 14:31 ; 04-03-17 ] you wrote: > >CGO> 以下这段程序在运行时出现一个对话框,点击上面唯一的按钮,就弹出一个打开 文件对话框,此时如果选择英文文件名,程序运行完全正常;如果选择中文文件名,程 序就提示出错;如果选择“取消”,程序不是正常退出,而是出现死机。 >CGO> 名位帮我分析一下虫子在哪里?如何改进? > >CGO> # MyScript.py >CGO> from Tkinter import * >CGO> import tkFileDialog >CGO> import sys > >CGO> def chg(): >CGO> MyFile=tkFileDialog.Open(root) >CGO> MyFileName=MyFile.show() >CGO> print MyFileName # Both Chinese and English? >CGO> print MyFileName<'0' # When choose "Cancle" >CGO> if MyFileName<'0': >CGO> sys.exit() > >CGO> root=Tk() >CGO> Button(root,text='Open File >CGO> Dialog',command=chg).pack() >CGO> root.mainloop() > > > >CGO> _________________________________________________________ >CGO> Do You Yahoo!? >CGO> 完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间 >CGO> http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com >CGO> _______________________________________________ >CGO> python-chinese list >CGO> python-chinese at lists.python.cn >CGO> http://python.cn/mailman/listinfo/python-chinese > >=== === === === === === === === === === > >-- >Best regards, > Zoom.Quiet > > /=======================================\ >]Time is unimportant, only life important![ > \=======================================/ > >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese _________________________________________________________________ 免费下载 MSN Explorer: http://explorer.msn.com/lccn
2004年03月17日 星期三 15:11
Hello Who, 没有吧? 在下的一些安好!? Python 2.3.3 (CJK/SJIS) (#51, Feb 13 2004, 22:04:56) [MSC v.1200 32 bit (Intel)] on win32 +Tk 8.4.3 见附图,中文路径,中文文件名都可以的?!?!? === [ 14:56 ; 04-03-17 ] you wrote: WB> 我认为这是Tk本身对中文支持不好所造成的。我也在使用txt2tags,不知Zoom.Quiet在 WB> 用txt2tags有没有遇到这种情况:用txt2tags打开一个t2t文件,它的路径中包含中文 WB> ,一convert就报错。把t2t放到不含中文的路径下,就没有错误了。 >>From: "Zoom.Quiet" <zoomq at infopro.cn> >>Reply-To: "Zoom.Quiet" <zoomq at itcase.com>, zoomq at infopro.cn, WB> ,python-chinese at lists.python.cn >>To: python-chinese at lists.python.cn >>Subject: Re: [python-chinese] Debug a Python script >>Date: Wed, 17 Mar 2004 14:47:46 +0800 >> >>Hello CHEN, >> >>txt2tages 的脚本中使用的是类似: >>""" >>from tkFileDialog import askopenfilename >>... >> >> def _get_outfile_name(self, conf): >> "dirname is the same for {in,out}file" >> infile = conf['infile'] >> if not infile: return '' >> if infile == STDIN or conf['outfile'] == STDOUT: >> outfile = STDOUT >> else: >> basename = re.sub('\.(txt|t2t)$','',infile) >> outfile = "%s.%s"%(basename, conf['type']) >> self.dft_options['outfile'] = outfile # save for self.compose() >> Debug(" infile: '%s'"%infile , 1) >> Debug("outfile: '%s'"%outfile, 1) >> return outfile >>""" >> >>控件用错了?? >>http://txt2tags.sourceforge.net/gui.html >> >>=== [ 14:31 ; 04-03-17 ] you wrote: >> >>CGO> >>以下这段程序在运行时出现一个对话框,点击上面唯一的按钮,就弹出一个打开 WB> 文件对话框,此时如果选择英文文件名,程序运行完全正常;如果选择中文文件名,程 WB> 序就提示出错;如果选择“取消”,程序不是正常退出,而是出现死机。 >>CGO> 名位帮我分析一下虫子在哪里?如何改进? >> >>CGO> # MyScript.py >>CGO> from Tkinter import * >>CGO> import tkFileDialog >>CGO> import sys >> >>CGO> def chg(): >>CGO> MyFile=tkFileDialog.Open(root) >>CGO> MyFileName=MyFile.show() >>CGO> print MyFileName # Both Chinese and English? >>CGO> print MyFileName<'0' # When choose "Cancle" >>CGO> if MyFileName<'0': >>CGO> sys.exit() >> >>CGO> root=Tk() >>CGO> Button(root,text='Open File >>CGO> Dialog',command=chg).pack() >>CGO> root.mainloop() >> >> >> >>CGO> _________________________________________________________ >>CGO> Do You Yahoo!? >>CGO> 完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间 >>CGO> http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com >>CGO> _______________________________________________ >>CGO> python-chinese list >>CGO> python-chinese at lists.python.cn >>CGO> http://python.cn/mailman/listinfo/python-chinese >> >>=== === === === === === === === === === >> >>-- >>Best regards, >> Zoom.Quiet >> >> /=======================================\ >>]Time is unimportant, only life important![ >> \=======================================/ >> >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese WB> _________________________________________________________________ WB> 免费下载 MSN Explorer: http://explorer.msn.com/lccn WB> _______________________________________________ WB> python-chinese list WB> python-chinese at lists.python.cn WB> http://python.cn/mailman/listinfo/python-chinese === === === === === === === === === === -- Best regards, Zoom.Quiet /=======================================\ ]Time is unimportant, only life important![ \=======================================/ -------------- next part -------------- A non-text attachment was scrubbed... Name: cnPath.jpg Type: image/jpeg Size: 59024 bytes Desc: not available Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20040317/30a6c95a/cnPath.jpg
Zeuux © 2025
京ICP备05028076号