2

Here's my code:

import easygui
f = easygui.fileopenbox()
print f

Seems simple, but when I run it, I can't select any of the files, see figure in link. Sorry if this is dumb, but I am at my wit's end!

https://i.stack.imgur.com/A0otI.jpg

6
  • 1
    Try including default="*" and filetypes="*" parameters.
    – mdurant
    Aug 1, 2014 at 19:21
  • your code works for me ( windows as well as linux )
    – Icarus3
    Aug 1, 2014 at 19:34
  • 1
    I suggest you stop using EasyGUI. The project was shut down. It's not maintained, updated, or recommended anymore. Aug 1, 2014 at 19:35
  • from the link, it looks like if you were trying to select a directory. The code does work and when I try to select the directory, it just opens it as to select from its contents.
    – rch
    Aug 1, 2014 at 19:39
  • 1
    It seems to work in windows. As a bit of a plug for easygui, I plan to release a version before the end of 2014 which adds the option 'multiple' to fileopenbox as well as plenty of bug fixes and a few more enhancements. Check sourceforge. Dec 17, 2014 at 6:58

1 Answer 1

2

EasyGui isn't supported anymore. On OS X I don't have this problem with fileopenbox (it looks like what happens with diropenbox actually.) I'd recommend you try something like wxPython. Here's how to get a file open box in that (from https://stackoverflow.com/a/9319832/866271)

import wx

def get_path(wildcard):
    app = wx.App(None)
    style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
    dialog = wx.FileDialog(None, 'Open', wildcard=wildcard, style=style)
    if dialog.ShowModal() == wx.ID_OK:
        path = dialog.GetPath()
    else:
        path = None
    dialog.Destroy()
    return path

print get_path('*.txt')

Tested on OS X with no problem. It's also cross-platform. If you're going to be doing GUI development, there's a lot of options to look at but wxPython is a good one because it uses the native widgets of whatever OS you're running. So everything looks pretty :)

For your case, you could instead call get_path('*.csv') if that's the type of file you're opening. Or just call get_path('*') to get all of them.

4
  • 1
    Thank you very much for this. Unfortunately, I have tried this, and the window flashes open and closes immediately. I have tried to debug this, but am once again hitting the wall. Thanks! Aug 3, 2014 at 2:22
  • 1
    Did you ever get it working? I'm on a Mac and do not have problems with this. Aug 15, 2014 at 18:20
  • Thanks for checking in, and apologies for not updating everyone. Relaunching my terminal seemed to solve the problem… Aug 19, 2014 at 18:13
  • 2
    As an aside, easygui just released version 0.97.2 on pypi. We will have quarterly bug and enhancement releases. Dec 27, 2014 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.