Eto.Forms.OpenFileDialog with multiple filters

Hi I’m trying to use the Eto.Forms.OpenFileDialog and its Filter property with Rhino Common to achieve the following behaviour:

  • the user can select a SINGLE file type filter (PNG, BMP, JPG, ZIP) if he already knows precisely what he’s looking for – or –
  • the user can select an “ALL FILE” filter to browse all files

For the single file type filters all is working as expected:

dialog.Filters.Add(new FileFilter("Png files", ".png"));
dialog.Filters.Add(new FileFilter("Jpg files", ".jpg", ".jpeg"));
...

but if I try to add a filter like this

dialog.Filters.Add(new FileFilter("All files", ".*"));

the dialog is shown correctly, however as soon as I select the “All files” filter from the combo box, Rhino crashes.

I guess filters in a “regexp style” with wildcard characters are not managed behind the hood of Eto.Forms.OpenFileDialog class.

I also tried to use Rhino.UI.OpenFileDialog instead, where the Filter property can be set up in the classic way `Png files (*.png)|*.png|All files (*.*)|*.*`, but no filter is shown.

I’m running my plugin on Rhino 8 for macOS.

  • Rhino version: 8.24
  • macOS version: Tahoe 26.0.1

Is there any workaround to achieve the mentioned behaviour?

Thanks

1 Like

Hi @p.stragliotto,

#! python3
import Eto
import Rhino
import System

def Test():
    dialog = Eto.Forms.OpenFileDialog()
    dialog.Title = "Open"
    dialog.Filters.Add(Eto.Forms.FileFilter("BMP", [".bmp"]))
    dialog.Filters.Add(Eto.Forms.FileFilter("JPG", [".jpeg"]))
    dialog.Filters.Add(Eto.Forms.FileFilter("PNG", [".png"]))
    dialog.Filters.Add(Eto.Forms.FileFilter("Supported Files", [".bmp", ".jpeg", ".png"]))
    dialog.Filters.Add(Eto.Forms.FileFilter("All Files", ["*"]))
    result = dialog.ShowDialog(Rhino.UI.RhinoEtoApp.MainWindow)
    if result == Eto.Forms.DialogResult.Ok:
        path = dialog.FileName
        print(dialog.FileName)

if __name__ == '__main__':
    Test()

– Dale

Thanks @dale

I tried your code as-is on the Script editor, and actually Rhino for macOS crashes the same when selecting “All files” from the combo box.

It works for Rhino Windows, I need to make it work on macOS as well though.

I think this is a bug that needs a fix, in the meantime I will apply no filter and just show all files by default to the user.

Cheers

Hey @p.stragliotto - I tested my script on the Mac, successfully. Let me look into this a little more.

– Dale

1 Like

Hey @p.stragliotto,

Looks like we have already done a fix for this in Rhino WIP, and should be back ported to Rhino 8.

I’ve filed RH-90064 Eto FileDialog crashes when specifying all files to get that fixed up.

Thanks for reporting the issue!

2 Likes

RH-90064 is fixed in Rhino 8 Service Release 25

1 Like

Thank you guys! :flexed_biceps:

1 Like