[pygtk] "Rolling Up" Calculations in Treeview

Andrew Rowland weibullguy at gmail.com
Fri Nov 11 18:59:14 WST 2011


I have a group of information that is related in a hierarchical 
structure.  I display the structure in a treeview.  I am trying to roll 
up various calculations where, the sum of the lower levels becomes the 
unit value of the next higher level.  Below is, hopefully, a helpful 
example of how the calculations should roll up.

Description                        Quantity    Unit Cost    Total Cost
System                                      1             21.42          
21.42
     Subsystem 1                        1              12.45          12.45
         Assembly 1                      2                4.85    
         9.70
             Part 1                            1                0.10    
         0.10
             Part 2                            2                1.00    
         2.00
             Part 3                            5                0.55    
         2.75
         Assembly 2                      1                
1.70            1.70
             Part 4                            2                
0.55            1.10
             Part 5                            3                
0.20            0.60
     Subsystem 2                        1                8.97            
8.97
         Assembly 3                      1                
8.97            8.97
             Subassembly 1            1                8.97            8.97
                 Part 6                        1                
2.98           2.98
                 Part 7                        1                
5.99           5.99

Clearly, things need to be calculated in the correct order starting with 
Part and working up to System.  I am struggling with a good way to 
"walk" up the tree making all the calculations at one level before 
continuing to the next higher level.  I'm sure it's not as difficult as 
I've convinced myself it is.

Thanks in advance for any helpful pointers.

Andrew

-- 
Andrew Rowland, CRE
Reliability Consultant
<darowland AT ieee.org>
https://sourceforge.net/projects/reliafree/
http://www.linkedin.com/pub/andrew-rowland/6/800/10a



More information about the pygtk mailing list