I’m trying to use the mouse event to change the color of the drawable image, but I seem to run into problems on “drawable.mousemove += move” it’s wrong, “drawable.MouseDown += down” is fine, but I seem to have hit a dead end
#! python 3
import Rhino
import Eto
import Eto.Forms as ef
import Eto.Drawing as ed
import rhinoscriptsyntax as rs
class SampleTransparentEtoForm(Eto.Forms.Form):
def __init__(self):
super().__init__()
self.AutoSize = False
self.Resizable = True
self.TopMost = True
self.ShowActivated = False
self.Size = Eto.Drawing.Size(300, 300)
self.Padding = Eto.Drawing.Padding(80)
self.MovableByWindowBackground = True
self.Location = Eto.Drawing.Point(100, 100)
self.Button = Eto.Forms.Button()
self.Button.Text = "Close"
self.Button.Click += self.OnButtonClick
drawable = ef.Drawable()
drawable.Width = 40
drawable.Height = 40
def move(sender, e):
cor = True
def draw(sender, e):
rect = ed.RectangleF(0, 0, 40, 40)
if cor:
e.Graphics.FillEllipse(ed.Colors.Red, rect)
e.Graphics.FillEllipse(ed.Colors.Green, rect)
def down(sender, e):
rs.Command("down_on")
drawable.Paint += draw
drawable.MouseDown += down
drawable.MouseMove += move #here
self.layout = Eto.Forms.DynamicLayout()
self.layout.AddRow(self.Button, None, drawable)
self.Content = self.layout
def OnButtonClick(self, sender, e):
self.Close()
def EstablishForm():
form = SampleTransparentEtoForm()
form.Owner = Rhino.UI.RhinoEtoApp.MainWindow
form.Show()
if __name__ == "__main__":
EstablishForm()