Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gtk in ada using radiobuttons

54 views
Skip to first unread message

ldries46

unread,
Oct 15, 2022, 10:29:53 AM10/15/22
to
I realized a set of two radiobuttons that should operate in a group,
either one or the other but I cannot find the correct way to combine
these two radio buttons although I can see the dialog in which they are
used. only both buttons are on and clicking on them cannot set either of
the off. I tried to find an example how to do this on internet.  I just
send the used files along. Can anybody help me.


CPP2Ada_Dialog_Type_Init.ads
CPP2Ada_Dialog_Type_Init.adb

Ludovic Brenta

unread,
Oct 15, 2022, 11:58:04 AM10/15/22
to
Read the comments at the top of gtk-radio_button.ads; it explains how to
retrieve the group from the first radio button and then assign all other
buttons to that group. See Get_Group, Set_Group.

--
Ludovic Brenta.
Talent retention and emotional impact technically interact with scalabilities.

ldries46

unread,
Oct 16, 2022, 12:43:22 PM10/16/22
to
Op 15-10-2022 om 16:28 schreef ldries46:
As far as I can read in gtk-radio_button.ads the followinf dtatements
should do the trick:

      TypeDialog.Radio_Frame := Widget_SList.Null_List;
      TypeDialog.Radio_Header :=
Gtk_Radio_Button_New_With_Label(TypeDialog.Radio_Frame,To_String(Ext_C_Header(lan)));
      TypeDialog.Radio_CPP :=
Gtk_Radio_Button_New_With_Label(TypeDialog.Radio_Frame,
To_String(Ext_CPP_Header(lan)));

      Pack_Start
        (TypeDialog.Radio_Button_Box,
         TypeDialog.Radio_Header,
         Expand  => True,
         Fill    => True,
         Padding => 0);
      Pack_Start
        (TypeDialog.Radio_Button_Box,
         TypeDialog.Radio_CPP,
         Expand  => True,
         Fill    => True,
         Padding => 1);

But the dialog looks good with the exception that both buttons are
activated and cannot be deactivated. I still do want the choice between
the two I cannot find that in the When running in debugging mode I can
see that the group still is null


Jeffrey R.Carter

unread,
Oct 16, 2022, 4:09:10 PM10/16/22
to
On 2022-10-15 17:58, Ludovic Brenta wrote:
> Read the comments at the top of gtk-radio_button.ads; it explains how to
> retrieve the group from the first radio button and then assign all other
> buttons to that group. See Get_Group, Set_Group.

I know of no reason why the client of a GUI library would ever create a single,
independent radio button. A single radio button is useless. One always wants to
create a set of linked buttuns. A GUI library that makes the client do extra
work to achieve this is poorly designed.

--
Jeff Carter
"No one is to stone anyone until I blow this whistle,
do you understand? Even--and I want to make this
absolutely clear--even if they do say, 'Jehovah.'"
Monty Python's Life of Brian
74


Jeffrey R.Carter

unread,
Oct 16, 2022, 4:12:24 PM10/16/22
to
On 2022-10-16 18:43, ldries46 wrote:
>
> But the dialog looks good with the exception that both buttons are activated and
> cannot be deactivated. I still do want the choice between the two I cannot find
> that in the When running in debugging mode I can see that the group still is null

A set of 2 radio buttons is usually equivalent to a check box, which is visually
simpler as well.

Ludovic Brenta

unread,
Oct 16, 2022, 6:14:32 PM10/16/22
to
"Jeffrey R.Carter" <spam.jrc...@spam.acm.org.not> writes:
> On 2022-10-15 17:58, Ludovic Brenta wrote:
>> Read the comments at the top of gtk-radio_button.ads; it explains how to
>> retrieve the group from the first radio button and then assign all other
>> buttons to that group. See Get_Group, Set_Group.
>
> I know of no reason why the client of a GUI library would ever create
> a single, independent radio button. A single radio button is useless.
> One always wants to create a set of linked buttuns.

Yes but you create the radio buttons one at a time, so one of the
buttons must be the first you create.

> A GUI library that makes the client do extra work to achieve this is
> poorly designed.

Agreed but since you've read the documentation by now, you know about
Gtk_Radio_Button_New_With_Label_From_Widget.

--
Ludovic Brenta.

ldries46

unread,
Oct 17, 2022, 2:56:14 AM10/17/22
to
Op 16-10-2022 om 22:12 schreef Jeffrey R.Carter:
> On 2022-10-16 18:43, ldries46 wrote:
>>
>> But the dialog looks good with the exception that both buttons are
>> activated and cannot be deactivated. I still do want the choice
>> between the two I cannot find that in the When running in debugging
>> mode I can see that the group still is null
>
> A set of 2 radio buttons is usually equivalent to a check box, which
> is visually simpler as well.
>
Building a program is sometimes a step by step process. It may be
possible that I need a third or even a fourth possibility in the choice,
so in my opinion it is good to anticipate

ldries46

unread,
Oct 17, 2022, 3:27:15 AM10/17/22
to
Op 17-10-2022 om 0:14 schreef Ludovic Brenta:
Finally I had the correct view and working of my dialogue.
But the very first remark I made stays true for someone trying to use
Gtk is stays a problem without good example code.
Examples are almost always a better way to learn something while the
description in the ads files are always technically correct descriptions
of the function and not how the function interacts with all other functions.

Jeffrey R.Carter

unread,
Oct 17, 2022, 4:18:16 AM10/17/22
to
On 2022-10-17 00:14, Ludovic Brenta wrote:
> "Jeffrey R.Carter" <spam.jrc...@spam.acm.org.not> writes:
>>
>> I know of no reason why the client of a GUI library would ever create
>> a single, independent radio button. A single radio button is useless.
>> One always wants to create a set of linked buttons.
>
> Yes but you create the radio buttons one at a time, so one of the
> buttons must be the first you create.

This may be necessary at a low level in the GUI, but there's no reason why the
client-interface pkg of a library can't provide a higher-level interface.
Consider the equivalent from Ada GUI
(https://github.com/jrcarter/Ada_GUI/blob/master/ada_gui.ads):

type Text_List is array (Positive range <>) of
Ada.Strings.Unbounded.Unbounded_String
with
Dynamic_Predicate => Text_List'First = 1;

type Orientation_ID is (Horizontal, Vertical);

function New_Radio_Buttons (Row : Positive := 1;
Column : Positive := 1;
Label : Text_List;
Break_Before : Boolean := False;
Orientation : Orientation_ID := Vertical)
return Widget_ID with Pre => Set_Up and Label'Length > 1;
-- Creates Label'Length radio buttons; Label contains the labels for the
-- buttons
-- Orientation = Horizontal results in a row of buttons
-- = Vertical has each button after the 1st below the preceding
buttons
-- The button for Label'First will be active
-- The operations Set_Active and Active for radio buttons take an Index;
-- Index will refer to the button for Label (Index)

An implementation based on, say, GTK, will have to create the buttons
individually as the GUI requires, but the client doesn't have to deal with that.

--
Jeff Carter
"The men get one hot meal a day: a bowl of steam."
Take the Money and Run
145


Ludovic Brenta

unread,
Oct 17, 2022, 7:17:10 AM10/17/22
to
That's what I assumed. Have you considered a Gtk_Combo_Box as an alternative?

--
Ludovic Brenta.
The attackers re-invent our correlations. As a result, co-innovations swiftly revolutionise our projections.

Ludovic Brenta

unread,
Oct 17, 2022, 7:18:13 AM10/17/22
to
ldries46 <bertus...@planet.nl> writes:
> Finally I had the correct view and working of my dialogue.
> But the very first remark I made stays true for someone trying to use
> Gtk is stays a problem without good example code.

There is example code in the doc but written in C; trivial to translate
to Ada.

https://docs.gtk.org/gtk3/class.RadioButton.html

--
Ludovic Brenta.
Going forward, a leadership effectiveness strengthens the enablers.

Ludovic Brenta

unread,
Oct 17, 2022, 7:23:01 AM10/17/22
to
ldries46 <bertus...@planet.nl> writes:
> Finally I had the correct view and working of my dialogue.
> But the very first remark I made stays true for someone trying to use
> Gtk is stays a problem without good example code.

Also, GtkAda comes with a complete example code called testgtk, which
shows how to use every type of widget. In the case of radio buttons,
look at the file create_radio_buttons.adb. On Debian and derivatives,
this is installed as part of package libgtkada-doc, as
/usr/share/doc/libgtkada-doc/examples/testgtk.tgz.

--
Ludovic Brenta.
The Chief Risk Appetite Officer reaches out our systems.
0 new messages