Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

TkxTables within a TkxTable

by richardh865 (Initiate)
on Jun 20, 2015 at 05:40 UTC ( [id://1131238]=perlquestion: print w/replies, xml ) Need Help??

richardh865 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Enlightened Ones

I have written a routine to generate a calender using TkxTable. The problem is that the inner tables only display the date sequence for the last month processed for all months displayed. If you adjust the 'for' loop which runs through the months the previous months get attributed with that last months sequence

Not sure what I have got wrong but there seems limited information on the www and the man pages don't seem to cover this scenario

Any help appreciated

use Tkx; Tkx::package_require("Tktable"); use Date::Calc qw(Today Month_to_Text Decode_Month Delta_Days Add_Delta_Days Day_of_Week Days_in_Month ); sub calc_month($$$); my @month_name; my $year = "2015"; my @mf; my @mt; my @test; my @tmo; my $mw = Tkx::widget->new("."); my %hash1 = ( '0,0' => '' ); my %hash = ( # data to display '0,0' => 'M', '0,1' => 'T', '0,2' => 'W', '0,3' => 'T', '0,4' => 'F', '0,5' => 'S', '0,6' => 'S', ); # Year Frame (my $yf = $mw->new_ttk__frame(-padding => "5 5 5 5",))->g_pack; $mw->g_wm_minsize(750,730); #Year Table my $yt = $yf->new_table ( -rows =>4, -cols =>3, -rowheight=>11, -colwidth=>40, -maxheight=>700, -maxwidth=>700, -variable => \%hash1, ); for (my $m = 1; $m <=12; $m++) { $mf[$m] = $yt->new_ttk__frame(-padding => "5 5 5 5"); $mt[$m] = $mf[$m]->new_table ( -rows => 7, -cols => 7, -colwidth=>4, -variable => \%hash, ); $month_name[$m] = Month_to_Text($m); $tmp[$m] = $mf[$m]->new_label(-textvariable => \$month_name[$m]); $tmp[$m]->g_pack; calc_month($year,$m,$mt[$m]); $mt[$m]->g_pack; my $x = $m -1; $x = int $x /3; my $y = ($m - 1) % 3; print "$x, $y \n"; $test[$m] = $yt->window_configure("$x,$y", -window=>$mf[$m]); }; my $tmp = $yf->new_label(-textvariable => \$year); $tmp->g_pack; $yt->g_pack; Tkx::MainLoop(); sub calc_month($$$) { my $year = shift; my $month = shift; my $t = shift; my $start_day = Day_of_Week($year,$month,1); $start_day =$start_day - 1; #brings it back to cols in tables my $days = Days_in_Month($year,$month); $month_name = Month_to_Text($month); print "$start_day , $days, $month_name, $t\n"; my $x = 1; my $fday; # formatted day for (my $r = 1; $r <=6; $r++) { for (my $c = 0; $c <= 6; $c++) { if (($x > $start_day)&&($x <= ($days + $start_day))) { $fday = sprintf "% 2d",$x - $start_day; } else { $fday = ""; } $t->set("$r,$c",$fday); $x++; } } }

Replies are listed 'Best First'.
Re: TkxTables within a TkxTable
by Anonymous Monk on Jun 20, 2015 at 07:34 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1131238]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-16 15:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found