ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-tk
perl-tk
How to find out path of widget in TK-like style ?
by Joel HATSCH other posts by this author
Jul 19 2007 1:42PM messages near this date
Tk on PC/ OSX | Re: How to find out path of widget in TK-like style ?
SOURCE Hello *,

I first though this is a totally newbee FAQ, but after browsing the web and asking several e
xperienced colleagues, it looks like it's not so dumb...

OK, so here it goes : I did a lot of Tk programming in the past. There, when you want to acc
ess a widget, you address it using it's hierarchical name like .frame1.frame2.mybutton. In p
tk however, you use variables to store the objects. If you know the parent's variable, you c
an browse through its children to find the given widget. However, there doesn't seem to be a
 function that maps the string ".frame1.frame2.mybutton" to the corresponding widget's varia
ble. This would be a very useful thing when writing generic procedures, or accessing widgets
 from different sections of the code : given $frame, you could access $frame.mybutton, regar
dless of what $frame is actually pointing to.

So far, people I asked told me they use global variables to store all the widgets they creat
e. Works basically fine, but is not very nice if you use hundreds of widgets in your applica
tion ! Other suggestion was a kind of mapping table (hash) that would allow, having the path
 string, to return the variable representing the widgets. Implemented, works perfectly, but 
I still keep asking myself : 

shouldn't there be built-in functions for this ? or am I doing something methodologically co
mpletely wrong ?

Anyone ?

TIA

Joel
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
ptk@[...].edu
https://mailman.stanford.edu/mailman/listinfo/ptk
Thread:
Joel HATSCH
Slaven Rezic
Vadim
Joel HATSCH

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved