ETO Tree Grid form in Python

Hi I need a Full example for Tree Grid for Iron.python as mine will not run in Rhino 8 Python 3 which is what I need. In fact I struggle to get any ETO forms running in Python 3 so I must be doing something fundamentally wrong, that is why I could do with a FULL example of getting an ETO form to run in Python 3 so any eto control would probably do.
If McNeel could add some full examples it would be a great help as the ones on GitHub don’t seem to work either.

Hi @RogerD ,

Under your class declaration(s) add super like this:

class MyClass():
    def __init__(self):
        super(self).__init__

Or

class MyClass():
    def __init__():
        super().__init__

Additionally I would add:

#! python3

At the top of your file.

If executing .py generically it will run it as Py3 this way.

You can also save as Py3 if I recall correctly.

I believe they are working on updated Eto documentation. No idea on the timeframe on that but that’s what I read on the forums somewhere.

1 Like

Thanks I think I will need the new documentation as well total newbie here with ETO and it is not clear in Python3

1 Like

This has the new rhino 8 python 3 sample with updated init code: https://developer.rhino3d.com/guides/rhinopython/eto-forms-python/

It should work copy and paste.

2 Likes

I can test the grid view on Monday. Rhino - Eto Controls in Python

2 Likes

Hi Scott any help you can give will be appreciated.

Roger

Hi Scott did you get a chance to look at this ?

Working on it. That control specifically changed a lot from the examples, so we are re-writing it.

Hi Scott glad it was not just me then.

Roger

Hi Scott any idea when the new code for the ETO GridView will be available ?

Roger

Sorry for the delay, here is the code. Essentially it needs to be a list and not a datastore. It does have to do with Python 3 and casting to .NET datatypes.

#! python3
from System.Collections.Generic import List
from Rhino.UI import RhinoEtoApp
import Eto.Forms as forms


class Test(forms.Form):
    def __init__(self):
        super().__init__()
        self.Owner = RhinoEtoApp.MainWindowForOwner
        self.m_gridview = forms.GridView()
        self.m_gridview.ShowHeader = True
        # self.m_gridview.DataStore = (
        #     forms.GridItem(['first pick', 'second pick', 'third pick', True]),
        #     forms.GridItem(['second','fourth','last', False])
        # )

        self.m_gridview.DataStore = (
            List[object](["first pick", "second pick", "third pick", True]),
            List[object](["second", "fourth", "last", False]),
        )

        column1 = forms.GridColumn()
        column1.HeaderText = "Column 1"
        column1.Editable = True
        column1.DataCell = forms.TextBoxCell(0)
        self.m_gridview.Columns.Add(column1)

        column2 = forms.GridColumn()
        column2.HeaderText = "Column 2"
        column2.Editable = True
        column2.DataCell = forms.TextBoxCell(1)
        self.m_gridview.Columns.Add(column2)

        column3 = forms.GridColumn()
        column3.HeaderText = "Column 3"
        column3.Editable = True
        column3.DataCell = forms.TextBoxCell(2)
        self.m_gridview.Columns.Add(column3)

        column4 = forms.GridColumn()
        column4.HeaderText = "Column 4"
        column4.Editable = True
        column4.DataCell = forms.CheckBoxCell(3)
        self.m_gridview.Columns.Add(column4)

        self.Content = self.m_gridview


t = Test()
t.Show()

I will update the example online also.

1 Like

Thanks Scott a great help.

Roger