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

Hey Monks,

I'm updating and merging some modules here... :)
But something annoying happened here...
Please download: http://www.aceserver.dyndns.org:2100/MatchEntryMListbox.zip
and put MatchEntryMListbox.pm in Tk lib dir...
and run matchEntryMListboxTkTest.pl
If all started up, you will see that first column is very small! Looks like its 1, but it should be 20! (as you can see in the exampletest I created.)
And this is what I need help with! I dont get it. It works with the others, but not the first column! Annoying!

UPDATE: Yea, sorry about external link, but I figured you could get the full widget, since I dont know where the problem lies exactly. This way you get the full picture. Zip contains 2 files. The modified .pm and the testscript. _But_, if it's really necessary, I could try break it down (and I could before, but then you wouldnt be able of recreating the problem live...) and as I said, not sure _where_ the problem is in there...

Thanks,
Ace
  • Comment on First column acting wierd! (MatchEntryMListbox) (Tk)

Replies are listed 'Best First'.
Re: First column acting wierd! (MatchEntryMListbox) (Tk)
by pg (Canon) on Sep 18, 2005 at 03:15 UTC

    In MatchEntryMListbox.pm, you have:

    my $scrolled_mlistbox = $popup_frame->Scrolled( qw/MListbox -selectmode browse -scrollbars oe/ );

    Change scrollbars setting from oe to e, your GUI looked fine. I understand that oe is a valid setting, but...

    my $scrolled_mlistbox = $popup_frame->Scrolled( qw/MListbox -selectmode browse -scrollbars e/ );

    But this is not a bug with Tk::MListbox, as this works:

    use Tk; use Tk::MListbox; my $mw = MainWindow->new(); $ml=$mw->Scrolled("MListbox", -scrollbars=>"oe", -columns=>[[-text=>'H +eading1', -sortable=>0], [-text=>'Heading2']])->pack(); MainLoop;
      Ok, changing from oe to e didnt make any difference here at all. First Column is still small, and doesnt seem to be affected at all. Thanks for trying though.
Re: First column acting wierd! (MatchEntryMListbox) (Tk)
by zentara (Cardinal) on Sep 18, 2005 at 11:24 UTC
    If all started up, you will see that first column is very small!

    First, when you distribute custom modules for testing, you should keep them in the working directory for easy cleanup and prevention of garbage collecting in PERL5LIB. So you could have just created a directory in your script directory, called Tk, put your custom module in it, and put " use lib '.' " in your test script.

    Having done that, when I run your test script, I get

    "$full_path" requires explicit package name......
    When I set an inital value to $full_path, like "my $full_path=0", it starts up and the first column, is very small.

    Now that brings us to what is probably causing it. I'm just guessing here, but you are probably getting the default width for MListbox, not what you are passing in as the population hash. Why? Read "perldoc Tk::Derived" and pay close attention to the Populate sub

    sub Populate { my( $self, $args ) = @_; my $flag = delete $args->{-flag}; if( defined $flag ) { # handle -flag => xxx which can only be done at create # time the delete above ensures that new() does not try # and do $self->configure( -flag => xxx ); } ...... .......
    It seems to me that your -width arg is getting lost somewhere in the way you populate your custom widget. Try Tk::Derived

    I'm not really a human, but I play one on earth. flash japh
      Hey,

      "First, when you distribute custom modules for testing, you should keep them in the working directory for easy cleanup and prevention of garbage collecting in PERL5LIB. So you could have just created a directory in your script directory, called Tk, put your custom module in it, and put " use lib '.' " in your test script."

      Ok, gonna do that next time then. Thanks.


      "Having done that, when I run your test script, I get "$full_path" requires explicit package name...... "

      Ok, crap. I fixed that problem on the zip, but I guess you got it before I did that... Sorry about that. Those things bugs me, when you get some test example, and the example isnt even working! (well, atleast this kind of error is annoying).

      And about the problem. Well, Im not sure what I'm supposed to do with the Tk::Derived...
      Also, I dont understand how the width is in the mlistbox widget (according to Data::Dumper), but still seems to have no affect. And, since the other width's works fine (doing the  columnInsert('end', -width => $width, -text => $text);) I mean, since the others work, it doesnt seem to be lost... if not somehow _just the first_ is poped out or deleted somehow and size is set to 1 (or something like that). But it all seems like contradictions... gonna do some more testings here, when Im calm down... :)
        Tk::Derived is a module to help you correctly make custom widgets, which inherit problem-free from parent widgets.

        I may have been "guessing" at the root-source of the problem, and like pg suggested, I got your window to display properly by setting the scrollbar to 's' in the module. 'oe' didn't work for me.


        I'm not really a human, but I play one on earth. flash japh
Re: First column acting wierd! (MatchEntryMListbox) (Tk)
by Anonymous Monk on Sep 18, 2005 at 01:28 UTC

    Why was there no initial investigation done by yourself?

      Come again? Well, I've tested around. Even set the $width in columnInsert('end', -width => $width, -text => $text); to a fix size... no luck.. And this is where it should be the problem, so to speak... but even when I did a print Dumper($mlistbox), it said width = 20... I'm having hard time figuring what the problem could be at this point... can't be that the widget needs an update, and as seen, no wrong value... using latest Tk, v804.027...