[Tutor] Fwd: Re: Need Help Modifying a wxPython GUI (scrolling display and logging)
Matt D
md123 at nycap.rr.com
Thu Jun 13 06:18:58 CEST 2013
-------- Original Message --------
Subject: Re: [Tutor] Need Help Modifying a wxPython GUI (scrolling
display and logging)
Date: Thu, 13 Jun 2013 00:17:44 -0400
From: Matt D <md123 at nycap.rr.com>
To: Dave Angel <davea at davea.name>
On 06/12/2013 09:44 PM, Dave Angel wrote:
> On 06/12/2013 09:23 PM, Matt D wrote:
>>
>>> 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.
>>>
>>>
>> hey i found the logfile. just took a few minutes of looking round. the
>> file is logged all out of order
>
> Do you have more than one thread? Perhaps you have a race condition.
>
>> so i have some work to do on that
>> formatting issue. if you have a sec can you take a look at my code
>> please?
>>
>> def update(self, field_values):
>
>>
>> # logger code---------------
>> # first write the CURRENT date/time
>> self.logfile.write('%s,'%(str(strftime("%Y-%m-%d %H:%M:%S",
>> gmtime()))))
>
> The return value of strftime is already a str, so why do you call str()
> on it?
>
>> # loop through each of the TextCtrl objects
>> for k,v in self.fields.items():
>
> items() returns an unordered list; what order did you actually want?
>
>> # get the value of the current TextCtrl field
>> f = field_values.get(k, None)
>> if f:
>> #output the value with trailing comma
>> self.logfile.write('%s,'%(str(f)))
>> self.logfile.write('\n')
>
> That looks like a newline, not a comma
>
>> #end logger code ----------------
>>
>> #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():
>
> Same ordering problem here. If you have a specific order in mind,
> you'll need to preserve it in a list, not in a dict.
>
>> # get the pickle value for this text control
>> f = field_values.get(k, None)
>> # if the value is empty then set the new value
>> if f:
>> v.SetValue(f)
>>
>>
>> When i open the .csv file the fields are all out of order. what i want
>> is have them all in one row beginning with the date/time. and idea?
>> Thanks!
>>
>>
>
> A dictionary is unsorted, so those two are probably your problem. As I
> mentioned above, you can't count on the items() order.
>
> Of course, self.items might not really be a dict. This fragment doesn't
> prove that one way or another.
>
>
yes the .py file has TextCtrl fields that get there values from a
pickled dictionary. Another peice of the code watches a thread for the
pickle. this is why i didnt use a list. I have been unable to find a
nice way to just make a list with the items i need. would be nice to
have that simplicity.
What you said is true, the the list is unordered. More importantly the
new line comes in at the wrong point. I want all the values in a row
starting with time. from there i will look for a way to remove some
unwanted items and ordering the others.
I attached the .py file for you to see the whole thing hoping this is
not too presumptuous. Thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: op25_traffic_pane.py
Type: text/x-python
Size: 9188 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20130613/2e48b993/attachment.py>
More information about the Tutor
mailing list