Re: Getting 'Data' from Glade 'Signals' tab, GladeXML global
| From: | Alan Knowles | Date: | Sun, 12 Jan 2003 13:48:25 +0000 |
| Subject: | Re: Getting 'Data' from Glade 'Signals' tab, GladeXML global | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-2897@lists.php.net to get a copy of this message | ||
php-gtk User wrote:
First question: I'd like to write a function that incorporates the Data present in the 'Data' field within the Glade widget property 'Signals' tab (the one with the tooltip, "The data passed to the handler"). I'm trying to write a (single, reusable) handler to update an arbitrary Entry widget by passing it the Object name and the Text to update it with. function update_entry($widget_name, $text) { $widget_name->set_text($text); } It's possible, but you would need to sketch it out in more detail before getting any valuable comments....
Suggestions are appreciated. Especially if they contain URLs or examples. "RTFM" is acceptable if accompanied by the above. The above code is only a rough guess. Second question: More PHP-related, I suppose, but I've got the following: $gx = &new GladeXML('gui.glade'); Is there a cleaner way to keep $gx global than declaring, 'global $gx;' within every function that needs access to the GladeXML object? $GLOBALS["gx"] is a bit ugly. normally you would grab all the widgets when you create the glade object: eg.have a look at the _loadInterface() method of this. http://devel.akbkhome.com/VarDump.php.txt also have a look through http://talks.php.net/show/kongress-gtk-des-stratagies/26 (althougth there arent that many examples in it..) since PHP4 does not have static object variables, GLOBALS is about as good as it gets...:: I would normally suggest the pear standard, as using the class name that you start the glade file with eg. class my_interface { function load() {
$GLOBALS['_MY_INTERFACE']['glade'] = new GladeXML;} PHP5 will hopefully allow
my_interface::$glade = new GladeXML;or similar... Regards Alan
Thanks again.-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com