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 Thu 18 Dec 2014, 03:21
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 Posts_count  
Author Message
Argolance


Joined: 06 Jan 2008
Posts: 1851
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.

_________________


Edited_time_total
Back to top
View user's profile Send_private_message Visit_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: 1851
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_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

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


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0489s ][ Queries: 12 (0.0055s) ][ GZIP on ]