in reply to Re^5: Tk Realtime data aquisition
in thread Tk Realtime data aquisition
while(<$new_sock>) { my $input = chomp $_; #print $_; $canvas->update_graph( $input ) # pseudocode to demo point :-) $mw->update; # force the event loop to auto update the window }
Ideally, you don't want to use a $mw->update in a while() loop. A timer is better, but may not be as fast.....although it will allow you to run other subs in the eventloop simultaneously with the socket connection.... like watching for a value to trip an alarm.
thats better. Then in the update_graph sub, read your socket, and update the canvas. You can start a second timer to watch for values, as they come in( store the last 10 values in a buffer)). It's all an event-loop system underneath......very powerful and useful once you get the idea. :-) Gtk2's event-loop is even more powerful than Tk's.my $timer = $mw->repeat(10, \&update_graph);
|
|---|