Eto Showsemimodal works on PC but not MAC

Hello,
I create Eto form to manage my project but actually working on parts of my code, I want to obtain a Semimodal windows.
It actually works great on PC but I have a problem using the same code on Mac, I have always an error :slight_smile:
Error Message:

dialog.DefaultButton cannot be null, you must specify a default OK button

Traceback:

line 61, in ShowMyCustomDialog, “/Users/Antoine/Library/Application Support/McNeel/Rhinoceros/7.0/scripts/TEST2.py”

line 64, in , “/Users/Antoine/Library/Application Support/McNeel/Rhinoceros/7.0/scripts/TEST2.py”

The code:

import Eto.Forms as forms
import Eto.Drawing as drawing
import Rhino.UI
import Rhino

# Dialogue pour la sélection de l'essence de bois
class WoodSelectionDialog(forms.Dialog[bool]):
    def __init__(self, callback):
        self.Title = "Sélection d'Essence de Bois"
        self.Padding = drawing.Padding(10)
        self.Resizable = False
        self.callback = callback

        wood_types = ["Chêne", "Hêtre", "Pin", "Érable", "Noyer", "Teck", "Merisier", "Fresno", "Bambou", "Acajou"]
        layout = forms.DynamicLayout()
        layout.Padding = drawing.Padding(10)

        for wood in wood_types:
            button = forms.Button(Text=wood)
            button.Click += self.on_wood_selected
            layout.AddRow(button)

        self.Content = layout

    def on_wood_selected(self, sender, e):
        if self.callback:
            self.callback(sender.Text)
        self.Close()

# Dialogue principal
class MyCustomDialog(forms.Dialog[bool]):
    def __init__(self):
        self.Title = "My Custom Dialog"
        self.ClientSize = drawing.Size(400, 200)
        self.Padding = drawing.Padding(10)
        self.Resizable = False

        self.label = forms.Label(Text="Essence de bois non sélectionnée")
        woodButton = forms.Button(Text="Choisir essence de bois")
        woodButton.Click += self.on_wood_button_click

        layout = forms.DynamicLayout()
        layout.Padding = drawing.Padding(10)
        layout.AddRow(self.label)
        layout.AddRow(woodButton)

        self.Content = layout

    def on_wood_button_click(self, sender, e):
        dlg = WoodSelectionDialog(self.update_label_with_wood_type)
        dlg.ShowModal()

    def update_label_with_wood_type(self, wood_type):
        self.label.Text = wood_type

# Affichage du dialogue principal de manière semi-modale
def ShowMyCustomDialog():
    dlg = MyCustomDialog()
    # Utilisation de ShowSemiModal pour afficher la fenêtre principale de manière semi-modale
    Rhino.UI.EtoExtensions.ShowSemiModal(dlg, Rhino.RhinoDoc.ActiveDoc, Rhino.UI.RhinoEtoApp.MainWindow)

if __name__ == "__main__":
    ShowMyCustomDialog()

Thanks for your help or advices

Antoine

this seems to circumvent the issue:

class MyCustomDialog(forms.Dialog[bool]):
    def __init__(self):
        self.Title = "My Custom Dialog"
        self.ClientSize = drawing.Size(400, 200)
        self.Padding = drawing.Padding(10)
        self.Resizable = False
        self.DefaultButton = forms.Button()
1 Like

thanks a lot for this quick helps @Gijs

Maybe a Rhino limitation, but once in semimodal mode with my windows, I can use Rhino but I can’t change view, is tay in the active view before opening my dialog…a way to solve it easily or not?
Thanks

I don’t think I follow your last question. Here Rhino is fully accessible when the first dialog is open, and fully blocked when the second opens. What do you see?

When i open the first window, Rhino is accessible but limited, i can’t change the tab view, from perspective to top or right…is stay only on the active tab when opening the window.

When opening the second it is fully blocked as expected.

I 'll test tonight because the day on Mac and the night on PC… and I think it is a Mac problem :slight_smile: