Radio button problem
- From: David <dbree duo-county com>
- To: gtk-app-devel-list gnome org
- Subject: Radio button problem
- Date: Sun, 22 Aug 2004 22:49:47 -0500
In experimenting with radio buttons, this simple program displays my
confusion.. From the documentation, I'd think it should work.
I originally did something along this line:
button1 = gtk_radio_button_new... as below)
then button{2,3} =
gtk_radio_button_new_..._from_widget(gtk_radio_button_get_group(button1)
and it worked, but I thought this method would be simpler to read.
What am I doing wrong? Note that button3 _is_ in the correct group, but
button2 is wrong... I tried a .._set_group before the initial
.._get_group, (I saw this in a glade output), but this didn't work
either).
Out of curiosity, I tried it with 4 buttons. buttons 1 & 4 were in the
same group but buttons 2 and three were each in different groups.
Strange (to me).
---------------------- cut ---------------------
#include <gtk/gtk.h>
int main (int argc,char **argv)
{
GtkWidget *window, *box;
GtkWidget *button1, *button2, *button3;
GSList *group = NULL;
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
box = gtk_vbox_new(TRUE,5);
gtk_container_add(GTK_CONTAINER(window),box);
button1 = gtk_radio_button_new_with_label(NULL, "Button1");
gtk_box_pack_start( GTK_BOX(box),button1,FALSE,FALSE,2);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button1));
g_print("%d group\n",(int)group);
button2 = gtk_radio_button_new_with_label( group,
"Button2");
button3 = gtk_radio_button_new_with_label( group,
"Button3");
gtk_box_pack_start(GTK_BOX(box),button2,FALSE,FALSE,2);
gtk_box_pack_start(GTK_BOX(box),button3,FALSE,FALSE,2);
g_print("%d button1\n",
gtk_radio_button_get_group(GTK_RADIO_BUTTON(button1)));
g_print("%d button2\n",
gtk_radio_button_get_group(GTK_RADIO_BUTTON(button2)));
g_print("%d button3\n",
gtk_radio_button_get_group(GTK_RADIO_BUTTON(button3)));
gtk_widget_show_all(window);
gtk_main();
}
---------------------- cut ---------------------
and here's the output I get:
134574448 group (from right after initializing button1)
134574456 button1
134574544 button2
134574456 button3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]