Test.gh (6.2 KB)
Eto.Opacity does not work correctly. Rhino 8.20.25133.14001
Hi @taraskydon,
Try Eto.Drawing.Color.FromArgb() and use your opacity value in the A of the RGBA
This will not give a semi-transparent result, unless you create a style.
@michaelvollrath
In rhino 7 works correctly !
in MacOS rhino 8.18 works correctly !.
in Windows rhino 8.20 and rhino 9 Opacity does not work correctly ! @curtisw
Hmm… I believe the intention is that it “should” be able to handle semi transparent colors as well. It looks to be working on my end.
In your code you are setting the window.opacity but what I am saying is set the form.BackgroundColor directly to Eto.Drawing.Colors.Transparent for full transarency or Eto.Drawing.Color.FromArgb(0, 0, 255, your_opacity_value_here) for semi transparency that you can dynamically control with a variable in the alpha argument
EDIT:
It is working on my end on windows on 8.20:
# self.BackgroundColor = Eto.Drawing.Colors.Transparent
self.BackgroundColor = Eto.Drawing.Color.FromArgb(0, 0, 255, 50)
EDIT 2:
This may be clear to others but FromArgb as System.Drawing.Color.FromArgb(a, r, g, b) expects the alpha (a) first, followed by r, g, b values… where as Eto.Drawing.Color.FromArgb(r, g, b, a) expects the r, g, b first followed by alpha last.
This used to trip me up a lot. Sharing for others who may be confused by that as well.
Hi @taraskydon,
Thanks for bringing this to our attention. Yes, I think something went awry with Opacity after transparent BackgroundColor support was added. In particular, and correct me if I’m wrong, it appears to clear out the set background color instead of just changing its opacity.
I’ve created RH-87617 to address this, and to get Opacity and transparent BackgroundColor to work nicely together.
Hi @curtisw,
I just updated to 8.21 and now I can’t get the form background colors to be transparent again.
How do I use the new methods since this last RH-87617 update?
I’ve tried the following on the eto.forms.form init:
self.BackgroundColor = Eto.Drawing.Colors.Transparent (did not work 8.19 and prev but worked great in 8.20, no longer works in 8.21)
self.BackgrondColor = Eto.Drawing.Color.FromArgb(0, 0, 0, 0) does not work in 8.21
self.Opacity = 0 (this will make all controls invisible as well, not just the background color) which I could see being useful for certain cases of course
Please see the below code.
8.20 was perfect (though it didn’t work for @taraskydon implementation)
but now 8.21 (for me, is a regression)
Am I not using it correctly?
A: Styles hack (OR Colors.Transparent or Argb(0,0,0,0) in 8.20)
B: Opacity = 0
C: BackgroundColor = Colors.Transparent
D: BackgroundColor = Colors.FromArgb(0,0,0,0)
#! python 3
import Rhino
import scriptcontext
import System
import Eto
class SampleTransparentEtoForm(Eto.Forms.Form):
def __init__(self):
super().__init__()
self.WindowStyle = Eto.Forms.WindowStyle.NONE
# Styling the form has worked 8.19 and prior, 8.20, and 8.21 still but this is more of a workaround...
self.Styles.Add[Eto.Forms.Panel]("transparent", self.MyFormStyler)
self.Style = "transparent"
# self.Opacity = 0 # This will make controls invisible as well
# self.BackgroundColor = Eto.Drawing.Colors.Transparent # This worked great in 8.20 but did not work in 8.19 or older and does not work in 8.21
# self.BackgroundColor = Eto.Drawing.Color.FromArgb(0, 0, 0, 0) # This worked great in 8.20 but did not work in 8.19 or older and does not work in 8.21
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
self.layout = Eto.Forms.DynamicLayout()
self.layout.AddRow(self.Button)
self.Content = self.layout
def MyFormStyler(self, control):
self.BackgroundColor = Eto.Drawing.Colors.Transparent
window = control.ControlObject
if hasattr(window, "AllowsTransparency"):
window.AllowsTransparency = True
if hasattr(window, "Background"):
brush = window.Background.Clone()
brush.Opacity = 0.1
window.Background = brush
else:
color = window.BackgroundColor
window.BackgroundColor = color.FromRgba(0,0,0,25)
def OnButtonClick(self, sender, e):
self.Close()
def DoSomething():
form = SampleTransparentEtoForm()
form.Owner = Rhino.UI.RhinoEtoApp.MainWindow
form.Show()
if __name__=="__main__":
DoSomething()
EDIT:
I think i’ve narrowed down the issue.
It seems that the following settings have effect on the transparency of the background:
self.WindowStyle = ef.WindowStyle.NONE
self.Resizable = False
if WindowStyle is anything but none then we get the translucent fill for the background color but if its set to NONE we get the true transparent background color.
if Resizable is True, we get the transparent fill but if it’s False we get the translucent fill.
None of my forms are resizable manually, they get resized from code so this flag is always False on my forms but I need the backgrounds to always be transparent, thanks for your help!
I haven’t tested 8.21 on MacOS but 8.20 was working great on both OS
Hey @michaelvollrath,
Thanks for the update, and I’m glad you found the solution to your problem.
Yes, the transparent background will show unless you use WindowStyle.None because it is part of the background window frame. While it could be done to make that part transparent, it does not work for all cases so it was disabled.
On Mac this is not the case and there is no semi-transparent background.
Cheers,
Curtis.
The error with the transparent background appeared again. Version 8 SR22
(8.22.25201.15001, 2025-07-20)
Eto.Forms
this.Resizable = false; if = false then the background is no longer transparent !!!
TransparentForm Test.py (1.8 KB)
@curtisw @michaelvollrath
that’s what I was saying here as well: