Several progress bars inside a single window 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
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

Several progress bars inside a single window script [SOLVED]

#1 Post by Argolance »

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, 09:45, edited 1 time in total.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

Re: Multiple progress bars inside a single window script?

#2 Post by akash_rawal »

This can be easily done using pipes. Example:

Code: Select all

#!/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

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#3 Post by Argolance »

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.

Post Reply