in reply to Extensibility of Tk::TableMatrix

As I currently see your task, you do not need any of Tk::TableMatrix.

You only need two Text widgets, placed together, with maybe a separator between them so the user could adjust widths.
from time to time, I tend to write such kind of tasks, but I have different approach to usage of Tk from within Perl.
if you wish, I can extract proper GUI building parts from my recent GUI program to show how your could do the task.

as for another part of your question - efficiency of Text widgets - it is rather efficient. No worries about editing several thousand of lines in each.

Regards,
Vadim

Replies are listed 'Best First'.
Re^2: Extensibility of Tk::TableMatrix
by elef (Friar) on Feb 06, 2011 at 19:43 UTC
    Thanks, I would appreciate any guidance and code snippets.
    The reason why I'm considering TableMatrix is that I would like the layout to be like a spreadsheet with word wrap. I.e. grid lines around the text, wrapped into as many lines as needed, and with the rows of the two columns in sync. I.e. if the A1 cell is 2 lines, and B1 is 5 lines, than both A2 and B2 start after the fifth line etc.
    I'm fairly sure Tk::TableMatrix can do this easily, but coding this layout from scratch would probably take a while.
      I've built an app with TableMatrix - I'm not sure that this is going to be the best for you.

      One thing to investigate is wordwrapping. My app just uses the default behavior where text just disappears off the screen if column width is too small. I seem to remember a post that mentioned some trouble getting word wrap to work - so I'd definitely investigate that issue with a little prototype first - make sure your major feature works before getting too far into this.

      You should also be aware that the data storage is a bit strange. TableMatrix uses a hash with keys like: "0,3" or "45,14" to indicate row 0, col 3, etc. That means that inserting a row is a hassle. I didn't do any inserts, but I did do sorts. To sort, on some combination of columns, I wound up just copying to an AoA, sort and then copy back. As it turned out even with 80,000 hash keys, the performance of this was noticeable, but "ok". I don't know what to recommend, but I'd spend some more time looking for something that would allow easier insert operations.

      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.
        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?