in reply to Perl/Tk vs Win32::SerialPort

First of all, Tk and threads need special handling, which may confound a beginner. You can find alot of sample code with a google for "Perl/Tk threads". However, I will tell you that even with a thread, you will still need to run a timer to update the shared variable in the main Tk thread. So I will skip the thread approach and show a linux example which just uses a timer to repeatedly read the serial port. This example is for a Linux system, but you should be able to adapt it to Win32.

The basic idea, is to set a textvariable $input which automatically gets updated from the repeater.

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 10 millisecs update from port $mw->repeat(10, sub{ # $input = $port->input; #or maybe better if(defined $port->input){ $input = $port->input } }); MainLoop; __END__

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh