On 06/24/2013 05:57 PM, Dave Angel wrote:
> On 06/24/2013 05:39 PM, Matt D wrote:
>>
>>> But what he's doing has nothing to do with logging.  He's just using
>>> that word.
>>>
>>>
>> Right, I'm not doing a debugging thing.  Just trying to create a log of
>> data that has been passed into the display of this program.  Since I
>> started trying to use the array the program is not working.  So I am
>> wondering if its not the best way to try to save TextCtrl values.
>>
> 
> You accidentally posted this offline, direct to me.  So it loses all
> context.  I'll try to get it back into the thread, but it may not "take."
> 
> I don't know what array you're referring to.  I VERY seldom use arrays
> in Python, since list is much more flexible and easy to use.  Nor do I
> know what you mean by the program not working.
> 
> I also don't know what you mean by saving TextCtrl values.  Aren't they
> being appended to the csv file (in random order) with your latest changes?
> 
> 
> You asked about a "save-as" feature.  Why isn't that as simple as
> copying the current contents of the saved csv file?  Or do you not know
> how you would go about copying?
> 
> Be specific with your questions, and you might get some answers.  Use
> those answers in later versions, and you'll get the same people more
> willing to help further.
> 
> Why is it no longer of interest to you to get a predictable order in
> your csv file?
> 
> 
> -- 
> DaveA
> 
> 
Well i decided to switch to a .txt file because it is easier for me to
lay eyes on it and the commas are there if i want to import it into
librecalc or sas or whatever.  and values were writing in an acceptable
order becuase, while the order was not of my choosing, the order was
always the same.  so that is fine for importing into another program for
later inspection.

What you said about the 'save as' is right, i didnt know how to go about
copying the logfile.txt (as I had it) to the file the user opened.
thats why i decided to try an array like this:

 # openfile defined to start FileDialog and write the traffic log to the
file
    def openFile(self, evt):
        with wx.FileDialog(self, "Choose a file", os.getcwd(), "",
"*.txt*", wx.OPEN) as dlg:
            if dlg.ShowModal() == wx.ID_OK:
                path = dlg.GetPath()
                mypath = os.path.basename(path)
                with open(mypath, "a") as f:
                    f.writelines(self.log_array)

I name the array up in the initializer

self.log_array = []

and this is supposed to get the the values out of the pickle and into
the textcrls and into the array:

    # Update the field values
    # put values in array
    def update(self, field_values):
        next_line = ""
        next_line += strftime("%Y-%m-%d %H:%M:%S")
        next_line +=  ','.join( field_values[k] for k in
self.fields.keys() if k in field_values )
        log_array.append(next_line)

        #if the field 'duid' == 'hdu', then clear all the fields
        if field_values['duid'] == 'hdu':
            self.clear()
        #loop through all TextCtrl fields storing the key/value pairs in
k, v
        for k,v in self.fields.items():
            # get the pickle value for this TextCtrl
            f = field_values.get(k, None)
            # if the value is empty then set the new value
            if f:
                v.SetValue(f)

But the program is not working, meaning the TextCtrl fields are not
getting their values and the log is not being written.  I dont know if I
am missing a self.something or I some indentation wrong that doest throw
the error or what.  Very Stuck.




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to