in reply to Re^2: Extensibility of Tk::TableMatrix
in thread Extensibility of Tk::TableMatrix

on a second thought - maybe you need table indeed.

There is a number of tk widgets to deal with task, and tablelist widget is one of them (another alternatives could be treeview from tile package and tktable).

use strict; use Tcl::Tk; my $int = new Tcl::Tk; my $mw = $int->mainwindow; # the tablelist widget is described at # http://docs.activestate.com/activetcl/8.5/tablelist/tablelistWidget. +html $int->pkg_require('tablelist'); $int->Eval('namespace import tablelist::*'); my $w_t = $mw->Scrolled('tablelist',-columns =>[0, "First Column", 0, +"Another column"], -stretch =>'all', -background =>'white')->pack(-fill=>'both', + -expand=>1, -side=>'top'); $w_t->columnconfigure(0, -editable=>1); $w_t->columnconfigure(1, -editable=>1); $w_t->insert('end', ["row $_;", "$_ bla bla"]) for 'a'..'zzz'; $int->MainLoop;
look at description of tablelist - it is really powerful - it allows editing with text or checkbutton or 'edit' widget.

Replies are listed 'Best First'.
Re^4: Extensibility of Tk::TableMatrix
by elef (Friar) on Feb 07, 2011 at 12:38 UTC
    Most of this is way over my head, especially $w_t->insert('end', ["row $_;", "$_ bla bla"]) for 'a'..'zzz';. No idea what that may do.
    I see your code uses Tcl::Tk, which I've never looked into. I've been playing around with Perl/Tk and implemented some very simple Tk code in the latest release of my script. I'm not sure I want to switch over to Tcl::Tk, but I can't see any mention of the tablelist widget in any Perl/Tk documentation. Tcl::Tk is supposed to be simply be another way to acces the same Tk stuff that one can use with the Tk module, so one would expect the same widgets to be available... I'm getting confused here. Well, who would be better able to clear this up than the Tcl::Tk developer, right?
      I warned that my approach to Tk is a bit different :)

      this line:

      $w_t->insert('end', ["row $_;", "$_ bla bla"]) for 'a'..'zzz';
      is rather simple, it is just looping over a list:
      for my $hh ('a'..'zzz') { $w_t->insert('end', ["row $hh;", "$hh bla bla"]); }
      The great advantage of Tcl::Tk over perl/Tk is that in latter you have only those Tk widgets that are happen to be specially adopted for perl, plus pure-perl widgets (and this is not really much)

      Tcl::Tk gives you all zoo of tcl/tk widgets and provides you with a perl/Tk syntax. It is really thin glue between perl and tcl/tk

        just looping over a list

        I got that (eventually, after posting the question), but I still don't see what it would do. Entering the text into cells would be my guess, but the structure of that command makes no sense to me at all. I guess I will look into the widget's documentation if you think the split/merge features can be coded up with tablelist without devoting the rest of my life to the task.
        Is there any TCL::Tk tutorial you can recommend? Some tablelist sample code would be nice as well.