in reply to Widget with Scrolled Listbox

Maybe this node will help? TK ListBox Scrolling

Replies are listed 'Best First'.
Re^2: Widget with Scrolled Listbox
by wbarrett (Initiate) on Apr 13, 2016 at 21:46 UTC

    Thanks for your reply - but - I already know how to construct a scrolled Listbox with its callback function, etc. And I have a sophisticated system working, except for this detail.

    I'd like to construct a widget in the form of a popup window that can be called as a dialog box containing a scrolled Listbox.

    Chapter 14 of the Mastering book explains how to construct a widget. It rests on the Construct operation, followed by a Component call. This appears to be a macro generator, but it's hard to tell, since the Perl debugger refuses to follow the operation. Component seems to work fine for a Listbox, but I do not see how to use it to construct a Scrolled Listbox.

    If you look at my example, lines 79-87 in principle should replace lines 89-94, but it will not compile. The example works very well without the Scrolled feature, and I've tried lots of variations on that plan with no success.

    Comes down to poor documentation of Construct and Component. Someone obviously knows how to make great widgets. Why can't I?

      sub build($) { my ($self)= @_; $self->title("My Picker"); $self->Component('Label', 'label1', -text=>"Select a name", -background=>"lightblue")->pack; my $lbox= $self->Scrolled("Listbox", -scrollbars => 'oe')->pack; $lbox->insert('end', @fields); $self->{lbox}= $lbox; }

      Why create a sub class at all? The code posted so far, from the class name, to the @fields array, hints heavily against a sub class being necessary

      Also "Scrolled" is not a type of widget/class, its a helper method

      Use Tk::WidgetDump to see what see sub Tk::Widget::Scrolled and sub Tk::Frame::AddScrollbars actually do, what widgets they create