@mikhail wrote:
I am trying to get collapsable form implemented. And I am having a crash issue caused by lines 69 and 75. When the dialog tries to get resized.
If I comment those out they “work” as in text shows up and get’s hidden.
But as soon as its uncommented it just brings everything down.I am using this as an example
Here is what I have right now.
Clearly, there is a syntax issue or something, I just can’t figure out what I should change to get it to work correctly.
Any advice is much appriciated.import System import Rhino import Rhino.UI import Eto.Drawing as drawing import Eto.Forms as forms import scriptcontext as sc __commandname__ = "viAttributeShow" class viAttributeShowModelessForm(forms.Form): # Initializer def __init__(self): self.m_selecting = False # Basic form initialization self.Initialize() # Create the form's controls self.CreateFormControls() # Basic form initialization def Initialize(self): self.Title = 'Show Attributes' self.Padding = drawing.Padding(5) self.Resizable = True self.Maximizable = False self.Minimizable = False self.ShowInTaskbar = False self.MinimumSize = drawing.Size(200, 150) # button to toggle collapsing self.collapseButton = forms.Button(Text = '+', MinimumSize = drawing.Size.Empty) self.collapseButton.Click += self.collapseButton_Click # FormClosed event handler self.Closed += self.OnFormClosed # set content of the collapsed section self.collapsePanel = forms.DynamicLayout(Visible = False, Padding = drawing.Padding(40, 10), DefaultSpacing = drawing.Size(5, 5)) self.collapsePanel.AddRow('Some text 0') self.collapsePanel.AddRow('Some text 1') self.collapsePanel.AddRow('Some text 2') self.collapsePanel.AddRow('Some text 3') self.collapsePanel.AddRow('Some text 4') self.collapsePanel.AddRow('Some text 5') self.collapsePanel.AddRow('Some text 6') # Create all of the controls used by the form def CreateFormControls(self): # Create table layout layout = forms.DynamicLayout() layout.Padding = drawing.Padding(10) layout.Spacing = drawing.Size(5, 5) layout.AddSeparateRow('Text', None, self.collapseButton) layout.AddCentered(self.collapsePanel) # we need this auto-sized so we can get its width to adjust form height layout.Add(None); # expanding space, in case you want the form re-sizable #layout.AddSeparateRow(None, 'Refresh Button', 'Close Button'); # Set the content self.Content = layout def collapseButton_Click(self, sender, e): try: if self.collapsePanel.Visible: #self.Content.ClientSize = drawing.Size(self.Content.ClientSize.Width, self.Content.ClientSize.Height - self.collapsePanel.Height) self.collapsePanel.Visible = False self.collapseButton.Text = '+' else: self.collapsePanel.Visible = True self.collapseButton.Text = '-' #self.Content.ClientSize = drawing.Size(drawing.max(self.Content.ClientSize.Width, self.collapsePanel.Width), self.Content.ClientSize.Height + self.collapsePanel.Height) except: print "Unexpected error:", sys.exc_info()[0] pass # so we don't bring down rhino if there's a bug in the script # Form Closed event handler def OnFormClosed(self, sender, e): # Dispose of the form and remove it from the sticky dictionary if sc.sticky.has_key('attribute_show_form'): form = sc.sticky['attribute_show_form'] if form: form.Dispose() form = None sc.sticky.Remove('attribute_show_form') ################################################################################ # TestViAttributeModelessForm function ################################################################################ def TestViAttributeShowModelessForm(): # See if the form is already visible if sc.sticky.has_key('attribute_show_form'): return # Create and show form form = viAttributeShowModelessForm() form.Owner = Rhino.UI.RhinoEtoApp.MainWindow form.Show() # Add the form to the sticky dictionary so it # survives when the main function ends. sc.sticky['attribute_show_form'] = form def RunCommand( is_interactive ): print "Running", __commandname__ TestViAttributeShowModelessForm() ################################################################################ # Check to see if this file is being executed as the 'main' python # script instead of being used as a module by some other python script # This allows us to use the module which ever way we want. ################################################################################ if __name__ == "__main__": RunCommand(True)
Posts: 2
Participants: 2