Re: Newbie question: How to create a directory dialog?

709 views
Skip to first unread message

Jim Passmore

unread,
Apr 17, 2013, 11:17:11 PM4/17/13
to winp...@googlegroups.com

On Tuesday, April 16, 2013 9:09:55 AM UTC-4, Robert Pollak wrote:


Now I am wondering: Is there a simple way (like Matlab's 'uigetdir') to present a directory dialog to the user? Additionally, I would like to avoid writing Windows-specific code.

Robert,
PyQt is included in WinPython, and could be used for any level of complexity in a GUI, from a dialog to a large application. However, PyQt might get complex (still haven't mastered it!), and it sounds like you're looking for a simple dialog only, with no other GUI elements. WinPython includes guidata and guiqwt, which can simplify Qt applications, especially those with datasets.

For instance, I just tried the following, which pops up a dialog to select a directory, then prints the directory name to the console.

from guidata.qt.compat import getexistingdirectory

if __name__ == '__main__':
    # Create QApplication
    import guidata
    _app = guidata.qapplication()

    myDir = getexistingdirectory()
    print myDir

Perhaps this helps?

Jim

Robert Pollak

unread,
Apr 19, 2013, 11:04:55 AM4/19/13
to winp...@googlegroups.com
from guidata.qt.compat import getexistingdirectory if __name__ == '__main__': # Create QApplication import guidata _app = guidata.qapplication() myDir = getexistingdirectory() print myDir

 Thank you, Jim. This is exactly what I was looking for!

Unfortunately, I could not (and still cannot) find this in the guidata documentation. Anyway, it's now documented here :)

Robert

Jim Passmore

unread,
Apr 19, 2013, 9:53:43 PM4/19/13
to winp...@googlegroups.com

On Friday, April 19, 2013 11:04:55 AM UTC-4, Robert Pollak wrote:

Thank you, Jim. This is exactly what I was looking for!

No problem!

Unfortunately, I could not (and still cannot) find this in the guidata documentation. Anyway, it's now documented here :)

Yeah, the documentation pages for guidata and guiqwt are a little lacking, or maybe just out of date. You can get a feel for what these two libraries have by trying

from guidata import tests
tests.run()

and

from guiqwt import tests
tests.run()

and also checking out the Sift demo in guiqwt. Additionally you can always browse the source--not the easiest way, but you learn a lot that way!

Jim

Reply all
Reply to author
Forward
0 new messages