How to use File Open dialog to get file path in Python

It is pretty easy to pass a filename as a command-line argument to a Python program. However, this can be cumbersome if the users of your program are naive or you need to pass a path that is long or difficult. In such cases, a good solution is to display a File Open dialog and let the user pick the file she wants.

This can be done easily using the Tk library that ships with Python:

Tried with: Python 2.7.3 and Ubuntu 12.04 LTS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s