I make a button with eto python script. The mission of button is get text. I want when button click then ‘form’ be hide. When i get text succeed and press ‘Enter’ then ‘form’ comeback.
How can make like that.
Please help me
Help me!
Hi @xiix.xoox,
This should do the trick.
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms
class SimpleEtoDialog(forms.Dialog):
def __init__(self):
self.Title = "Sample Eto Dialog"
self.ClientSize = drawing.Size(200, 200)
self.Padding = drawing.Padding(5)
self.Resizable = False
button = forms.Button()
button.Text = "Click Me!"
button.Click += self.OnPushPickButton
self.Content = button
def OnPickPoint(self, sender, e):
Rhino.Input.RhinoGet.GetPoint("Pick a point", True)
def OnPushPickButton(self, sender, e):
Rhino.UI.EtoExtensions.PushPickButton(self, self.OnPickPoint)
dialog = SimpleEtoDialog()
dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
– Dale
1 Like
Thank you!
Hi Dale, how do I then use the point data elsewhere in my code?
Hi @egdivad, the method to get a point returns a tuple from which you can get the command result and the point if picking the point worked:
def OnPickPoint(self, sender, e):
rc, pt = Rhino.Input.RhinoGet.GetPoint("Pick a point", True)
if rc == Rhino.Commands.Result.Success:
self.Point = pt
print "Point picked: {}".format(pt)
else:
self.Point = None
print "No point picked"
You might define self.Point
already in your constructor function (__init__)
and set it to None
. The variable self.Point
is then available in the scope of your class.
_
c.