I’m trying to flatten the transparent form of the class.
But I can’t figure out what argument “control” is passing, and the editor is giving me an error about “control”
@michaelvollrath Perhaps Sir There is something you should know, asking for your help
Traceback (most recent call last):
File "file:///D:/py/Rhino/Eto/%E7%B1%BB%E7%9A%84%E9%80%8F%E6%98%8E%EF%BC%8C%E7%BB%98%E5%88%B6%E6%88%90%E9%9D%9E%E7%B1%BB%E7%9A%84%E9%80%8F%E6%98%8E.py", line 71, in <module>
NameError: name 'control' is not defined
Are you trying to achieve transparency for the smaller control as well?
I’ve never found a need to do that? If you want to have a “transparent” or “clipped” button you should create an Eto.Forms.Drawable control and then inside the Drawable init and OnPaint you can define your button rectangles/shapes/paths/etc. and then draw/fill them in the OnPaint method.
You override the OnMouseEnter, OnMouseLeave, OnMouseDown, OnMouseUp events in the Drawable to handle the “button interactions” with the mouse.
You can also use use Graphics.SetClip and ResetClip to have images fall within the bounds of a a graphics path such as drawing a typical square image inside of a circle shaped path or oval or whatever…
Here you can see a rectangular headshot image clipped inside an ellipse path:
Inside OnPaint:
def OnPaint(self, e):
e.Graphics.SetClip(self._ellipse_path) # Set the rounded path to clip the icon
e.Graphics.DrawImage(self.icon_image, self._i_rect) # Draw Icon
e.Graphics.ResetClip() # Reset the clipping
But there’s a lot of advantages to setting it up as a class more directly.
Eto.Forms.Form is already a class so by creating form = we are creating an instance of that class.
Is there an issue you are having when trying to set up your form as a class directly?
Well, thanks for your explanation, because when i learned eto, I learned in the official example of eto, which did not show the use of classes, and then I got used to it. In normal times, I would not use classes to encapsulate ETO and directly write flat.
Thank you for your explanation of the benefits of using classes to write eto
Cool, glad it helped you! I also started my Eto journey with avoiding classes as long as I could but it’s really nice being able to organize functions withing a larger class, set class attributes for use throughout that classes definitions, etc. and I caved in eventually
Hey, do you know any tools that can convert bits py2 to py3?
I remember seeing this tool on git, but I forget where it is, it seems to be in the rhino py repository
Which, honestly to me looks like it’s doing the same thing… but I don’t know enough about python nuances to tell you why py3 doesn’t like the way the argument is passed to the constructor of the py2 version…
I like the way py3 is written, it looks very comfortable.
I am looking for it. I found it in a rhino repository some time ago, but I forgot to save the URL path at that time. It seems that there are many rhino libraries, so I need to look for it