I am working on my first Eto form in python, (thank you McNeel for posting examples! rhino-developer-samples/rhinopython at 6 · mcneel/rhino-developer-samples · GitHub )
I have been able to get started by adding a webview to one of the examples. I’m stuck trying to figure out how to position the form in the rhino window? This is what I have now. It works, I just don’t know how to position it…to somewhere besides the center of the window. (pretty sure this is the relevant bit)
def WebViewerExample():
dialog = SampleWebViewDialog();
rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
whole thing is here if it helps.
import Rhino
import scriptcontext
import System
import System.Drawing as sd
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms
# Using SampleEtoRoomNumber dialog Example as guide
class SampleWebViewDialog(forms.Dialog[bool]):
def __init__(self):
self.Title = 'Web View Test'
self.Padding = drawing.Padding(10)
self.Resizable = True
self.DefaultButton = forms.Button(Text = 'OK')
self.DefaultButton.Click += self.OnOKButtonClick
self.AbortButton = forms.Button(Text = 'Cancel')
self.m_webview = forms.WebView()
self.m_webview.Size = drawing.Size(400, 600)
self.m_webview.Url = System.Uri('http://developer.rhino3d.com/guides/rhinopython/')
layout = forms.DynamicLayout()
layout.Spacing = drawing.Size(5, 5)
layout.BeginVertical()
layout.AddRow(self.m_webview)
layout.EndVertical()
layout.AddRow(None) # spacer
layout.BeginVertical()
layout.AddRow(self.DefaultButton, self.AbortButton)
layout.EndVertical()
self.Content = layout
def OnCloseButtonClick(self, sender, e):
self.Close(False)
def OnOKButtonClick(self, sender, e):
self.Close(True)
def WebViewerExample():
dialog = SampleWebViewDialog();
rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
if __name__ == "__main__":
WebViewerExample()