[Python-Dev] Save file by using file() function and fileDialog()
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_PROMPTfilter = '*.txt'
result = dialog.fileDialog(self, 'ist def', '', 'n', wildcard, aStyle)
myfile= result.pathsif 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___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] How to select text of text field in pythonCard
Hi, I need to select a text of text field! Which function is used for selection of text of text field? Sonia, > From: [EMAIL PROTECTED]> Subject: Python-Dev Digest, Vol 64, Issue 4> To: > [email protected]> Date: Mon, 3 Nov 2008 03:10:48 +0100> > Send > Python-Dev mailing list submissions to> [email protected]> > To subscribe > or unsubscribe via the World Wide Web, visit> > http://mail.python.org/mailman/listinfo/python-dev> or, via email, send a > message with subject or body 'help' to> [EMAIL PROTECTED]> > You can reach > the person managing the list at> [EMAIL PROTECTED]> > When replying, please > edit your Subject line so it is more specific> than "Re: Contents of > Python-Dev digest..."> > > Today's Topics:> > 1. Re: Fwd: Removal of GIL > through refcounting removal. (Eric Smith)> 2. Re: Fwd: Removal of GIL through > refcounting removal. (Adam Olsen)> 3. Re: Fwd: Removal of GIL through > refcounting removal. (Greg Ewing)> 4. Re: Fwd: Removal of GIL through > refcounting removal.> ([EMAIL PROTECTED])> 5. Re: Fwd: Removal of GIL through > refcounting removal.> (skip@ pobox.com)> 6. Looking for VCS usage scenarios (Brett Cannon)> 7. Re: Fwd: Removal of GIL through refcounting removal. (Eric Smith)> 8. Re: Looking for VCS usage scenarios (Gustavo Niemeyer)> 9. Re: My patches (Alex Martelli)> > > --> > Message: 1> Date: Sun, 02 Nov 2008 15:34:14 -0500> From: Eric Smith <[EMAIL PROTECTED]>> Subject: Re: [Python-Dev] Fwd: Removal of GIL through refcounting> removal.> To: [email protected]> Message-ID: <[EMAIL PROTECTED]>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed> > Giovanni Bajo wrote:> > [[ my 0.2: it would be a great loss if we lose reference-counting > > semantic (eg: objects deallocated as soon as they exit the scope). I > > would bargain that for a noticable speed increase of course, but my own > > experience with standard GCs from other languages has been less than > > stellar. ]]> > And my $0.02:> > I'd gladly trade deterministic de struction (due to reference counting or > any other mechanism) for improved performance. I've often thought of > creating a mode where destruction didn't happen right away with > reference counting, just so I could find places where I'm relying on it. > I consider it a bug to rely on reference counting to close files, for > example. Maybe I should just run under Jython or IronPython everyone > once in a while.> > > --> > Message: 2> Date: Sun, 2 Nov 2008 15:07:45 -0600> From: "Adam Olsen" <[EMAIL PROTECTED]>> Subject: Re: [Python-Dev] Fwd: Removal of GIL through refcounting> removal.> To: "Eric Smith" <[EMAIL PROTECTED]>> Cc: [email protected]> Message-ID:> <[EMAIL PROTECTED]>> Content-Type: text/plain; charset=ISO-8859-1> > On Sun, Nov 2, 2008 at 2:34 PM, Eric Smith <[EMAIL PROTECTED]> wrote:> > Giovanni Bajo wrote:> >>> >> [[ my 0.2: it would be a great loss if we lose reference-counting semantic> > > (eg: objects deallocated as soon as they exit the scope). I would bargain> > >> that for a noticable speed increase of course, but my own experience > with> >> standard GCs from other languages has been less than stellar. ]]> > >> > And my $0.02:> >> > I'd gladly trade deterministic destruction (due to > reference counting or any> > other mechanism) for improved performance. I've > often thought of creating a> > mode where destruction didn't happen right > away with reference counting,> > just so I could find places where I'm > relying on it. I consider it a bug to> > rely on reference counting to close > files, for example. Maybe I should just> > run under Jython or IronPython > everyone once in a while.> > I've considered making files issue a warning if > they've got buffered> writes and they're not explicitly closed. Although my > feeling is a> read-only file should produce the same warning, there's > situations> where "proper" error handling is very difficult or impossible.> > > > -- > Adam Ols en, aka Rhamphoryncus> > > --> > Message: 3> Date: Mon, 03 Nov 2008 11:33:11 +1300> From: Greg Ewing <[EMAIL PROTECTED]>> Subject: Re: [Python-Dev] Fwd: Removal of GIL through refcounting> removal.> To: python-de
