2010-08-03 5 views
0

내 C/gtk + 응용 프로그램에 gtkradiobuttons가 4 개 있습니다. 그러나 그들 모두는 활동적입니다.GtkRadioButton이 활성 상태이고 비활성 상태입니다.

내 코드 :

radio_button1 = gtk_radio_button_new_with_label(radio_list, "radio1"); 
radio_button2 = gtk_radio_button_new_with_label(radio_list, "radio2"); 
radio_button3 = gtk_radio_button_new_with_label(radio_list, "radio3"); 
radio_button4 = gtk_radio_button_new_with_label(radio_list, "radio4"); 

나는 사람을 읽을 수는 있지만 솔루션을 한 번에 그것을 만들 수있는 방법 하나의 라디오 버튼이 활성화 될 수를 찾을 수 없습니다.

Gtk Docs에서 당신에게

답변

2

감사합니다

void create_radio_buttons (void) { 

    GtkWidget *window, *radio1, *radio2, *box, *entry; 
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 
    box = gtk_vbox_new (TRUE, 2); 

    /* Create a radio button with a GtkEntry widget */ 
    radio1 = gtk_radio_button_new (NULL); 
    entry = gtk_entry_new(); 
    gtk_container_add (GTK_CONTAINER (radio1), entry); 


    /* Create a radio button with a label */ 
    radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), 
                 "I'm the second radio button."); 

    /* Pack them into a box, then show all the widgets */ 
    gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2); 
    gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2); 
    gtk_container_add (GTK_CONTAINER (window), box); 
    gtk_widget_show_all (window); 
    return; 
} 
관련 문제