[Tutor] Need Help Modifying a wxPython GUI (scrolling display and logging)

Dave Angel davea at davea.name
Thu Jun 13 03:02:58 CEST 2013


On 06/12/2013 08:46 PM, Matt D wrote:
> On 06/12/2013 05:59 PM, Dave Angel wrote:
>> On 06/12/2013 05:32 PM, Matt D wrote:


     <SNIP>
>>> Hey,
>>> if i put:
>>>
>>>    self.logfile = open('logfile.csv', 'w')
>>>
>>> in the .py file, within the 'class TrafficPane', then shouldn't
>>> logfile.csv be written to the directory the .py file is in?  because its
>>> not there after running the program?  Where should i look for it?
>>> Thanks
>>> Matt
>>>
>>
>> It should put it in the current directory.  That *may* be the directory
>> the script is in, but not necessarily.  It's easy to run something like:
>>
>> python somdir/myscript.py
>>
>> in which case the file would be in the parent directory to myscript.py
>>
>> Note that in some environments, the current directory is invisibly set
>> to some convenient place.  For example, when right-clicking on a script
>> in Windows Explorer, they make the bald assumption that you want to set
>> the current directory the same as the location of the script. That's
>> about the worse place for it, but nevermind.
>>
>>
>>
> Yes, that was my assumption (even thought I am using linux); and right
> again, it is a very inconvenient place for it to be.  however in the
> interest of speed of testing i figured i would make sure the log was
> logging the way i want it to and then try to find some sort of wx wigit
> to let the user of the gui name/save to desired location. meanwhile . .
> . so you think it saved somewhere right?

There are other ways a script might change the current directory.  For 
example, some naive scripts use os.chdir()

But how is it you don't know what the current directory was when the 
code ran?   A simply pwd can tell you, if your prompt doesn't already 
reveal it.


-- 
DaveA


More information about the Tutor mailing list