Only one of checkmark "A" and "B" is allowed to being checked?

124 views
Skip to first unread message

no....@party.ms

unread,
Aug 22, 2021, 6:34:17 PM8/22/21
to yad-common
In a form, two checkmarks (--field="...":CHK) exclude each other, logically. When "Feature A" becomes selected (TRUE) "Feature B" must become unchecked (FALSE) and vice versa:

Minimal example:
yad --form --field="Feature A":CHK TRUE --field="Feature B":CHK FALSE

So, how to uncheck "Feature B" when "Feature A" is check-clicked? What code can achieve this sort of switch?

TIA,
too

Johnny Rosenberg

unread,
Aug 22, 2021, 7:10:46 PM8/22/21
to yad-c...@googlegroups.com
I think really old versions of Yad had Radiobuttons, which work like that, but they were removed. I needed them, but I found that a Combo Box (CB) does exactly the same job: You have a couple of items and you can select one of them. Yad then returns the item you selected, so that is easy to handle too.


Kind regards

Johnny Rosenberg
 

TIA,
too

--
You received this message because you are subscribed to the Google Groups "yad-common" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/yad-common/7a4255f8-40c2-4c7f-ac0e-2820651ec098n%40googlegroups.com.

no....@party.ms

unread,
Aug 22, 2021, 7:51:03 PM8/22/21
to yad-common
I know and I use the :CB to select one out of mutiple options. In this case I actually want to achieve something different:

Two groups of settings (:CB, text entry, :FL) may be set but only one group of settings can be applied. To avoid errors or a mix mes of all these, I have one checkbox ("A") near the "A" group of user settings / selections and the "B" checkbox near the "B" group of settings / selections.

Both groups of settings can be configured at will (and don't reset) but only one of these groups can be applied at any given time. I prefer to have the intuitive checkbox "Take these settings!" (and uncheck the other, like a switch).

In addition, I actually use a 4 TAB notebook and the next step would be to check/uncheck a parameter group on TAB1 which than must toggle a different / dependent / independent settings group on TAB2, TAB3 and/or TAB4.

There are defaults, spread over the TABs and when selecting set "A" on TAB1 different settings on other TABs depend on them and thus should be "switched on / off" respectively. The logical challenge is to only being able to select meaningful setting groups ("parameters") together and don't get contradicting ones mixed in.

Johnny Rosenberg

unread,
Aug 22, 2021, 8:19:30 PM8/22/21
to yad-c...@googlegroups.com
Den mån 23 aug. 2021 kl 01:51 skrev no....@party.ms <no....@party.ms>:
I know and I use the :CB to select one out of mutiple options. In this case I actually want to achieve something different:

Two groups of settings (:CB, text entry, :FL) may be set but only one group of settings can be applied. To avoid errors or a mix mes of all these, I have one checkbox ("A") near the "A" group of user settings / selections and the "B" checkbox near the "B" group of settings / selections.

Both groups of settings can be configured at will (and don't reset) but only one of these groups can be applied at any given time. I prefer to have the intuitive checkbox "Take these settings!" (and uncheck the other, like a switch).

In addition, I actually use a 4 TAB notebook and the next step would be to check/uncheck a parameter group on TAB1 which than must toggle a different / dependent / independent settings group on TAB2, TAB3 and/or TAB4.

There are defaults, spread over the TABs and when selecting set "A" on TAB1 different settings on other TABs depend on them and thus should be "switched on / off" respectively. The logical challenge is to only being able to select meaningful setting groups ("parameters") together and don't get contradicting ones mixed in.

I don't run the latest version of Yad so I don't know if this can be done. Are you really sure that Yad is the best tool for the job?



Kind regards

Johnny Rosenberg
 

gurus....@gmail.com schrieb am Montag, 23. August 2021 um 01:10:46 UTC+2:
Den mån 23 aug. 2021 kl 00:34 skrev no....@party.ms <no....@party.ms>:
In a form, two checkmarks (--field="...":CHK) exclude each other, logically. When "Feature A" becomes selected (TRUE) "Feature B" must become unchecked (FALSE) and vice versa:

Minimal example:
yad --form --field="Feature A":CHK TRUE --field="Feature B":CHK FALSE

So, how to uncheck "Feature B" when "Feature A" is check-clicked? What code can achieve this sort of switch?

I think really old versions of Yad had Radiobuttons, which work like that, but they were removed. I needed them, but I found that a Combo Box (CB) does exactly the same job: You have a couple of items and you can select one of them. Yad then returns the item you selected, so that is easy to handle too.


Kind regards

Johnny Rosenberg
 

TIA,
too

--
You received this message because you are subscribed to the Google Groups "yad-common" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/yad-common/7a4255f8-40c2-4c7f-ac0e-2820651ec098n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "yad-common" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.

Милош Павловић

unread,
Aug 23, 2021, 2:26:16 AM8/23/21
to yad-common
Maybe it's possible with dialogbox, an alternative to yad written with Qt libs.
I was told there is dialogbox packaged for Debian Buster in Antix Linux repositories.

Johnny Rosenberg

unread,
Aug 23, 2021, 10:22:25 AM8/23/21
to yad-c...@googlegroups.com
Den mån 23 aug. 2021 kl 08:26 skrev Милош Павловић <mpsr...@gmail.com>:
Maybe it's possible with dialogbox, an alternative to yad written with Qt libs.

Python with TkInter seems to be something people use as well.



Kind regards

Johnny Rosenberg
 

Милош Павловић

unread,
Aug 23, 2021, 11:28:35 AM8/23/21
to yad-common
I think he was asking for bash dialogbox
but sure python3-tk library
  1. #!/usr/bin/env python3
  2. from tkinter import *
  3. def sel():
  4. selection = "You selected the option " + str(var.get())
  5. print(selection)
  6. label.config(text = selection)
  7. window = Tk()
  8. window.title('Tkinter')
  9. window.geometry('300x80')
  10. var = IntVar()
  11. R1 = Radiobutton(window, text="Feature A", variable=var, value=1,
  12. command=sel)
  13. R1.pack( anchor = W )
  14. R2 = Radiobutton(window, text="Feature B", variable=var, value=2,
  15. command=sel)
  16. R2.pack( anchor = W )
  17. label = Label(window)
  18. label.pack()
  19. R1.invoke()
  20. window.mainloop()
tkinter.gif
But one can as well use gtk+ library if familiar with python

Johnny Rosenberg

unread,
Aug 31, 2021, 3:41:12 PM8/31/21
to yad-c...@googlegroups.com
Den mån 23 aug. 2021 kl 17:28 skrev Милош Павловић <mpsr...@gmail.com>:
I think he was asking for bash dialogbox

Yes, but sometimes things can't be done easily in the current environment, and then it COULD be time to consider a different one… Or a mix. You could make a python script for the dialogue only and do the rest in Bash. :)


 
but sure python3-tk library
  1. #!/usr/bin/env python3
  2. from tkinter import *
  3. def sel():
  4. selection = "You selected the option " + str(var.get())
  5. print(selection)
  6. label.config(text = selection)
  7. window = Tk()
  8. window.title('Tkinter')
  9. window.geometry('300x80')
  10. var = IntVar()
  11. R1 = Radiobutton(window, text="Feature A", variable=var, value=1,
  12. command=sel)
  13. R1.pack( anchor = W )
  14. R2 = Radiobutton(window, text="Feature B", variable=var, value=2,
  15. command=sel)
  16. R2.pack( anchor = W )
  17. label = Label(window)
  18. label.pack()
  19. R1.invoke()
  20. window.mainloop()
tkinter.gif
But one can as well use gtk+ library if familiar with python

Nice! I'm not great with Python myself, only done some simple scripts within AutoKey.


Kind regards

Johnny Rosenberg
 

Милош Павловић

unread,
Aug 31, 2021, 8:56:23 PM8/31/21
to yad-common
Tkinter is the easiest but making it look professional is not easy.

You would want your dialog to follow the yad/gtk+ theming.
There are some extensions for theming but they do not perfectly match gtk themes.

With C and gtk much can be done.
johnny.gif
Dizzy from all that rolling... time to listen Rawhide: https://www.youtube.com/watch?v=p6jQj6rGqnE
Reply all
Reply to author
Forward
0 new messages