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++; } } }

In reply to TkxTables within a TkxTable by richardh865

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.