Title: Signature.html
(Guilty again of not hitting Reply All. I responded (to Kent) 8 hours ago. If anyone is against the controversial way this mail list handles replies, put me at the top of the list. In my book this list is unique in the way it handles replies.)

Yes, I probably confused the two. The link you mentioned is the one I found most helpful of the ones I mentioned. Note that his descriptions here, like others, and to me at least, are minimal. At the bottom of the page, he mentions English is not his language, and might need some help on the wiki entry. A very helpful example though.

First,
  60   def asksaveasfile(self):
  61 
  62     """Returns an opened file in write mode."""
  63 
  64     return tkFileDialog.asksaveasfile(mode='w', **self.file_opt)
Although, his description in the table doesn't mention the return type, it would seem like it should be the file name. However, the comment says the file is open. OK, how do you write on it?  Where's the object? OK, I see you say it is an object. I'm sure you're right, but how do you know?

BTW, I printed out the return from line 64 and got:
 <open file 'C:/myfile.txt', mode 'w' at 0x0519D4A0>

I may be misinterpreting this, but I took it as a file name, while it really may be the representation for an object. That makes sense now, since it certainly isn't just myfile.txt.

Next consider:
  66   def asksaveasfilename(self):
  67 
  68     """Returns an opened file in write mode.
  69     This time the dialog just returns a filename and the file is opened by your own code.
  70     """
  71 
  72     # get filename
  73     filename = tkFileDialog.asksaveasfilename(**self.file_opt)
  74 
  75     # open file on your own
  76     if filename:
  77       return open(filename, 'w')
Here, the file is not opened, and one is on their own. So output=open(filename,'w') will open it for writing. No difficulty here.

Kent Johnson wrote:
On Fri, Feb 6, 2009 at 6:53 PM, Wayne Watson
<sierra_mtnv...@sbcglobal.net> wrote:
  
I'm using asksaveasfilename, and, as I understand it, it returns the file
name to me in write mode. I don't recall that there's a way to reference the
file with only the filename. That is, there's no filename.write(). Comments?
    

I think you are confused between askopenfile() and askopenfilename().
The first opens the file and returns a file object, the second returns
just the file name and you open the file yourself.

  
While I'm at it, I have found a good example program for TkFileDialog
methods, but the description of them on the internet is pretty shallow. For
example, An Intro to Tkinter, Lundh's Tkinter pages, NM Tech pdf files and
Python docs have little to say.
    

This is helpful:
http://tkinter.unpythonic.net/wiki/tkFileDialog

Kent

  

--
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
            
            Q: What do you do when your resistors get to hot?
            A: Open the switch and coulomb they off.
                 -- Anon. (fortunately!)

                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to