I have a question about syntax using rhinopython to create check boxes using Eto. I’ve been using Grasshopper for a while and have some programming experience with Java mostly and a little bit of python so this maybe a stupid question with a very easy answer but I cant seem to figure it out.
I would like to create a checkbox for each layer in the file. Normally, I would do it like this
# Create controls for the dialog
self.m_label = forms.Label(Text = 'Layers:')
if layers:
for i in range (0,len(layers)):
self.m_checkbox[i] = forms.CheckBox (Text = layers[i])
This is the error I get Message: 'UserInterface' object has no attribute 'm_checkbox'
So for now, I’m doing it manually like this but it seems like a stupid way of doing it since different files might have different number of layers.
# Create controls for the dialog
self.m_label = forms.Label(Text = 'Layers:')
if layers:
for i in range (0,len(layers)):
self.m_checkbox = forms.CheckBox (Text = layers[0])
self.m_checkbox2 = forms.CheckBox (Text = layers[1])
self.m_checkbox3 = forms.CheckBox (Text = layers[2])
Can anyone point me the correct way of doing this? Thanks
Thank you Graham, that seems to have done the trick. Only thing is, again, Im sure this is a very stupid question but how can I keep track of the the index in the loop, I need to do something like
for checkbox in self.m_checkboxes:
layout.AddRow(checkbox[i],checkbox[i+1])
and more importantly when I’m checking their state
def GetState(self):
if self.m_checkbox.Checked : layersToProcess.append(layers[0])
if self.m_checkbox2.Checked : layersToProcess.append(layers[1])
as I said, I think I’m doing things the JAVA / Processing way which isnt ideal for Python