Script refreshes a table in a notebook

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
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

Script refreshes a table in a notebook

#1 Post by don570 »

I wrote this example to learn how to refresh a table widget that
is located inside a notebook. A list widget sends the signal.

The table gets its data from the following line...

Code: Select all

<input file>/tmp/population/default</input>

The key is to understand the following lines in the script...

Code: Select all

				
				<action>cp -f /tmp/population/"$LIST" /tmp/population/default</action>
				<action>clear:TABLE</action>	
				<action>refresh:TABLE</action>	
				<action>refresh:ENTRY</action>		   
		
The first action directive will make the change in the default file
which has the population data for the province.

The second action directive allows the rebuilding of the table,
since I found that a simple refresh wasn't enough. (Remove this line
and observe that the population data is steadily added to bottom)

<action>refresh:TABLE</action> --> sends refresh signal to the table widget.

<action>refresh:ENTRY</action> ---> sends refresh signal to entry widget


Image

________________________________________________
Attachments
population.sh.gz
remove fake gz extension
(3.9 KiB) Downloaded 199 times

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#2 Post by don570 »

I've continued to work on this example . I added the province populations
together and calculated the total.

I do this at beginning of script. I experimented with an array.

I made the array with command substitution which is very powerful.

Code: Select all

YEAR=( `function_total`)


where function_total simply prints the individual province populations
to the screen

I removed the comma in the number with

Code: Select all

YEAR_mod=${YEAR[$PROVINCE]//,/} # remove comma from population
Image
Attachments
population2.sh.gz
remove fake gz extension
(3.87 KiB) Downloaded 191 times
Last edited by don570 on Sat 08 Feb 2014, 21:11, edited 1 time in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#3 Post by don570 »

I corrected the script 'population2.sh' to show Canada's population correctly.

I didn't make the loop correctly to change PROVINCE.
Therefore I was adding Alberta's population 10 times to find Canada's population. :oops:

I just needed to change a line to ...

Code: Select all

YEAR_mod=${YEAR[$PROVINCE]//,/} # remove comma from population 
__________________________________________________

Post Reply