Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Extensibility of Tk::TableMatrix

by elef (Friar)
on Feb 06, 2011 at 19:43 UTC ( #886542=note: print w/ replies, xml ) Need Help??


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

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.


Comment on Re^2: Extensibility of Tk::TableMatrix
Re^3: Extensibility of Tk::TableMatrix
by Marshall (Prior) on Feb 07, 2011 at 04:14 UTC
    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.

Re^3: Extensibility of Tk::TableMatrix
by vkon (Deacon) on Feb 07, 2011 at 08:56 UTC
    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?
        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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://886542]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-07-30 15:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (235 votes), past polls