Re: best practice
| From: | Alan Knowles | Date: | Mon, 22 Apr 2002 09:24:09 +0000 |
| Subject: | Re: best practice | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-1822@lists.php.net to get a copy of this message | ||
Its one of those perplexing questions :) -
I would probably go for the preloader
class myinterface {
var $_interface_items = array(
"window",
"entrybox",
"ok_button"
);
/* put this in a base classe ? */
function load_glade($file) {
$this->glade = &new GladeXML($file);
foreach($this->_interface_items as $item)
$this->$item = $this->glade->get_widget($item);
}
function main () {
$this->load_glade("mygladefile");
$this->entrybox->set_text("hello world");
$this->window->show();
}
}
if you can get the overload extension (http://www.php.net/manual/en/ref.overload.php) working you could try
class myglade extends gladeXML {
function &__get($name) {
return $this->get_widget($name);} }
hence you may be able to useoverload('myglade'); $glade = &new myglade('glade.xml'); overload($glade)= $glade->window->show(); $glade->gtktext_item->set_text("somevar"); so you get all the glade objects automagically.. - I've not tested this - so it may/or may not work !- let me know if you have any success... regards alan Rolland Dudemaine wrote:
Heloo, I'm using php-gtk along with libglade to create some complex yet maintainable gui work. Between those two, which is the best practice ?: - have a GladeXML reference that lives along and ask it for components each time needed - have an array loaded at startup that contains references to each of these components A motivated answer would be good, as I cannot really choose between one or another. Best regards, Rolland Dudemaine