New Python user - GUI on a Mac?

I’m starting to get my head around Python, but trying to find a way to access som eGUI elements that could be combined together in a simply form/dialog?

I’ve installed Atom and have seen references to Tkinter as a library, but not sure how to import that into Atom for use? Radio buttons, text box, numbers…

I’ve looked at the Meier_UI_Utility also, but think it might be windows only?

Thanks in advance!

Adrian

Hi Adrian,
Tkinter isn’t going to work. I would recommend using Eto for creating user interface; unfortunately I don’t think we have any good examples of how to do this yet. @curtisw, do we have python samples for some hello world type Eto UI?

Hi, Eto is going to be the future here with RhinoPython, I think, though I haven’t looked at it in a while.

Look here and try editBox for a start. I use this in combo with raw_input to get info within python. I usually use it to print Text info into my files.

Hi @stevebaer,

There’s no examples of how to use Eto in python yet other than this mini sample I posted a while ago. I can put together some more, but I’d need some direction on what type of samples would be most useful.

Cheers!
Curtis.

Thanks Curtis, I don’t think it is too necessary at this point in time relative to the other tons of work that you have :smile: Rereading the initial post, I think getting the user starting with our existing user interface elements that are available in rhinoscriptsyntax is the proper route to take. This is what @rhinorudi was referring to.

Thanks @stevebaer

I’m hoping for a bit more than just matching the rhinoscript limited GUI.
I’m looking to put multiple objects on a single form ideally, which the tkinter one seemed to do.
I’m guessing that is what eto is intended to do? I can’t get the sample to load - there was a note that it came with Rhino Mac, I have the new version installed as of today.

Adrian

Hi @curtisw,
I couldn’t get the mini sample to work - do I need to load up eto in some special way first?
I’m the new Rhino for Mac.
Thanks,
Adrian

[quote=“curtisw, post:4, topic:21188, full:true”] but I’d need some direction on what type of samples would be most useful.

[/quote]

how to make this:

:smile:


not really asking how to make that…
just wondering if it’s possible now to get similar functionality with Eto or if you think it will be possible in the future?

Yes @jeff_hammond, that is the sort of thing I’m hoping for as well.

Adrian

Yes this will be possible. It is a matter of writing quality ‘how-to’ articles and samples.

Great, looking forward to it.

Awesome @stevebaer , is this something that is nearly there? Or still a fair way off?

Thanks,

Adrian

It isn’t at the top of anyone’s list at the moment. We are currently working on new documentation for writing plug-ins on Mac, but that is really focused more toward C# development.

I tried the sample again, and it seems iron python is having trouble importing some types from the Eto.Forms namespace. I fixed it by importing the used types directly. I’m sure these types of issues will be flushed out when this is supported, but I’ve updated the sample with a bit more functionality so you can see how to layout controls and get a value from a text box:

import clr
clr.AddReference("Eto")
clr.AddReference("Rhino.UI")

from Rhino.UI import *
from Eto.Forms import Form, Dialog, Label, TextBox, StackLayout, StackLayoutItem, Orientation, Button, HorizontalAlignment, MessageBox
from Eto.Drawing import *

dlg = Dialog[bool](Title = "Some Dialog", Padding = Padding(10))

label = Label(Text = "Enter a value:")

textBox = TextBox()

entry = StackLayout(Spacing = 5, Orientation = Orientation.Horizontal)
entry.Items.Add(label)
entry.Items.Add(textBox)

apply = Button(Text = "Apply")
def apply_click(sender, e): dlg.Close(True) # true is return value
apply.Click += apply_click

cancel = Button(Text = "Cancel")
def cancel_click(sender, e): dlg.Close(False)
cancel.Click += cancel_click

buttons = StackLayout(Spacing = 5, Orientation = Orientation.Horizontal)
buttons.Items.Add(cancel)
buttons.Items.Add(apply)


content = StackLayout(Spacing = 5) # default orientation is vertical
content.Items.Add(entry)
content.Items.Add(StackLayoutItem(buttons, HorizontalAlignment.Right))

dlg.DefaultButton = apply
dlg.AbortButton = cancel
dlg.Content = content;
result = dlg.ShowModal(RhinoEtoApp.MainWindow)

if result:
	# Do something
	MessageBox.Show("You entered: " + textBox.Text)

Hope this helps!
Curtis.

Thanks Curtis,

I managed to get a multi textbox form working - using your example.

Cheers,
Keith

Yes, have that working @curtisw, it sounds like support might still be a way off, but this offers a bit of hope :smile: