in reply to Tk (Tcl::Tk) programmatically monitor change in Listbox
How would @list get modified? That is the real question here.
You don't show any code for that.
Do you want a right-click menu to add/delete? Do you want an Add/Delete menu bar?
Adding a new element to the listbox means that
has been modified. Perhaps:my @list = ( "a", "b", "c", "d", "e", "f" );
my @list = ( "a", "b", "c", "d", "e", "f","g" ); or perhaps ( "a", "b", "NEW", "c", "d", "e", "f" ) or perhaps ( "a", "b", "c")
I would be thinking of just deleting all element in the Listbox
and then re-insert the new elements from this modified list.
That is one way to change the contents of a Listbox.
It would be very helpful if you could describe what the user is
going to do that results in a different displayed Listbox contents?
I think there is a wrong thought model here. If you change the Listbox,
then you know you did that. Call the update Listbox routine. Or perhaps
the window with list box, fetches new data every time is is displayed.
My last thought would be a timed update every x seconds.
================================= use strict; use warnings; use Tk; my $mw = MainWindow->new(); my $lbox = $mw->Listbox()->pack(); my @list = ( "a", "b", "c", "d", "e", "f" ); $lbox->insert('end', @list ); $lbox->selectionSet('2'); #default starting selection in the box,"c" $lbox->bind('<<ListboxSelect>>', sub{warn "new ListBox element selecte +d!\n"} ); MainLoop;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Tk programmatically monitor change in Listbox
by IB2017 (Pilgrim) on Jan 06, 2020 at 10:45 UTC | |
by jcb (Parson) on Jan 07, 2020 at 02:15 UTC | |
by IB2017 (Pilgrim) on Jan 07, 2020 at 11:12 UTC | |
by Anonymous Monk on Jan 07, 2020 at 04:21 UTC | |
by IB2017 (Pilgrim) on Jan 07, 2020 at 11:22 UTC | |
by huck (Prior) on Jan 07, 2020 at 15:34 UTC | |
by Takamoto (Monk) on Jan 08, 2020 at 08:47 UTC | |
by IB2017 (Pilgrim) on Jan 07, 2020 at 17:17 UTC | |
by jcb (Parson) on Jan 08, 2020 at 00:37 UTC |