PDA

View Full Version : Restoring control to Rhino after Application.Run



cicero38
07-15-2010, 03:55 PM
Hello There.
Just starting to enjoy using Python inside Rhino, but I've come across a niggle (of sorts).
After importing the clr, adding a Forms reference from System.Windows, finally using Application.Run(myForm), I successfully have an interactive GUI from which Rhino commands are working, bidirectionally.
The problem is that when I close this instantiated GUI form, I can no longer see code in the Python editor window within Rhino. To clarify, I do see the contents of the Rhino Python Editor, there's just no code visible. I know that the code is still there (ie, if I rerun the code by pressing f5), as it can still run.
In order to fix this, I have to restart Rhino.
Any help would be much appreciated!

Steve Baer
07-16-2010, 08:10 PM
Don't use Application.Run to show a form; this is how standalone applications show their initial form. You want to use the ShowDialog and Show functions instead. Something like:

myForm.ShowDialog()

cicero38
07-17-2010, 11:21 AM
Thanks so much Steve.
Now why can't all of life's problems be answered so succinctly?
Brilliant, thanks again!

cicero38
07-17-2010, 12:46 PM
Hello again.
Using ShowDialog() allows me to return to the Python Editor window once finished, but is there a way to simultaneously use the new coded dialog interactively with the Rhino workspace? Meaning, control of both windows can be simultaneous rather than blocked?

Steve Baer
07-18-2010, 01:49 AM
For that you'll want to use the Show function.

myForm.Show(Rhino.RhinoApp.MainWindow())

cicero38
07-20-2010, 09:11 AM
Steve you are my new hero