in reply to a perl tkx GUI

Mwahahahaha

#!/usr/bin/perl -- use strict; use warnings; $Tkx::TRACE = 64; use Tkx; Tkx::package_require("Tktable"); my $mw = Tkx::widget->new("."); my %hash = ( # data to display '1,0' => 'Vertical', '2,0' => 'Lng', '3,0' => 'Lateral', '0,1' => 'Expected shifts (A)', '0,2' => 'Shifts based on img alignment (B)', '0,3' => '|A-B|', ); my $t = $mw->new_table ( -rows => 4, -cols => 4, -cache => 1, -variable => \%hash, ); $t->g_pack(-fill => 'both', -expand => 1); $mw->new_button( -text => 'Populate', -command => sub { my( $r, $c ) = ( $t->cget('-rows') , $t->cget('-cols') ); for my $rr ( 0 .. $r ){ for my $cc ( 0 .. $c ){ $t->set("$rr,$cc", "yo $rr, $cc oy" ); } } return; }, )->g_pack; $b=$mw->new_button (-text=>"Finish", #~ -command=>sub {RecordData()}, -command=>sub { RecordData(); #~ $mw->destroy; # err #~ $mw->Tkx::destroy; #~ http://docs.activestate.com/activeperl/5.16/lib/Tkx.html #~ http://docs.activestate.com/activeperl/5.16/lib/Tcl/tkkit.html #~ http://docs.activestate.com/activetcl/8.5/tktable/tkTable.html #~ pathName get first ?last? #~ Returns the value of the cells specified by the table indices first + and (optionally) last in a list. use Data::Dump; dd[ $t->configure ]; dd[ Tkx::SplitList( $t->configure ) ]; dd[ $t->cget('-rows') , $t->cget('-cols') ]; #~ dd[ $t->cget ]; dd[ $t->get( qw/ topleft bottomright / ) ]; #~ my $cols = $t->cget('-cols'); for my $row ( 0 .. $t->cget('-rows') ){ #~ dd[ $t->get( "$row.0, $row.$cols" ) ]; #~ bad table index "0.0, 0.4": must be active, anchor, end, origin, to +pleft, bottomright, @x,y, or <row>,<col> #~ dd [ map { $t->get( "$row,$_" ) } $t->cget('-cols') ]; dd [ map { $t->get( "$row,$_" ) } 0 .. $t->cget('-cols') +]; } $mw->g_destroy; }, ); $b->g_pack(); sub RecordData() { # save the data input in the table to a file }; Tkx::MainLoop();

Replies are listed 'Best First'.
Re^2: a perl tkx GUI
by USCG360D (Initiate) on May 29, 2013 at 00:26 UTC
    Thank you so much for the reply. as a new user of perl, I am trying to understand the program you wrote. I guess following code is to populate the value filled in from GUI into the table: $mw->new_button( -text => 'Populate', -command => sub { my( $r, $c ) = ( $t->cget('-rows') , $t->cget('-cols') ); for my $rr ( 0 .. $r ){ for my $cc ( 0 .. $c ){ $t->set("$rr,$cc", "yo $rr, $cc oy" ); } } return; }, )->g_pack; Can you give some comments on the code or give me some website that talk about this in detail? Thank you so much!

      Can you give some comments on the code or give me some website that talk about this in detail? Thank you so much!

      About what exactly , can you be specific?

      I linked the tkx/tk docs and tutorials (which link other tutorials) ... Have you read perlintro?

        I know the basics of perl such as I/O, regular expression, etc. I use perl frequently for file manipulation, calculation, SO I don't know how to make a GUI and don't know how to use all those packages such as table. Could you give me some websites that tells about how to create table, refer to a table, and how to grabbed data typed through GUI? and/or maybe you can give a more detailed comments considering the situation above? Thank you again.