Design Question. Data Acquisition/Display related.

Alex Verstraeten alex at quad.com.ar
Tue May 17 11:27:20 EDT 2005


StepH wrote:

>>a simple loop could do it
>> - handle user events
>> - collect data
>> - update displays
>> - sleep
>>    
>>
>Here i've a prob. (due to the fact that I start both with Python & 
>TkInter).  In TkInter, you run your app by launching a mainloop() 
>routine, right ?  So, how, in my forever loop (handle user events / 
>Collect data / Update Display / Sleep) handle the user data ?
>
>Sure, i can (i suppose), log user activity (via the event send by the Tk 
>underlayer), the "poll" theses event in my for ever loop ?  But in this 
>case, are these event will be correctly generated (by Tk) ?  How to 
>"give the hand" to Tk in such scenario ?
>
>Thanks for your help.
>
>StepH.
>  
>
oops, sorry, I was thinking of a 'pygame' kind of loop, where you have 
control over it.
I dont have experience on Tk, I allways use wxPython or pygame for gui's.

you can forget about the loop I mentioned... it doesn't apply to 
event-driven applications where you have no control over the loop.
you'd be using a timer that triggers a tick method at a certain 
interval, in that tick method you could tell your data collectors to 
collect data... then the data collectors would trigger all its 
subscribed displays's "update" function, so they draw the new available 
data, just like the "for display in self.subscribed_displays: 
display.update(data)".

so it comes to something like this:

tk mainloop is set to call tick() every 100ms through a timer.
tick() will iterate through all data collectors and call their "collect" 
method
each data collector will then collect data  and iterate through all 
asociated displays calling their respective 'update' method on each.

of course there are plenty of ways to design an app, this is just an idea.

hope it helps,
Alex














More information about the Python-list mailing list