Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 25 Jun 2017, 22:11
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Xdialog Combobox problem select
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
arivas_2005

Joined: 25 Feb 2007
Posts: 167

PostPosted: Mon 27 Feb 2017, 22:27    Post subject:  Xdialog Combobox problem select  

regards
In the following script everything is selected
I need to capture a name from the list
Code:
#!/bin/bash
procArray=$(cat listado.txt )
RESULT=$(Xdialog --title "process list"  --stdout  --combobox "Please choose " 10 55 "$procArray[@]")
Xdialog --msgbox ""$RESULT"" 0 0

I want to use combobox or menubox to choose
Attached files of the problem
Thanks for the help
Xdia-Combo-or-menubox.tar.gz
Description 
gz

 Download 
Filename  Xdia-Combo-or-menubox.tar.gz 
Filesize  450 Bytes 
Downloaded  19 Time(s) 
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1276
Location: Japan

PostPosted: Tue 28 Feb 2017, 01:01    Post subject:  

A couple of problems in the script. procArray is not an array and quotations are wrong.

#!/bin/bash
procArray=$(cat listado.txt )
RESULT=$(Xdialog --title "process list" --stdout --combobox "Please choose " 10 55 "$procArray[@]")
Xdialog --msgbox ""$RESULT"" 0 0

Then your listado.txt:
Code:
Arana Rivera, Keily Noelia
Avalos Morán, Ester Elizabeth
Beltrán Santosw, Fátima Guadalupe
Campos Avalos, Angela Andrea
Cardona Delgado, Mayra Yanira
Córdova García, Karla Michelle
Not very suitable as a source list and on top it includes MS Windows style CRLF line endings.
It would be easier if you could use a better list, e.g. either comma separated (without additional spaces!) or new line separated, but not both mixed.

If you really have to use your current list you can try
Code:
#!/bin/bash
procArray=$(cat listado.txt)
procArray=${procArray//$'\r'}      # Change CRLF endings to LF
procArray=${procArray//, /$'\n'}   # Change ', ' (comma space) name sparators to new line separators
IFS=$'\n'
RESULT=$(Xdialog --title "process list"  --stdout --combobox "Please choose " 10 55 $procArray)
Xdialog --msgbox "$RESULT" 0 0
Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 167

PostPosted: Fri 03 Mar 2017, 23:52    Post subject:  

Hello MochiMoppel
thanks for your support
it's great

The combobox I stay like this (Work well Very Happy )
Code:
#!/bin/bash

nomarchivo=$1  # ruta completa del archivo clicqueado
ruta=`echo ${nomarchivo%"/"*}`
soloarchivo=`echo ${nomarchivo##*"/"}`
cd $ruta
sleep 0.1
procArray=$(cat -n "$ruta"/listado.txt |sed -e 's/,//g' | sed 's/^ *//g'  | sed 's/ *$//')
procArray=${procArray//$'\r'}      # Change CRLF endings to LF
#procArray=${procArray//, /$'\n'}   # Change ', ' (comma space) name sparators to new line separators
IFS=$'\n'
RESULT=$(Xdialog --title "process list"  --stdout --combobox "$soloarchivo" 10 80 $procArray)
#retval=$?


Again thank you for your cooperation
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1276
Location: Japan

PostPosted: Tue 07 Mar 2017, 11:19    Post subject:  

You're welcome. I'm glad to see that you edited your post and dropped your idea to use a menubox with numbers and names. This would return a number, not a name ...probably not what you are looking for.

So only for the record and for your entertainment here is your example, this time using a menubox:
Code:
#!/bin/bash
procArray=$(cat listado.txt)
procArray=${procArray//$'\r'}               # Change CRLF endings to LF
procArray=${procArray//, /$'\n'}            # Change ', ' (comma space) name sparators to new line separators
procArray=$(echo "$procArray" | sed =)      # Precede each name line with additional line, containing running number
IFS=$'\n'                                   # Make sure that Xdialog reads first line as tag, then next line as item , then next line as next tag etc.
RESULT=$(Xdialog --title "process list"  --stdout  --menubox "Please choose " 10 55 0 $procArray)
Xdialog --msgbox "$RESULT" 0 0
menubox.png
 Description   
 Filesize   61.13 KB
 Viewed   160 Time(s)

menubox.png

Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 167

PostPosted: Tue 07 Mar 2017, 22:08    Post subject:  

Hello MochiMoppel

This is my code that does not work, ... Based on trial and error
Quote:
#!/bin/bash
cat listado.txt | sed -e 's/,//g' | sed 's/^ *//g' | sed 's/ *$//' | sed 's/^/"/' | sed 's/$/"/' > listado1.txt
cat -n listado1.txt > listado2.txt
#procArray=$(cat listado.txt | sed -e 's/,//g' | sed 's/^ *//g' | sed 's/ *$//' | sed 's/^/"/' | sed 's/$/"/' | sed 'N;s/\n/\t/' )
procArray=($(cat listado2.txt))
#cat ${procArray[@]} > listado2.txt
Xdialog --title "process list" --menubox "Please choose " 25 40 ${procArray[@]} 2>/temp0


In my code the line
Quote:
cat -n listado1.txt > listado2.txt

Insert the number ( .. Well lost !!)

but
in your code .. Insert the number with
Code:
procArray=$(echo "$procArray" | sed =)      # Precede each name line with additional line, containing running number

And how would I think that Embarassed
Quote:
... for your entertainment here is your example

I tell you that I have been given 35 sections of 40 students to rename photos

Photographer gives name photos of this form
0190_1_A_General_ABREGO_GARCIA_JONATHAN_DAVID.jpg
At school they need them so
Abrego García, Jonathan David.jpg
The student list has already been typed
-------->
Your example is very important to me. (I will reduce many mouse clicks compared to the combobox)
so wath... with the number is very sufficient.... great contribution
I'll find the complement
That's a big help for me
great!! Very Happy Very Happy
MochiMoppel - Infinite thanks !
Back to top
View user's profile Send private message 
tenochslb

Joined: 10 Jul 2010
Posts: 62
Location: Mexico

PostPosted: Thu 09 Mar 2017, 18:19    Post subject:  

FYI: MULTIRENAME is included in puppy tahr

Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 167

PostPosted: Fri 24 Mar 2017, 22:56    Post subject:  

Mini final script using menubox

Code:
#!/bin/bash
nomarchivo=$1
ruta=`echo ${nomarchivo%"/"*}`
soloarchivo=`echo ${nomarchivo##*"/"}`
soloarchivo2=`echo "\n " $soloarchivo "\n"`

cd $ruta
sleep 0.1
procArray=$(cat "$ruta"/listado.txt |sed -e 's/,//g' | sed 's/^ *//g'  | sed 's/ *$//')

## =============== aporte MochiMoppel
#procArray=$(cat listado.txt)
procArray=${procArray//$'\r'}               # Change CRLF endings to LF
procArray=${procArray//, /$'\n'}            # Change ', ' (comma space) name sparators to new line separators
procArray=$(echo "$procArray" | sed =)      # Precede each name line with additional line, containing running number
IFS=$'\n'                                   # Make sure that Xdialog reads first line as tag, then next line as item , then next line as next tag etc.
RESULT=$(Xdialog --title "Lista de nombres"  --stdout  --menubox "$soloarchivo2" 45 70 0 $procArray)
#Xdialog --msgbox "$RESULT" 0 0
## ===============   Thanks!

respu=`echo $?`
if [ $respu -eq 1 ];
then
   exit 0
else
   numlinea=`echo ${RESULT:0:2} | sed 's/^ *//g'  | sed 's/ *$//'`
   lineatexto=`sed -n $numlinea'p' "$ruta"/listado.txt`
   nvonombre2=`echo ${lineatexto//$'\r'} | sed 's/^ *//g' | sed 's/ *$//'`
   nombrefin="$ruta"/"$nvonombre2"".jpg"
   mv -f "$nomarchivo" "$nombrefin"
   sleep 0.1
   sed -i $numlinea'd' "$ruta"/listado.txt
fi

exit 0

completed work Very Happy
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0664s ][ Queries: 15 (0.0061s) ][ GZIP on ]