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

This isn't a question, but a tip for people who run into the same problems i did. I will point out some properties of the corresponding Modules, which weren't clearly documented, or not documented at all.

I needed a tabular Tk widget to display and modify a large amount of datasets. The Standard HList widget doesn't feature resizing and sorting so i had a look on cpan.

First i found the widget MListbox which has a lot of features(resizing,sorting), but for which binding of keyboard shortcuts didn't work.

The Reason for the keyboard shortcuts not working is a simple one, but one has to be aware of it:
Even though one has clicked into the widget, or even selected some entries, the widget doesn't automatically receive the keyboard input focus (most other Tk-widgets do that for you once sbd clicks into it). This has to be done manually:
$mlistbox->bindRows( '<Button>' , sub {$mlistbox->focus();});
Afterwards binding keys worked fine, but unfortunately this widget was to slow for the 10000 records which were inserted into it.

Looking for a faster widget, i found another widget Tk::TableMatrix which is really fast, but which also had one point in which it's behaviour was less than intuitive:
Trying to left justify the text inside each box, i was tempted to use the option -justify => 'left' - which to my surprise - didn't work. After trying several options i finally found out, that left justification of text can be achieved through the use of the option -anchor => 'w'.

My guess is (to lazy to check the source), that -justify only causes justification inside some tk-widget representing a single box, but the widget itself is displayed centered, causing the impression of centered text. But when anchoring that widget to the west, the text will appear left justified even though it might be centered inside the widget ... .

Another hint: Tk::TableMatrix which comes with Active State Perl 5.8.4 seems to be compiled against a wrong Tk-version, so it doesn't work.

Replies are listed 'Best First'.
Re: Some Tk::TableMatrix and Tk::MListbox excentricities
by zentara (Cardinal) on Apr 21, 2006 at 11:40 UTC
    Thanks for the tips.

    I've recently experienced a glitch with Tk::TableMatrix, with Perl 5.8.8. When you build the module, the makefile creation would fail. I'm not sure why, because I have no trouble building any other modules. I did find a work-around-hack..... I have a system using Perl 5.8.7 and ran "perl Makefile.PL" with it(which worked), copied the makefile over to my Perl5.8.8 system, adjusted all the locations, and ran make. It worked. I've reported it as a bug, and it's been reported before by others.


    I'm not really a human, but I play one on earth. flash japh
Re: Some Tk::TableMatrix and Tk::MListbox excentricities
by vkon (Curate) on Apr 21, 2006 at 14:59 UTC
    Your widget domain will be much larger, and therefore probability of success find, if you'll use Tcl::Tk cpan module, so allowing such Tcl/Tk widgets as Hugelist or somesuch
      thanks for the hint. Sounds really usefull (at least when i am coding for personal use). Unfortunately i doubt that it will be of use when i'm coding for my company, as it must be possible to compile my perlscripts with perlapp (from Activestate), and i doubt that the compiled version would work when using Tcl::Tk.
      Still - sounds excellent for my personal use, thanks.
        Yes, I didn't tried perlapp with Tcl::Tk, because ... I used my own packagin system, for some reasons.

        Due to simplicity of Tcl::Tk, packaging Tcl::Tk itself would be easier than perl/Tk, but harder part is packaging Tcl/Tk (it has its own packager, but I don't know if these two work together)

        If this still subject of interest for you (and other users) I can try asking ActiveState people questions like this.

        BR,
        vkon

Re: Some Tk::TableMatrix and Tk::MListbox excentricities
by ldln (Pilgrim) on Apr 23, 2006 at 19:31 UTC
    rminner, just curious but what approach have u taken to deal with the memory leakage problems this module has?
      didn't notice memory leakage, but i also wasn't looking for it. The app which i wrote tends to goble up a lot of memory anyhow, and it doesn't run for a long time in a row. So even if there are some circular references it doesn't matter so much, as it won't be left running for a long time.

      Still a valid question, even though i didn't have reason to look for an answer yet. (Didn't even know that problem existed).

      Sorry i couldn't help you. In case you find an answer for the problem you mentioned, it would be nice if you could post it here.

      UPDATE: I once had a problem with cyclic refrences, found the problem and solved it using Devel::Cycle, in case that helps you.