ETO Forms Group Box

Hi,

I’m trying to contruct a form in Rhino 6 (python) and going through the examples here:

I get an error when I try to put in a group box. I’m using the following code:

Create a group box

    self.m_groupbox = forms.GroupBox(Text = 'Groupbox')
    self.m_groupbox.Padding = drawing.Padding(5)
    
    grouplayout = forms.DynamicLayout()
    grouplayout.Spacing = Size(3, 3)

Here is the error:

Message: global name ‘Size’ is not defined

Traceback:
line 26, in init, “C:\Users\bunner\OneDrive - Sealed Air Corporation\Computer\Desktop\Test User Form\Rhino ETO Example.py”
line 132, in RequestRoomNumber, “C:\Users\bunner\OneDrive - Sealed Air Corporation\Computer\Desktop\Test User Form\Rhino ETO Example.py”
line 145, in , “C:\Users\bunner\OneDrive - Sealed Air Corporation\Computer\Desktop\Test User Form\Rhino ETO Example.py”

It doesn’t appear to like the line grouplayout.Spacing = Size(3, 3)

Thanks for the help.

Eric

Hi @eric.bunn,

It seems you forgot the namespace drawing

grouplayout.Spacing = drawing.Size(3, 3)

Edit:
Sorry after reading through the example, i see that the example does not have the namespace either on the GroupBox example, which is wrong. In the ImageView example you can see drawing.Size being used.

@scottd, as you have last modified the example can you fix the GroupBox example code?

Hi,

I did finally figure that out. (grouplayout.Spacing = drawing.Size(3, 3))

Are there any other resources on how to work with group boxes? I cannot determine how the code should be written for a group box and the items within the group box. An example would be good if one is available somewhere. The example posted in that page leaves a lot to the imagination.

I constructed this code from a couple examples. It runs but no group box. Something is missing?

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

class SimpleEtoDialog(forms.Dialog):

    def __init__(self):
        self.Title = "Sample Eto Dialog"
        self.ClientSize = drawing.Size(200, 200)
        self.Padding = drawing.Padding(5)
        self.Resizable = True

        label = forms.Label()
        label.Text = "Hello Rhino.Python!"
        self.Content = label
        
        # Create a group box
        self.m_groupbox = forms.GroupBox(Text = 'Groupbox')
        self.m_groupbox.Padding = drawing.Padding(5)
        
        grouplayout = forms.DynamicLayout()
        grouplayout.Spacing = drawing.Size(3, 3)
        
        label1 = forms.Label(Text = 'Enter Text:')
        textbox1 = forms.TextBox()

        checkbox1 = forms.CheckBox(Text = 'Start a new row')

        grouplayout.AddRow(label1, textbox1)
        grouplayout.AddRow(checkbox1)
        
        self.m_groupbox.Content = grouplayout

def TestSampleEtoDialog():
    dialog = SimpleEtoDialog()
    dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)

if __name__ == "__main__":
    TestSampleEtoDialog()  

Eric

Hi @eric.bunn,

Try the following:

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

class SampleEtoGroupDialog(forms.Dialog):

    def __init__(self):
        self.Title = "Sample"
        self.Padding = drawing.Padding(5)
        self.Resizable = False
        
        table = forms.TableLayout()
        table.Padding = drawing.Padding(5)
        table.Spacing = drawing.Size(5, 5)
        
        for i in range(3):
            title = "Group {0}".format(i)
            group = self.CreateGroup(title)
            table.Rows.Add(group)

        self.Content = table
        
    def CreateGroup(self, title):
        table = forms.TableLayout()
        table.Padding = drawing.Padding(5)
        table.Spacing = drawing.Size(10, 5)
        
        label1 = forms.Label(Text = "Label 1")
        label2 = forms.Label(Text = "Label 2")
        label3 = forms.Label(Text = "Label 3")
        
        table.Rows.Add(label1)
        table.Rows.Add(label2)
        table.Rows.Add(label3)
        
        group = forms.GroupBox()
        group.Text = title
        group.Content = table
        return group
        
def TestSampleEtoGroupDialog():
    dialog = SampleEtoGroupDialog()
    dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)

if __name__ == "__main__":
    TestSampleEtoGroupDialog()  
  • Dale
1 Like

Thank you Dale.

Eric