[Yt-svn] commit/yt: tabel: Added a feature that if load is called empty load() and Tkinter is avialable

Bitbucket commits-noreply at bitbucket.org
Wed Apr 27 08:28:24 PDT 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/5c3834e7471c/
changeset:   r4208:5c3834e7471c
branch:      stable
user:        tabel
date:        2011-04-27 17:17:44
summary:     Added a feature that if load is called empty load() and Tkinter is avialable
it will open a OpenFileDialog and ask you to select the file you want to open.
Consequently you can reuse scripts and apply them to different datasets without
editing the script. E.g. Also as you do interactive work just start with a
pf = load()
instead of trying to remeber which directory etc. you want to work in.
affected #:  1 file (341 bytes)

--- a/yt/convenience.py	Mon Apr 25 12:38:13 2011 -0400
+++ b/yt/convenience.py	Wed Apr 27 17:17:44 2011 +0200
@@ -68,6 +68,17 @@
     match, at which point it returns an instance of the appropriate
     :class:`yt.data_objects.api.StaticOutput` subclass.
     """
+    if len(args) == 0:
+        try:
+            import Tkinter, tkFileDialog
+        except ImportError:
+            return None
+        root = Tkinter.Tk()
+        filename = tkFileDialog.askopenfilename(parent=root,title='Choose a file')
+        if filename != None:
+            return load(filename)
+        else:
+            return None
     candidates = []
     for n, c in output_type_registry.items():
         if n is None: continue

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list