[Python-Dev] Save file by using file() function and fileDialog()

Sonia sonia_16 at live.com
Thu Oct 30 07:35:46 CET 2008


 
I m using fileDialog(self, message, path, filename, filter, aStyle(opotional)) to save the file. 
In my code, i used fileDialog to show save dialog box and when we click on save button, it should save that file which is of txt type (filter = '*.txt'). But when we click on save button it returns error: "coercing to unicode: need string or buffer, list found" rather than saving / creating a file. I also tried f = file(myfile, 'w', 1000) instead of f = file(myfile, 'w'), where 1000 is buffer size, but both have the same error. where as if we use 




file(
filename[, mode[, bufsize]])
, then it creates a file of specified type. But it is not working in fileDialog(). Why?Where i m wrong?
 
What should i do?
 
Following is my code:
def on_btn2_mouseClick(self, event):        aStyle = wx.SAVE|wx.HIDE_READONLY|wx.OVERWRITE_PROMPT        filter = '*.txt'
        result = dialog.fileDialog(self, 'ist def', '', 'n', wildcard, aStyle)        myfile= result.paths        if result.accepted == True :            f = file(myfile, 'w')            f.write('my file')            f.close()
_________________________________________________________________
Connect to the next generation of MSN Messenger 
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20081030/b503b75f/attachment.htm>


More information about the Python-Dev mailing list