RhinoEtoApp.MainWindow.Screen fails on Mac

Hi @curtisw,

i am trying to find the center of the screen in order to place a Form properly. Using below works fine under windows:

 screen = Rhino.UI.RhinoEtoApp.MainWindow.Screen
 w = screen.WorkingArea.Width 
 h = screen.WorkingArea.Height
 center = Eto.Drawing.Point(
                            int(w/2 - self.ClientSize.Width/2), 
                            int(h/2 - self.ClientSize.Height/2)
                            )

But on Mac i get this error for the first line:

Message ‘NoneType’ object has no attribute ‘Screen’

Is there a cross compatible way to find the screen center or a setting which forces a Form to open in the center of the screen ?

thanks,
c.

Hi @clement,

This runs on my Intel-based Mac running macOS Monterey and Rhino 7:

import Eto
import Rhino

s = Rhino.UI.RhinoEtoApp.MainWindow.Screen
w = s.WorkingArea.Width 
h = s.WorkingArea.Height
print('Width: {0}, Height: {1}'.format(w, h))

What do you have?

Here is an alternative, maybe:

bounds = self.Screen.Bounds;
self.Location = drawing.Point(int(bounds.MiddleX - self.ClientSize.Width / 2), int(bounds.MiddleY - self.ClientSize.Height / 2))

test.py (2.2 KB)

– Dale

Hi @dale, Big Sur. I ended up removing the code to center the form under Mac OS. It seems that only Windows does this wrong so i do not force it under Mac.

_
c.