Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: How to query entry path for embedded widgets and parent entry
If I understand correctly, I think he's embedding widgets, and probably
either binding them or setting up a callback for each one, and suddenly
there is the dilemma - assuming that the each widget has the same
callback or event handler code, how do you know which one in the list
was activated or triggered?

For what you're looking to do, there's a fairly easy way of handling
this: You pass the entry path as a parameter to each of the callbacks
or event handlers you set up. Here is a working demo. Is this something
like what you're trying to do?

Rob

use Tk;
use Tk::HList;

my $mw = MainWindow->new(-width => 360);

my $lab_orig = $mw->Label(-text => "test")->
pack(qw/ -expand 1 -fill both/);

## Create the Scrolled HList
my $list = $mw->Scrolled("HList",
-scrollbars => "osoe",
-background => "white",
-itemtype => 'window',
)->pack(qw/-expand 1 -fill both/);

## Add 10 entries, notice how I pass the "id" and $path to each callback
foreach my $i (1 .. 10) {

my $button = $list->Button( -text => "Button $i" );
my $path = $list->add($i, -itemtype => 'window', -widget => $button);
$button->configure(-command => [\&reportInfo, $list, $i, $path]);
}

MainLoop;

## THis subroutine demonstrates that the correct button is being
## invoked, and that I can access the $path in which the widget
## resides. I demonstrate by toggling the selection, just so that
## you can see something happening within the HList.

sub reportInfo {
my ($hlist, $id, $path) = @_;
print "Button $id pressed\n";
if   ($hlist->selectionGet()) { $hlist->selectionClear(); }
else                          { $hlist->selectionSet($path); }
}

Report this thread to moderator Post Follow-up to this message
Old Post
Rob Seegel
11-25-04 01:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:44 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.