Posted: 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!
Joined: 25 Aug 2010 Posts: 215 Location: Pune, Maharashtra, India
Posted: 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
_________________ If there's an open source project in your hand,
Don't aim for popularity, it's out of your hand.
Aim for perfection, as that's the best thing you can.
Rules_post_cannot Rules_reply_cannot Rules_edit_cannot Rules_delete_cannot Rules_vote_cannot You cannot attach files in this forum You can download files in this forum