LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Making radio buttons work with Zenity (https://www.linuxquestions.org/questions/programming-9/making-radio-buttons-work-with-zenity-614328/)

snowman81 01-17-2008 02:10 PM

Making radio buttons work with Zenity
 
I have a Zenity script that shows an acceptable use policy for a school I work at which looks like this
Code:

zenity --title "Acceptable Use Policy" --text "All users of this machine must acknowledge and abide by \n all rules and regulations set by the acceptable use policy \n of the schools. This policy can be viewed on the front \n of the door of this computer lab" --list --radiolist --column "Choice" --column "Answer" True Accept False Deny
What I want is if they hit "accept" it will just go away and if they hit deny, it reboots the computer. Any idea of how to do this?

pixellany 01-17-2008 02:57 PM

You need to look at the syntax for what Zenity returns for different options. There are a minimum of two things: The returned value, and the exit status.

I have a simple script that uses the --entry option. The value returned is the string entered in the box. The exit status is determined by whether the user clicks "OK" or "cancel". I assume the behavior is similar when using radio buttons.

To look at exit status, look at "$?" This is the bash variable which contains the exit status of the last command executed.

snowman81 01-17-2008 03:58 PM

So for example, if hitting the "accept" button returns an exit status of 0, I could use the 0 later in the script like in an if statement?

pixellany 01-17-2008 09:31 PM

Quote:

Originally Posted by snowman81 (Post 3026278)
So for example, if hitting the "accept" button returns an exit status of 0, I could use the 0 later in the script like in an if statement?

Assign $? to a variable, and then you can use it later. Remember that $? is the exit status of the last command executed.

snowman81 01-18-2008 01:41 PM

Ok, that makes sense. Thanks.

dplusplus 08-24-2015 05:33 PM

I just stumbled across this thread while trying to accomplish a similar task. Zenity has a text "information dialog box" option. You can store the message for your users in a separate file and give them the option of either checking the box and confirming or aborting. It seems that would be the better choice in this situation.

Habitual 08-25-2015 12:20 PM

http://linux.byexamples.com/archives...og-examples-2/


All times are GMT -5. The time now is 04:15 PM.