Hi,
I’m doing quite a bit of wheel spinning trying to close a modeless form with a close button instead of the user clicking the “X”. I’ve pasted in some sample code below. I’ve tried a self.Close(), which crashes Rhino and tried what is in the pasted code below with no success. Can someone tell me what I am doing wrong?
I posted something similar back in May and never got an answer: ETO Modeless Form Close Button
Eric
Test():
print ("Hi")
# Form Closed event handler
def OnFormClosed(self, sender, e):
print("the form has closed")
# Dispose of the form and remove it from the sticky dictionary
if sc.sticky.has_key('sample_modeless_form'):
form = sc.sticky['sample_modeless_form']
if form:
form.Dispose()
form = None
sc.sticky.Remove('sample_modeless_form')
# Close button click handler
def OnCloseButtonClick(self, sender, e):
print("the form has closed")
# Dispose of the form and remove it from the sticky dictionary
if sc.sticky.has_key('sample_modeless_form'):
form = sc.sticky['sample_modeless_form']
if form:
form.Close()
form.Dispose()
form = None
sc.sticky.Remove('sample_modeless_form')
# OK button click handler
def OnOKButtonClick(self, sender, e):
print("clicked")
## End of Dialog Class ##
def Test():
# See if the form is already visible
if sc.sticky.has_key('sample_modeless_form'):
return
# Create and show form
form = ETOModelessForm()
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['sample_modeless_form'] = form
if __name__ == '__main__':
Test()
3 posts - 2 participants