LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-17-2008, 02:10 PM   #1
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 225

Rep: Reputation: 30
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?
 
Old 01-17-2008, 02:57 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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.
 
Old 01-17-2008, 03:58 PM   #3
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 225

Original Poster
Rep: Reputation: 30
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?
 
Old 01-17-2008, 09:31 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Quote:
Originally Posted by snowman81 View Post
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.
 
Old 01-18-2008, 01:41 PM   #5
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 225

Original Poster
Rep: Reputation: 30
Ok, that makes sense. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
radio button: how to detect which was last checked in a multi group of buttons rblampain Programming 2 09-11-2007 08:42 AM
Firefox radio buttons look absolutely hideous. Maritime Linux - Newbie 1 05-23-2006 02:40 AM
making all mouse buttons work in slackware 10.1 TruANTOlogy Slackware 13 02-11-2005 06:35 AM
making active windows appear as buttons in the 'taskbar' in fluxbox scuzzman Linux - Newbie 4 06-23-2004 11:46 PM
Java menus (radio buttons) and panels titanium_geek Programming 6 01-07-2004 11:13 AM


All times are GMT -5. The time now is 07:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration