gnope php gtk gui gnope.org  

any example of grouped Radiobuttons?

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
Osiris



Joined: 17 Dec 2005
Posts: 65

PostPosted: Sun Jun 18, 2006 8:47 pm    Post subject: any example of grouped Radiobuttons? Reply with quote

Hi,

to make my application flexible i discarded the created Radiobuttons from a defined GtkTable in my gladefile.

But how to build a grouped radiobutton-"list"?
my first try was this
Code:

      foreach ($kennungen as $kennungKey =>$kennungValue){
         if ($row == 1){
            $firstRadioButton = new GtkRadioButton(null,$kennungValue);
            $firstRadioButton->set_group($firstRadioButton);
            $radioButton = $firstRadioButton;
         } else {
            $radioButton = new GtkRadioButton($firstRadioButton,$kennungValue);
         }
         $this->arWidgets["allgemeineKennungTable"]->attach($radioButton,0,1,$row,$row+1);
         $row++;
      }


but php says: "call to undefined method GtkRdioButton::set_group",
but is documented.
I use latest gnope dlls


Is there any working example available?

Thx a lot

Christian
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Sun Jun 18, 2006 9:21 pm    Post subject: Reply with quote

Christian, it should work the way you tried it. Don't know why it doesn't, though.
Back to top
kksou



Joined: 06 Sep 2006
Posts: 25

PostPosted: Thu Sep 14, 2006 3:11 am    Post subject: Reply with quote

Quote:
foreach ($kennungen as $kennungKey =>$kennungValue){
if ($row == 1){
$firstRadioButton = new GtkRadioButton(null,$kennungValue);
$firstRadioButton->set_group($firstRadioButton);
$radioButton = $firstRadioButton;
} else {
$radioButton = new GtkRadioButton($firstRadioButton,$kennungValue);
}


Try remove $firstRadioButton->set_group($firstRadioButton) from the above. It should work.

PHP-GTK2 will group buttons together as long as you pass in the pointer to the first radio button for subsequent calls to new GtkRadioButton.

The example below might make things clearer:
Quote:

$window = new GtkWindow();
$window->set_size_request(400, 200);

$window->connect_simple('destroy', array('Gtk','main_quit'));

$window->add($vbox = new GtkVBox());

// display title
$title = new GtkLabel();
$title->set_markup('<span color="blue" font_desc="Times New Roman Italic" size="24">Button Group Demo</span>');
$vbox->pack_start($title);

// setup grouped radio buttons
$radio1 = setup_radio(null, 'radio button 1', '101'); // note 1
$radio2 = setup_radio($radio1, 'radio button 2', '102'); // note 2
$radio3 = setup_radio($radio1, 'radio button 3', '103');

// pack them inside vbox
$vbox->pack_start($radio1, 0, 0);
$vbox->pack_start($radio2, 0, 0);
$vbox->pack_start($radio3, 0, 0);

// add a status area
$vbox->pack_start($status_area = new GtkLabel('Click a Button'));

// function to simplify the display of grouped radio buttons
function setup_radio($radio_button_grp, $button_label, $button_value) { // note 3
$radio = new GtkRadioButton($radio_button_grp, $button_label);
$radio->connect('toggled', "on_toggle", $button_value); // note 4
return $radio;
}

// call-back function when user pressed a radio button
function on_toggle($radio, $value) { // note 5
global $status_area;
$label = $radio->child->get_label(); // note 6
$active = $radio->get_active(); // note 7
if ($active) $status_area->set_text("radio button pressed: $label (value = $value)\n"); // note 8
}

$window->show_all();
Gtk::main();


Sample output:


Explanations here
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.