How best to populate eto GridView control from Python dictionaries?

If I have aggregated data in a list of dictionaries, e.g.

[ 
{"name":"Smith", "rank":"Major", "serial":1234},
{"rank":"Corporal", "name":"Jones","serial":9876}, 
...etc
]

is it possible to load the values directly into the eto GridView DataStore? Or do they first have to be converted to lists as used in the example in the Rhino developer documentation?

Can anybody supply an example of the best way to go about this?

Regards
Jeremy

Hi @jeremy5,

Maybe this sample helps?

test_gridview_dialog.py (2.1 KB)

– Dale

Hi Dale,

Thanks for the example. Unfortunately, if I run it in the R8 editor I get the following exception:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.ExecTry(RunContext context, IPlatformDocument& doc, Object& docState)
   at Rhino.Runtime.Code.Code.Run(RunContext context)

Regards
Jeremy

It runs with RunPythonScript.

Let me have a look…

– Dale

It runs that way for me too, so I can see the dialog and relate elements of the code to it. Thanks

I just updated to the latest SRC and get a more informative trace from the editor:

Rhino.Runtime.Code.Execution.ExecuteException: Object reference not set to an instance of an object.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Eto.Forms.Window.set_Title(String value) in D:\BuildAgent\work\dujour\src4\DotNetSDK\Eto\src\Eto\Forms\Window.cs:line 244
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of stack trace from previous location ---
   at Python.Runtime.PythonException.ThrowLastAsClrException()
   at Python.Runtime.PythonException.ThrowIfIsNull(NewReference& ob)
   at Python.Runtime.PyModule.Execute(PyObject script, PyDict locals)
   at Python.Runtime.RhinoCodePythonEngine.RunScope(Object scope, Object code, String pythonFile, String beforeScript, String afterScript)
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.ExecTry(RunContext context, IPlatformDocument& doc, Object& docState)
   at Rhino.Runtime.Code.Code.Run(RunContext context)
   --- End of inner exception stack trace ---
System.NullReferenceException: Object reference not set to an instance of an object.
   at Eto.Forms.Window.set_Title(String value) in D:\BuildAgent\work\dujour\src4\DotNetSDK\Eto\src\Eto\Forms\Window.cs:line 244
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of stack trace from previous location ---
   at Python.Runtime.PythonException.ThrowLastAsClrException()
   at Python.Runtime.PythonException.ThrowIfIsNull(NewReference& ob)
   at Python.Runtime.PyModule.Execute(PyObject script, PyDict locals)
   at Python.Runtime.RhinoCodePythonEngine.RunScope(Object scope, Object code, String pythonFile, String beforeScript, String afterScript)
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.ExecTry(RunContext context, IPlatformDocument& doc, Object& docState)
   at Rhino.Runtime.Code.Code.Run(RunContext context)