Re: I have some problems here... can anyone help me ?

From: Date: Sun, 01 Jul 2001 01:27:50 +0000
Subject: Re: I have some problems here... can anyone help me ?
Groups: php.gtk 
Request: Send a blank email to php-gtk+get-2008@lists.php.net to get a copy of this message
> First, presentation stetic: how to define the alignment of the table cells inside ? In this > specific case, i need all cells left-justified, but in others i need mixed alignments; 1 - Thanks to Steph, first problem solved ! - Now this have a nice look ! > Second, in the comboBox3, how to get the indexes, and not the text values (i.e., i need > 0,1,2 and not 'Tiny','Small','Normal'; without this ridiculous > comBox3Changed ? 2 - Just change how to fill a list don't solve how to get the index in a way similar to $entry->getText(), i.e., without the need of handling events and storing temporary results until necessary. > Third, exists a way to get the index of the selected button without this ugly > button4Changed ? 3 - The same to checkbox... > Fourth, my english; i'm reading tech docs for 20 years, but never learned to write or > talk...sorry 4 - Impossible to solve, i just need a new brain (a good one - this i'm using is a fake) ! I did a weak solution to 3, well, not a solution, just a better (???) way to do the same as before This is the new code with the changes - at least the visual now is beatifull - very better than the logic inside ('more-or-less' is more adequate than 'logic' until now) <? // standard header if(strtoupper(substr(PHP_OS,0,3))=='WIN') dl('php_gtk.dll'); else dl('php_gtk.so'); function closeWindow($widget){$window=$widget->get_toplevel();$window->destroy();} function shutdown(){Gtk::main_quit();} $window=&new GtkWindow; $window->connect('destroy','shutdown'); $window->set_title('form'); $window->set_border_width(0); $verBox = &new GtkVBox(FALSE,0); $verBox->set_border_width(0); $window->add($verBox); $verBox->show(); $table = &new GtkTable(3,5,FALSE); $table->set_row_spacings(2); $table->set_col_spacings(2); $table->set_border_width(5); $verBox->pack_start($table,FALSE,FALSE,0); $table->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); // result from a global search for 'align' $table->attach($align,0,1,0,1,GTK_FILL); // in all gtk manual... $align->show(); // and then a look in 'Hitchhiker's Guide' $label = &new GtkLabel('Code '); $label->set_justify(GTK_JUSTIFY_LEFT); // thanks twice, Steph ! Problem 1 solved ! $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,0,1,GTK_FILL); $align->show(); $colLength = 5; $entry0 = &new GtkEntry(); $entry0->set_max_length($colLength); if(($entryLength = 8*$colLength)<18) $entryLength = 18; $entry0->set_usize($entryLength,18); $align->add($entry0); $entry0->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,0,1,1,2,GTK_FILL); $align->show(); $label = &new GtkLabel('Short Description '); $label->set_justify(GTK_JUSTIFY_LEFT); $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,1,2,GTK_FILL); $align->show(); $colLength = 30; $entry1 = &new GtkEntry(); $entry1->set_max_length($colLength); if(($entryLength = 8*$colLength)<18) $entryLength = 18; $entry1->set_usize($entryLength,18); $align->add($entry1); $entry1->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,0,1,2,3,GTK_FILL); $align->show(); $label = &new GtkLabel('Length '); $label->set_justify(GTK_JUSTIFY_LEFT); $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,2,3,GTK_FILL); $align->show(); $typeText[0]="Tiny"; $typeText[1]="Short"; $typeText[2]="Normal"; $typeText[3]="Long"; $typeText[4]="Big"; $comBox3 = &new GtkCombo(); $comBox3->set_popdown_strings($typeText); $comBox3_entry = $comBox3->entry; $colLength = 20; $comBox3_entry->set_max_length($colLength); if(($entryLength = 8*$colLength)<18) $entryLength = 18; $comBox3_entry->set_usize($entryLength,18); $comBox3_list=$comBox3->list; $comBox3_list->set_selection_mode(GTK_SELECTION_BROWSE); $index3 = 2; $comBox3_list->select_item($index3); $comBox3_list->connect('select_child','comBox3Changed'); function comBox3Changed($whatIsThis){ // i don't know what goes here... global $comBox3,$typeText,$index3; $temp = $comBox3->entry; $index3 = $temp->get_text(); } $align->add($comBox3); $comBox3->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,0,1,3,4,GTK_FILL); $align->show(); $label = &new GtkLabel('Type '); $label->set_justify(GTK_JUSTIFY_LEFT); $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,3,4,GTK_FILL); $align->show(); $horBox = &new GtkHBox(FALSE,0); $horBox->set_border_width(0); $align->add($horBox); $horBox->show(); $index4 = 1; $button4=&new GtkRadioButton(null,'Autonumber'); $button4->connect('clicked','button4Changed',0); function button4Changed($button,$value){ global $index4; $index4 = $value; echo '['.$index4.']'; } $horBox->pack_start($button4,TRUE,TRUE,0); $button4->show(); $button=&new GtkRadioButton($button4,'Signed'); $button->set_active(TRUE); $button->connect('clicked','button4Changed',1); $horBox->pack_start($button,TRUE,TRUE,0); $button->show(); $button=&new GtkRadioButton($button4,'Unsigned'); $button->connect('clicked','button4Changed',2); $horBox->pack_start($button,TRUE,TRUE,0); $button->show(); $horBox = &new GtkHBox(FALSE,0); $horBox->set_border_width(0); $verBox->pack_start($horBox,FALSE,FALSE,0); $horBox->show(); $button=&new GtkButton('Show me'); $button->connect('clicked','showMe'); $horBox->pack_start($button); $button->show(); $button=&new GtkButton('Close'); $button->connect('clicked','shutdown'); $horBox->pack_start($button); $button->show(); $window->show(); Gtk::main(); function showMe($button) { global $entry0,$entry1,$index3,$typeText,$index4; $crlf = chr(13).chr(10); echo $crlf; echo 'Code:'.$entry0->get_text().$crlf; echo 'Short Description:'.$entry1->get_text().$crlf; // do this ugly search only 1 time - ok, is not a good solution, but is the best i can do until now... for($index=0;$index<count($typeText) && $index3!=$typeText[$index];$index++); echo 'Length:'.$index.$crlf; echo 'Type:'.$index4.$crlf; } ?>

« previous php.gtk (#2008) next »