| |||||||||||
globally refresh text-related widgets? Posted by that_guy (that_guy), 4 August 2003 hello. I have a program where after reloading a dataset a large number of widgets should change their contents. I.e. if I load an existing experiment, all the scrolledlistboxes and text widgets, etc., should now display content reflecting the experiment currently in use. Is there a standard(or at least fairly common) way to do this sort of task? Right now when I load an experiment, several arrays used in the program are correctly populated with the new values. I'm not sure how to translate this into an update of all the text related widgets other than perhaps writing a proc that painstakingly takes some action for each widget. I'm guessing there's no such thing as a top level forget and repack with new values command... Posted by admin (Graham Ellis), 4 August 2003 This is one of those things that Tk is really great at doing. Take a look at the label widget (just as an example). It has a -textvariable option, and that means that the label displays what's in the variable. You change the variable contents in your Tcl, and what's displayed on the label changes. No need to run a change command or call a special proc or anything like that. And even greater news; -textvariable is a standard option that works on all appropriate widgets. If you use on a user-changeable widget, it gives your user a way to change the variable ... Oh - and if you (example) increase the length of text in a widget in this way, you don't have to repack either. That's automatic the next time your event loop has the queue empty. Its REAL neat Posted by that_guy (that_guy), 6 August 2003 thanks for the suggestion - I guess my real problem is that I haven't organized things to make that convenient. I've had the widgets get their content via procedures because the way that the data is stored does not necessarily correspond to how it's displayed. I'll have to see if I can rearrange things so that this is no longer the case. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |