Eto GridView not showing values

Hello!

I am trying to crate a small window with an Eto GridView in python. The code compiles and the three rows that i am trying to show show up but there the values does not show.

I tried in a lot of different ways (also by creatig a custom class) but it does not work. It always only shows up blank lines. Also when printing grid_view.DataStore is an empty list .

I am on a mac intel

Thank’s in advance

Cheers

Eric

            self.form = forms.Form()
            self.form.Resizable = True
            self.form.Width = 200
            self.form.Height = 400

            # create grid view and columns
            self.grid_view = forms.GridView()
            self.grid_view.DataStore = (['one', 'two'],
                                        ['a', 'b'],
                                        ['alpha', 'beta'])
            
            print(self.grid_view.DataStore) 
        
            self.columnA = forms.GridColumn()
            self.columnA.HeaderText = "A"
            self.columnA.Editable = False
            self.columnA.DataCell = forms.TextBoxCell(0)
            self.grid_view.Columns.Add(self.columnA)

            self.columnB = forms.GridColumn()
            self.columnB.HeaderText = "B"
            self.columnB.DataCell = forms.TextBoxCell(1)
            self.grid_view.Columns.Add(self.columnB)
            

            self.form.Content = self.grid_view
            self.form.Show()

Hi @Eric_Norman_Gozzi

import Rhino
import Eto.Forms as forms
import Eto.Drawing as drawing

class GridItem(object):
    def __init__(self, col_a, col_b):
        self.ColumnA = col_a
        self.ColumnB = col_b

form = forms.Form()
form.Title = "Grid View Example"
form.Resizable = True
form.Width = 300
form.Height = 400

grid_view = forms.GridView()

columnA = forms.GridColumn()
columnA.HeaderText = "A"
columnA.Editable = False
columnA.DataCell = forms.TextBoxCell("ColumnA")
grid_view.Columns.Add(columnA)

columnB = forms.GridColumn()
columnB.HeaderText = "B"
columnB.Editable = False
columnB.DataCell = forms.TextBoxCell("ColumnB")
grid_view.Columns.Add(columnB)


data = [
    GridItem('40', 'Apples'),
    GridItem('30', 'Bananas'),
]

grid_view.DataStore = data


form.Content = grid_view


form.Show()

There were a bunch of mistakes, hope this clarifies your doubts,
Farouk

@farouk.serragedine thank’s a lot for the answer. Your solution works but I have the same issue: the form, the grid view and the rows they all appear, but not the values inside the single rows. The table is just empty. I think there is a problem with the DataStore attribute of the GridView, it somehow fails to collect the data.

Thank’s a lot for the help anyway.
This is my output

@Eric_Norman_Gozzi this seems an issue with Python3 rather than a mac issue

If you save your code as python2 you will find it works.

RH-89785 Gridview doesn’t work correctly in Python3

Not asking you to predict the future, but how long do these fixes usually take?

Using Python 2 isn’t a viable option.

Thanks

Anywhere between 1 day and 10 years.

But joking aside, I suspect this can be fixed fairly quickly.

Thank’s a lot for the answer. :smiley:

Not sure about fairly quickly, since the release target is set to 9.0,

But in the meantime I found

Hey @Eric_Norman_Gozzi,

I’ve written about Eto Cells and touched on Grid Views here → Rhino - Cells, you’ll be able to see how to make a GridView work in python.

@CallumSykes Thank’s a lot!

It is exactly what I needed :smiley: