======== On Jul 2, 7:46 am, zentara wrote: > On Sun, 01 Jul 2007 16:20:57 -0700, pnbe...@gmail.com wrote: > >I don't know what I am doing but I do know what I want. > >I am trying write a small Perl/Tk program that takes the data present > >on /dev/ttyS0 and displays it in a Label widget. > > >All that happens is I get a Perl/Tk window that displays "Weigh- > >Tronix /dev/ttyS0" rather than the actual scale weight. What am I > >missing here? > >Thanks for any help. > >Paul > > As felix said, you are just displaying the name of the serialport. > > You need to open the serial port and read it like a filehandle. > As you read the filehandle, you can update the label, but unless the > messages are extremely short, you may be better off displaying it in a > Text widget. > > Here is a super-simple way of reading the serial port. I'm using the > Object Oriented Device::Serial port, but you can also try to read the > port with filehandle directly (but it can be a hassle). > > use warnings; > use strict; > use Tk; > use Device::SerialPort; > > #my $serial_port = "/dev/ttyS0"; > my $serial_port = new Device::SerialPort ("/dev/ttyS0") || die "can't > open COM1\n"; > > #Setup Perl/Tk > my $mw = MainWindow->new(); > $mw->title("Scale"); > > #Close button > my $button = $mw->Button( > -text => 'Close', > -command => sub {$mw->destroy} # exit is better here > )->pack( > -pady => 20, > -side => 'bottom' > ); > > my $title_label = $mw->Label( > -text => "Weigh-Tronix" > )->pack( > -side => 'left'); > > my $input = '---------------'; > my $display_label = $mw->Label( > -textvariable => \$input, > -width=>15, #keep the width stable at 15 > )->pack( > -side => 'left'); > > # every 100 millisecs update from port > $mw->repeat(100, sub{ > $input = $port->input; > if(defined $port->input){ $input = $port->input } > > }); > > MainLoop; > > __END__ > > zentara > > -- > I'm not really a human, but I play one on earth.http://zentara.net/japh.html Thank you very much for the leads. I read up on filehandles in the Camel book and came up with the following code that does work: use warnings; use strict; use Tk; my $serial_port = "/dev/ttyS0"; open(SERIAL, "<$serial_port"); my $scale_weight = ; #Setup Perl/Tk my $mw = MainWindow->new(); $mw->title("Scale"); #Close button my $button = $mw->Button( -text => 'Close', -command => sub {$mw->destroy} )->pack( -side => 'bottom' ); my $title_label = $mw->Label( -text => "Weigh-Tronix" )->pack( -side => 'left', -pady => 5, -padx => 5 ); my $display_label = $mw->Label( -textvariable => \$scale_weight )->pack( -side => 'left', -pady => 5, -padx => 5 ); MainLoop; I will investigate the Device::SerialPort package and thank you very much for the example on getting the program to refresh the display, I was wondering how to do that! Paul