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

I would like to ask regarding Tk and Perl-Tk in particular, and more particular Tk::TixGrid. Using set() i as a method to TixGrid I know I can create a new cell in the table. As parameter to set() i can have -itemtype wich indicates what kind of content the cell has. My question is ,can the content of the cell be another widget like a button or a list or somethign like that ?

Replies are listed 'Best First'.
Re: TxGrid having widgets in cells
by zentara (Cardinal) on Aug 16, 2007 at 15:23 UTC
    Most Tk widgets, which take an itemtype, can take an itemtype of "window", which you can load with whatever you want.
    #!/usr/bin/perl -w use strict; use Tk; use Tk::TixGrid; my $g; my $mw = Tk::MainWindow->new(); $mw->optionAdd('*selectBackground' => 'lightblue'); MakeGrid($mw); MainLoop; sub MakeGrid { my ($w) = @_; $g = $w->Scrolled('TixGrid'); $g->pack(qw/-expand yes -fill both -padx 3 -pady 3/); $g->size(qw/col default -size 10char/); $g->size(qw/row default -size 2.1char -pad0 3/); for my $x (0..9) { for my $y (0..9) { my $window = $g->Button( -text=> int rand 100, -command=> sub{print "$x $y\n"} ); $g->set($x,$y, -itemtype=>'window',-window=> $window ); } } } __END__

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum

      thank you , i've made it :)