CPython Eto doesn’t set Class Parameter


i have the Problem when put a Label to the Dialog that the given Parameter by init the Label dosen´t set. When init the Label and than set the Parameter to the Label this work. This is happen in the Rino WIP use RhinoCode. I prefer when is not to match Parameters to give it the Labe when init this. Give a opportunity to change this?

Her my test Code:

import rhinoscriptsyntax as rs

import System
import System.Collections.Generic
import Rhino
import Eto.Drawing as drawing
import Eto.Forms as forms

class Test_UI(forms.Dialog[bool]):

    def __init__(self):
        self.Titel = 'Hallo'

        layout = forms.DynamicLayout()
        layout.Spacing = drawing.Size(5,5)

        # This dosen´t work with the Textparameter
        label = forms.Label(Text='Testtext')

        # This work
        label = forms.Label()
        label.Text = 'Hallo'

        layout.AddRow(label, None)

        self.Content = layout

def main():
    dialog = Test_UI()

if __name__ == "__main__":

Example_Classparameter.py (1.3 KB)

I can confirm this doesn’t work, while it works in Rhino Python.

ps: your


should be


in order to work

Yes the with the Title was my mistake. But I mean not the the Title Attribut from the Dialog Class. That was not work is this:

label = forms.Label(Text='Testtext')

yes, I understood it was about the label, I asked someone else to look into your posted issue as I don’t have a clue why that would fail.


This is NOT supposed to work. Label does not have a constructor that takes text as input. Even if there was a constructor, the parameter name would be lower case like text= not Text=

label = forms.Label(Text='Hallo')

This is the correct way to set the text value:

label = forms.Label()
label.Text = 'Hallo'

thanks, I saw indeed that it had no such constructor. Can you explain why it did work when running that code in RhinoPython?

I believe that is a feature of IronPython whereby Properties could be set directly via instantiating that way.

The documentation states:

IronPython also supports inline initializing of the attributes of the instance.

See: IronPython .NET Integration

This is similar to doing in C#:

var lbl = new Label() { Text = "Hallo" };
1 Like

@Gijs Nathan is correct. IronPython had a series of features like this that are not part of the python specification and thus not supported in Python 3

1 Like