|Do you know where your variables are?|
POE/Tk/Fileevent Strangenessby cmv (Chaplain)
|on Jun 26, 2009 at 21:52 UTC||Need Help??|
cmv has asked for the
wisdom of the Perl Monks concerning the following question:
I'm trying to write a GUI with Tk and POE, that simply reads in and parses text from a file, then puts up some GUI elements to represent the data. I want the data to be read in a line at a time, and for the data input, and GUI output to be done in real time (reason for POE). The GUI elements should always be active (ie the scroll bar should always scroll).
The program below shows my first attempt at a simple read-it-in-and-print-it-out scenario. This program seems to act strangely.
As you can see, I chose to use a single POE session (this may be the root of my problem), and use Tk's fileevent to handle the input. I assumed that POE would take care of sharing between reading input and doing GUI stuff (I suspect I'm wrong here for some reason).
When I run this, the Text window comes up blank, then I see the entire contents of the input file on STDOUT, then the Text window is updated.
Trying to scroll the Text window is very slow once all the text is there.
Whatever happened to the sleep?
I also don't understand why I should have to put "update" lines in there.
If I comment out the "update" lines, then the sleep get's hit, but the text window never shows up.
Any help or pointers is very much appreciated!