gui problems
| From: | Benjamin Orchard | Date: | Thu, 23 Sep 2004 14:36:45 +0000 |
| Subject: | gui problems | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-5108@lists.php.net to get a copy of this message | ||
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