@farouk.serragedine thanks for reply,
import Rhino as rh
import System as sy
import scriptcontext as sc
import Rhino.UI as ui
import Eto.Forms as frm
import Eto.Drawing as drw
class MyForms(frm.Dialog):
def __init__(self):
self.layout = frm.DynamicLayout()
self.radio = frm.RadioButtonList()
self.radio.DataStore = ['ADD', 'REM', 'DIS']
self.group = frm.GroupBox(Text = "GB")
self.label = frm.Label(Text = "Label")
self.layoutgb = frm.DynamicLayout()
self.layoutgb.AddRow(self.label)
self.slider = frm.Slider()
self.button = frm.Button(Text = "Button")
self.radio.SelectedIndexChanged += self.OnRadiobuttonChange
self.layout.AddRow(self.radio)
self.layout.AddRow(self.group)
self.layout.AddRow(self.slider)
self.layout.AddRow(self.button)
self.Content = self.layout
def OnRadiobuttonChange(self, sender, e):
if self.radio.SelectedKey == 'ADD': self.slider.Visible = True
if self.radio.SelectedKey == 'REM': self.slider.Visible = False
### OR <alternative>
#if self.radio.SelectedKey == 'ADD': self.group.Content = self.layoutgb
#if self.radio.SelectedKey == 'REM': self.group.Content = None
def RunCommand():
MyForms().ShowModal(ui.RhinoEtoApp.MainWindow)
RunCommand()
the layout should have as fixed controls, the radiobuttonlist at the top, while the button at the bottom. between these two controls there should be other controls to show and hide based on the selected radiobutton. (I was trying with self.layout.Remove(self.control) but maybe as you indicated self.control.visible is more suitable.)
as you can see by running the code i posted, when i hide a control, the height of the button increases, while what i would like to achieve is for the layout to decrease its size automatically. (always if possible)
alternatively I thought if the GroupBox adapts to the new dimensions, in your case it works, I think, because in the lower part there is no button, while in my case it is the button that resizes.
maybe this is how it works, the layout once all the objects are added, the size remains the same, but if some objects hide, the last check adjusts to the space that is left.
ps I noticed you use the Add method, unlike me using AddRow.
edit:
looking at your code, you have set the layout with the established dimensions, and then you go to increase the dimensions by clicking on the button. following this concept, taking the dimensions of the objects that I’m going to hide or show, I could resize the layout to my liking.