TreeGridView in Eto.Forms Grasshopper

Hi,
Does anyone know how to create a TreeGridView in Eto.Forms using a dictionary without manually creating items and adding them ? I’m assuming it must be a recursive function of sorts; I am using Python.

Thank you

@bovasbenjacob yes there would be a way to do that, however It’s hard to create one without knowing what kind of dictionary are you converting from. If you have a sample of the data you want to present in a TreeGridView I can help with a method to convert it over.

@curtisw thank you for the reply and sorry I am late to respond. Let me share my code here. I could not share the original data, but the structure here is almost the same. Also, would you be so kind as to clarify a couple more doubts?

  1. How do I make it so that whenever I check/Uncheck the parent item checkboxes, all the ones under do the same ? Also specify its default state;
  2. How to change the display of the form so that I can interact with Grasshopper as well. I am aware of Eto.Forms.Form; but that gave more problems with event handling .

import Eto, Eto.Forms as ef

data = {“Facade1”: {“Type” : “Kinetic”, “Material” : “Aluminium”, “Size” : “1x1” }, “Facade2” : {“Type” : “Static”, “Material” : “Glass”, “Size” : “1x1”}}

class Eform(Eto.Forms.TreeGridView):
def init(self, sgms):

    self.visibleBG = None
    self.Width = 1000
    self.Height = 500
    
    layout = ef.DynamicLayout()

    def makeTree(self):
        col1 = ef.GridColumn(HeaderText = 'Tree', Editable = False,
                             DataCell = ef.TextBoxCell(0))
        col2 = ef.GridColumn(HeaderText = 'Preview On/Off', Editable = True, 
                            DataCell = ef.CheckBoxCell(1))
        self.Columns.Add(col1)
        self.Columns.Add(col2)
        
        trc = ef.TreeGridItemCollection()
        t = []
        for key, value in data.items():
            if type(value) == dict or type(value) == list:
                item1 = ef.TreeGridItem()
                item1.Values=('Root',)
                t.append(item1)
                sub = ef.TreeGridItem(Values=(key,))
                for i, j in value.items():
                    it = ef.TreeGridItem(Values = (i,))
                    sub.Children.Add(it)
                t[0].Children.Add(sub)
                
            else:
                item1 = ef.TreeGridItem()
                item1.Values=('Root',)
                t.append(item1)
                sub = ef.TreeGridItem(Values=(key,))
                t[0].Children.Add(sub)
                
        trc.Add(t[0]) 
        self.DataStore = trc

    makeTree(self)
    layout.Add(self)
    
    dial = ef.Dialog()
    dial.Content = layout
    dial.ShowModal()

a = Eform(data)

Thank you!