Eto combobox in gridview (Python)

Trying to show a combobox in a gridview:

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

form = forms.Dialog()
form.Title = "test combobox in gridview"
form.ClientSize = drawing.Size(800, 600)
form.Resizable = False

comboMaterialType = forms.ComboBox(DataStore = ['Wood', 'Plastic'], SelectedIndex = 0)

dataStoreRow1 = ['Surface 01: Front_Planes', comboMaterialType]
dataStoreRow2 = ['Surface 02: Front_Edges', comboMaterialType]

gridOption1 = forms.GridView()
gridOption1.ShowHeader = False
gridOption1.DataStore = (dataStoreRow1, dataStoreRow2)
gridOption1.Columns.Add(forms.GridColumn(Editable = False, DataCell = forms.TextBoxCell(0)))
gridOption1.Columns.Add(forms.GridColumn(Editable = True, DataCell = forms.ComboBoxCell(1)))

layout = forms.DynamicLayout(DefaultSpacing = drawing.Size(5, 5), Padding = drawing.Padding(10))
layout.AddRow(gridOption1)

form.Content = layout
form.ShowModal()

The combobox is there but shows empty. You don’t see it immediately because the content is not shown.
When you click the combobox the first time (just behind the text), you have to click it a second time to see it’s a dropdown and a third time to actually see the dropdown list, which still shows empty:

eto_empty_combobox

What am I doing wrong?

PS: it’s a pity the documentation about Eto is so fragmented and in different languages. As I am not aquainted with C++ or C#, I can’t understand the code or translate it to Python …

Hi @dick.lelyveld,

Thanks for the inquiry and apologies for the late response. What you need to do is set the DataStore of the ComboBoxCell instead of using a ComboBox as the value for each cell. Something like this should work:

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

form = forms.Dialog()
form.Title = "test combobox in gridview"
form.ClientSize = drawing.Size(800, 600)
form.Resizable = False

comboMaterialType = forms.ComboBoxCell(1)

comboMaterialType.DataStore = ['Wood', 'Plastic']

dataStoreRow1 = ['Surface 01: Front_Planes', 'Wood']
dataStoreRow2 = ['Surface 02: Front_Edges', 'Plastic']

gridOption1 = forms.GridView()
gridOption1.ShowHeader = False
gridOption1.DataStore = (dataStoreRow1, dataStoreRow2)
gridOption1.Columns.Add(forms.GridColumn(Editable = False, DataCell = forms.TextBoxCell(0)))
gridOption1.Columns.Add(forms.GridColumn(Editable = True, DataCell = comboMaterialType))

layout = forms.DynamicLayout(DefaultSpacing = drawing.Size(5, 5), Padding = drawing.Padding(10))
layout.AddRow(gridOption1)

form.Content = layout
form.ShowModal()

Have you seen the Eto Controls in Python page in Rhino’s documentation? Please take a look and let us know if we are missing anything.

Thanks very much @curtisw!
Now I understand :slight_smile:

About the documentation, I will try to compile a list of items I had problems with to understand. Maybe you can use that to add to the documentation.
At the moment I’m not busy with Rhino Python, but when I do again, I will dedicate some time to it.

Kind regards, Dick