GtkRadioButton 设置活动和停用

发布于 2024-09-13 03:18:18 字数 439 浏览 2 评论 0原文

我的 C/gtk+ 应用程序中有 4 个 gtkradiobuttons。但他们都很活跃。

我的代码:

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");

我读了 man 但没有找到解决方案,如何才能使一次只有一个单选按钮处于活动状态。

谢谢

I have 4 gtkradiobuttons in my C/gtk+ application. But all of them are active.

My code:

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");

I read man but not found solution, How can make that in one time only one radiobutton be active.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜泪 2024-09-20 03:18:18

来自 Gtk 文档

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;
}

From the Gtk Docs:

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文