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

agordhandas
  • 47
  • 1
  • 3
  • 1
    Try including `default="*"` and `filetypes="*"` parameters. – mdurant Aug 01 '14 at 19:21
  • your code works for me ( windows as well as linux ) – Icarus3 Aug 01 '14 at 19:34
  • 1
    I suggest you stop using EasyGUI. [The project was shut down.](http://easygui.wordpress.com/) It's not maintained, updated, or recommended anymore. – Thomas Hobohm Aug 01 '14 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 01 '14 at 19:39
  • That looks a lot like the result of running `easygui.diropenbox()`... – austin1howard Aug 01 '14 at 19:40
  • 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. – Robert Lugg Dec 17 '14 at 06:58

1 Answers1

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.

Community
  • 1
  • 1
austin1howard
  • 4,815
  • 3
  • 20
  • 23
  • 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! – agordhandas Aug 03 '14 at 02:22
  • 1
    Did you ever get it working? I'm on a Mac and do not have problems with this. – austin1howard Aug 15 '14 at 18:20
  • Thanks for checking in, and apologies for not updating everyone. Relaunching my terminal seemed to solve the problem… – agordhandas Aug 19 '14 at 18:13
  • 2
    As an aside, easygui just released version 0.97.2 on pypi. We will have quarterly bug and enhancement releases. – Robert Lugg Dec 27 '14 at 04:33