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 Wed 22 Oct 2014, 21:43
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Several progress bars inside a single window script [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
Argolance


Joined: 06 Jan 2008
Posts: 1835
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Mon 30 Jul 2012, 10:16    Post subject:  Several progress bars inside a single window script [SOLVED]  

Hello,
I would like to know if it is possible and (if yes) how to build a gtkdialog script that shows several progress bars displayed inside a single window but running one after the other. When the first one has terminated to do its job, then the second one starts and so on...
Thank you!

Cordialement.

_________________


Last edited by Argolance on Tue 31 Jul 2012, 05:45; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Mon 30 Jul 2012, 14:29    Post subject: Re: Multiple progress bars inside a single window script?  

This can be easily done using pipes. Example:

Code:

#!/bin/bash

function reader()
{
   #This will be used to read from pipes
   while true; do echo "`< $task_dir/$1`"; done
}
export -f reader

function task()
{
   #Sample task 1
   for i in `seq 20 20 100`; do
      echo "$i" > "$task_dir/pipe_1"
      echo "Doing task 1... ($i %)" > "$task_dir/pipe_1"
      sleep 0.3 #Delay just to simulate a task
   done
   echo "done" > "$task_dir/pipe_1"
   
   #Sample task 2
   for i in `seq 20 20 100`; do
      echo "$i" > "$task_dir/pipe_2"
      echo "Doing task 2... ($i %)" > "$task_dir/pipe_2"
      sleep 0.3 #Delay just to simulate a task
   done
   echo "done" > "$task_dir/pipe_2"
   
   #Sample task 3
   for i in `seq 20 20 100`; do
      echo "$i" > "$task_dir/pipe_3"
      echo "Doing task 3... ($i %)" > "$task_dir/pipe_3"
      sleep 0.3 #Delay just to simulate a task
   done
   echo "done" > "$task_dir/pipe_3"
   
   #After 2s close the window
   sleep 2
   echo "100"
}
export -f task

#Temporary directory
mkdir -p "/tmp/task"
export task_dir="`mktemp -d /tmp/task/XXXXXXXX`"
mkfifo "$task_dir/pipe_1"
mkfifo "$task_dir/pipe_2"
mkfifo "$task_dir/pipe_3"

export dialog="
<window>
   <vbox>
      <progressbar>
         <input>reader pipe_1</input>
      </progressbar>
      <progressbar>
         <input>reader pipe_2</input>
      </progressbar>
      <progressbar>
         <input>reader pipe_3</input>
      </progressbar>
      <progressbar height-request=\"1\">
         <input>task</input>
         <action>exit:OK</action>
      </progressbar>
   </vbox>
</window>
"

gtkdialog3 -p dialog
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1835
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Tue 31 Jul 2012, 05:43    Post subject:  

Hello akash_rawal,
Great: Exactly what I was looking for!
This should be a tip of the very useful Zigbert GtkDialog thread...

Thank you very much!

Cordialement.

_________________

Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 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.0470s ][ Queries: 12 (0.0047s) ][ GZIP on ]