How do I add 3 buttons on my script SOLVED

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

How do I add 3 buttons on my script SOLVED

#1 Post by oldyeller »

Hello Everyone,

I am trying to get three buttons on my remove delete script so people will have a choice to 1 remove 2 delete 3 cancel. I am using Xdialog for this.

This here is just for two buttons with this setup you can only do one or the other.

Just am not sure just how to do this, any help would be great thanks

Code: Select all

#!/bin/sh

export RESOURCES="/usr/local/Manna/resources"
export REMOVE_DIR="/usr/local/Manna/removed"

if  [ -d /usr/local/Manna/resources/Apocrypha/001tobittxt ]; then
 Xdialog --title "Remove" --cancel-label "Remove from computor" --ok-label "Remove from Menu"  --yesno "\n Remove Tobit \n" 0 0 
 if [[ $? == 0 ]]; then
  mv $RESOURCES/Apocrypha/001tobittxt $REMOVE_DIR/ 
 fi
if [[ $? == 0 ]]; then
 rm -r $RESOURCES/Apocrypha/001tobittxt
 fi
 fi
exit 0
;;
Last edited by oldyeller on Sat 10 Aug 2013, 01:15, edited 1 time in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2 Post by sunburnt »

Xdialog is pre-made dialogs, changing them ain`t easy.

xmessage can have any number of only buttons
Type in a VT for help: xmessage --help

Run rxvt or xterm and type in this line:

Code: Select all

xmessage "xMessage Test" -buttons "# 1:1,# 2:2,# 3:3" ; echo $?

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#3 Post by Karl Godt »

xmessage is one of my favorites - it's kinda ugly gui though .

Don't know if in recent Pups xmessage still works since it is linked to pup?dialog .

If there are many buttons, xmessage might hide the buttons in the right offscreen .

One simple thing is to hit the close button in the title bar - Returnvalue might be -1, 254 or 255 .

Also to provide a second gui "Are You REALLY SURE to delete $VAR" YES/No might be not a bad idea .

urxvt -e dialog --extra-button might be a crude and ugly workaround .

The old shutdown dialogs used them in shutdownconfig/rc.shutdown . Now it is yaf I think . Yaf-splash might provide a third button , too .

I would look into the newish shutdownconfig script for examples .

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

I agree, xmessage => gxmessage is ugly.

Puppy use to have xmessage and it looked much better.!

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#5 Post by oldyeller »

Hi All,

@sunburnt I did look at xmessage not what I would use for this though-I am somewhat in favor of Xdailog more.

@Karl Godt I did look at rc.shutdown in lupu 528 and I did notice that it uses an --extra-button and --extra-label. Could not get this to work for me, lack of knowledge on my part.

This is what I decided to do. I added a safty net sort of speaking by adding another gui asking if they really want to Delete from computer. I was thinking on this when I saw your post about adding this also.

Thanks to the both of you for your ideas and showing me about xmessage maybe will use for something else. But I still prefer Xdailog just because I know more about it.

Thanks again.

Code: Select all

#!/bin/sh

export RESOURCES="/usr/local/Manna/resources"
export REMOVE_DIR="/usr/local/Manna/removed"

if  [ -d /usr/local/Manna/resources/Apocrypha/001tobittxt ]; then
 Xdialog --title "Remove" --cancel-label "Remove from computor" --ok-label "Remove from Menu" --yesno "\n Remove Tobit from Menu or Delete from Computer this is permanent!! \n" 0 0 
 if [[ $? == 0 ]]; then
  mv $RESOURCES/Apocrypha/001tobittxt $REMOVE_DIR/ 
 fi
 Xdialog --title "Delete" --cancel-label "Cancel" --ok-label "Remove from Computer" --yesno "\n Are you sure you want to Delete from Computer? This is permanent!! \n" 0 0 
 if [[ $? == 0 ]]; then
  rm -r $RESOURCES/Apocrypha/001tobittxt 
 fi
fi
exit 0
;;

Post Reply