Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Your code which I simplified below works fine.

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

my @list = ( "a", "b", "c", "d", "e", "f" );
has been modified. Perhaps:
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;

In reply to Re: Tk programmatically monitor change in Listbox by Marshall
in thread Tk (Tcl::Tk) programmatically monitor change in Listbox by IB2017

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-24 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found