I use Eto in Rhinoceros in Python.
In this example the user should be able to add a new control by clicking a button.
I am able to add a control after initialization of the dialog (line 47), but when I click a button to add a control, it does not show (line 43).
As far as I can debug, I do create a new group and row, but adding it to the layout doesn’t work…
Here’s my basic code:
import Eto.Drawing as drawing
import Eto.Forms as forms
class Group(forms.GroupBox):
def __init__(self, count):
self.Padding = drawing.Padding(5)
buttonRemoveGroup = forms.Button(Text = 'Remove this group')
buttonRemoveGroup.Click += self.ButtonRemoveGroupClick
self.Content = buttonRemoveGroup
def ButtonRemoveGroupClick(self, sender, e):
self.Detach()
class MyDialog(forms.Dialog):
def __init__(self):
self.Title = 'Add and delete controls'
self.ClientSize = drawing.Size(300, 500)
self.Padding = drawing.Padding(10)
self.Resizable = False
self.countGroups = 0
self.buttonAddGroup = forms.Button(Text = 'Add group')
self.buttonAddGroup.Click += self.ButtonAddGroupClick
self.layout = forms.DynamicLayout()
self.layout.AddRow(self.buttonAddGroup)
self.layout.AddRow(None)
self.Content = self.layout
def AddGroup(self):
self.countGroups += 1
group = Group(self.countGroups)
self.layout.AddRow(group)
self.layout.AddRow(None)
def ButtonAddGroupClick(self, sender, e):
self.AddGroup()
def TestMyDialog():
dialog = MyDialog()
dialog.AddGroup()
dialog.ShowModal()
if __name__ == '__main__':
TestMyDialog()