G'day coder_perl,
"This doesnt seem to work !"
That tells us nothing useful at all.
What didn't work?
In what way didn't it work?
What output did you get?
What output were you expecting to get?
Were there any error or warning messages?
Please following the guidelines in "How do I post a question effectively?" when posting questions.
Why are you using sysopen to read a text file?
Why are you using a mode of O_RDWR?
Possible options (for better ways to access the data) might include not using an intermediary file, but instead iterating the output of your egrep command by using:
Your "$myLabel=..." is also problematic.
You assign each Tk::Label widget you create (in every iteration of the while loop) to the same package global variable.
The 'vars' stricture of strict would have warned you about this.
The title of your post also needs mentioning: "Perl tk" is far from adequate.
A better choice would be something like: Problem creating Tk::Label widgets from file data.
See "How do I compose an effective node title?".
| [reply] [d/l] [select] |
#!/usr/bin/perl
use Tk;
use strict;
my $mw = MainWindow->new;
my $buf;
open (FH,"< $0");
read( FH, $buf, -s FH );
close FH;
my $label = $mw->Label(
-textvariable => \$buf,
-background => 'black',
-fg=>'yellow',
)->pack;
MainLoop;
The reason your code dosn't work, is you didn't define $memWindow anywhere, and you didn't pack your labels. If you don't pack them, or use another geometry manager, the labels lay hidden behind the scenes. Also see: linux memory leak monitor for a good example of what you may be looking for. Be aware, that you shouldn't
use system, or sleep, or anything which blocks the eventloop in GUI's. It is better
to fork or use a pipe to run commands.
| [reply] [d/l] |
| [reply] |