Eto: Control Element Resizing?

Hi,

I have a sample Eto I’m working on and having trouble understanding how to control element resizing? A super simplified version of the code (python) I have currently is:

import Eto
import Rhino

class Dialog_Example(Eto.Forms.Dialog):
    
    def OnButton01Click(self, sender, e):
        print('Button 01')
    
    def OnButton02Click(elf, sender, e):
        print('Button 02')
    
    def __init__(self):
        self.Title = "My Sample Window"
        self.Resizable = True
        self.Padding = Eto.Drawing.Padding(5) # Seems not to affect anything?
        
        # Create some Controls for the Dialog
        self.m_txtBox = Eto.Forms.TextBox( Text = 'Example')
        self.m_txtBox.Width = 300
        
        self.m_Button01 = Eto.Forms.Button(Text = 'Button 01')
        self.m_Button01.Click += self.OnButton01Click
        self.m_Button01.Size = Eto.Drawing.Size(100,25)
        
        self.m_Button02 = Eto.Forms.Button(Text = 'Button 02')
        self.m_Button02.Click += self.OnButton02Click
        self.m_Button02.Size = Eto.Drawing.Size(100,25)
        
        # Layout
        layout = Eto.Forms.DynamicLayout()
        
        # Group: Main Group
        self.groupbox_Main = Eto.Forms.GroupBox(Text = 'My First Group')
        layout_Group_01 = Eto.Forms.DynamicLayout()
        layout_Group_01.AddRow(self.m_txtBox, self.m_Button01, self.m_Button02)
        self.groupbox_Main.Content = layout_Group_01
        layout.Add(self.groupbox_Main)
        
        # Set the dialog window Content
        self.Content = layout

# Call the Dialog Window
dialog = Dialog_Example()
rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)

So that works fine, and gives me as I’d expect:

but when I resize it, only the last button ‘stretches’ to fill horizontally and all three elements stretch to fill vertically:

If I wanted to allow the overall window to be resized, but tell the elements inside to stay constant size (no stretch) is there a way to do that?

Alternately, if I wanted to tell it to keep only the buttons constant size, but allow the text-box to stretch, is there a technique to do that in a case like this?

Any input is much appreciated!

thanks,
@ed.p.may

Hi @ed.p.may,

There is some good information here worth reviewing:

I’m a fan of the TableLayout.

– Dale

Hi Dale,

Thank you for your reply. I’ll take a look at the TableLayout and see if that works better than Dynamic for what I’m up to here.

best,
@ed.p.may

Hey @ed.p.may,

TableLayout works just the same as DynamicLayout, the issue is that you aren’t allocating any empty space. Eto’s layout system fills each container with the content.

Using your code as a starting point, adding space inside the GroupBox layout makes the group box grow, but its content keep its size:

layout_Group_01 = Eto.Forms.DynamicLayout()
layout_Group_01.AddRow(self.m_txtBox, self.m_Button01, self.m_Button02)
layout_Group_01.AddSpace()

Alternatively, if you want the GroupBox to keep its size and just have empty space below it, you add the space to the main layout:

layout.Add(self.groupbox_Main)
layout.AddSpace()

Hope this helps!

1 Like

Thanks so much @curtisw ! AddSpace() is just what I was looking for. Super helpful.

thank you!

@ed.p.may

1 Like