Re: gui problems

From: Date: Thu, 23 Sep 2004 14:56:36 +0000
Subject: Re: gui problems
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-5109@lists.php.net to get a copy of this message
You can add only one widget to a window. This is from the manual (http://gtk.php.net/manual/en/gtk.gtkwindow.php): "A GtkWindow object is derived from GtkBin, and can therefore only have one child widget added to it directly. To add more children it is necessary to make that child a container that can hold mulitple children. See GtkBox." Try creating a gtkvbox and pack the two hboxes into it. smth. like this: $vbox = &new gtkvbox(); $vbox->pack_start($d4); $vbox->pack_start($d6); $window->add($vbox); instead of $window->add($d4); $window->add($d6); On Thu, 2004-09-23 at 17:36, Benjamin Orchard wrote: > Hey, > I have a question regarding the usage of certain widgets and boxes. > > When trying to pack widgets into multiple GtkVBoxes, I get no widgets, > whereas, adding a single widget works just fine. Let me show you my > source (simple enough). > <?php > //load gtk extension--works > $extension = "php_gtk" . (strpos(PHP_OS, "WIN") >= 0 ? ".dll" > : ".so"); > dl($extension); > > $window= & new GtkWindow(); > $window->connect('destroy', > create_function('','Gtk::main_quit();')); > $window->set_border_width(5); > $window->set_title("Ben's Amazing PHP-GTK Dice Roller"); > $window->set_usize((gdk::screen_width()/2), (gdk::screen_height()/2)); > > //this method, along with other commented sections, wasn't working > //$main= &new GtkVBox(); > > $d4=&new GtkHBox(); > $nd4=&new GtkEntry(); > $d4->pack_start($nd4); > $bd4=&new GtkButton("Roll 'em"); > $bd4->connect("clicked", roll_d4, $nd4); > $d4->pack_start($bd4); > > $d6=&new GtkHBox(); > $nd6=&new GtkEntry(); > $d6->pack_start($nd6); > $bd6=&new GtkButton("Roll 'em"); > $bd6->connect("clicked", roll_d6, $nd6); > $d6->pack_start($bd6); > > > //show main and all children--not working this way--also tried > $main->add($d4); > /*$main->pack_start($d6); > $main->pack_start($d4); > $main->show_all(); > */ > $window->add($d4); > //$window->add($d6); > /*When I add the above line, everything dissappears and I get the > following error message: Gtk-CRITICAL **: file gtkbin.c: line 217 > (gtk_bin_add): assertion 'bin->child == NULL' failed. > What is that? I am really new to all this, but this makes no sense--I > need to make a set of buttons and boxes that stack on top of each other, > but am having serious trouble here--any help would be appreciated. Thanks*/ > //show the window and all children > $window->show_all(); > gtk::main(); > > > function buttonClicked($number, $sides){ > //$txt=strrev($widget->get_text()); > $txt=$number; > $widget->set_text($txt); > } > > ?> > //end code > > I need to know how to make this all work out--the concept is simple > enough, but I just don't quite get the construction method. One of > these days I will. > > Thanks for any help. > > Ben -- http://cosminb.blogspot.com/ c3f7bc9d7683857572da3d1fa3d31af17bde4ebbc5c0f0dc2b7f6f

« previous php.gtk.general (#5109) next »