Ned Batchelder avatar Ned Batchelder committed cac2fce

Files can now be dragged onto the Aptus window.

Comments (0)

Files changed (2)

 
 * If the view crosses the x-axis, the symmetry is used to speed up computation.
 
-* 'o' opens saved settings or image files.
+* 'o' opens saved settings or image files (*.aptus or *.png).
+
+* Files can be dropped on the Aptus window to open them.
 
 * The About section of the Help dialog now shows versions of installed
   pre-requisite packages.

src/gui/mainframe.py

         self.pointinfo_tool = None
         self.julia_tool = None
 
+        # Files can be dropped here.
+        self.SetDropTarget(MainFrameFileDropTarget(self))
+
     def Show(self, show=True):
         # Override Show so we can set the view properly.
         if show:
             return None, None
 
     def cmd_new(self, event_unused):
-        wx.GetApp().new_window()
+        return wx.GetApp().new_window()
         
     # Files we can open and save.
     wildcards = (
             )
         typ, pth = self.show_file_dialog(dlg)
         if typ:
-            opts = AptusOptions(self.panel.compute)
-            opts.opts_from_file(pth)
-            self.SetClientSize(self.panel.compute.size)
-            self.panel.fire_command(id_redraw)
+            self.open_file(pth)
+            
+    def open_file(self, pth):
+        opts = AptusOptions(self.panel.compute)
+        opts.opts_from_file(pth)
+        self.SetClientSize(self.panel.compute.size)
+        self.panel.fire_command(id_redraw)
 
     def cmd_help(self, event_unused):
         from aptus.gui.help import HelpDlg
                 from aptus.gui import juliapanel
                 self.julia_tool = juliapanel.JuliaFrame(self, self.panel)
                 self.julia_tool.Show()
+
+
+class MainFrameFileDropTarget(wx.FileDropTarget):
+    """A drop target so files can be opened by dragging them to the Aptus window.
+    
+    The first file opens in the current window, the rest open new windows.
+    
+    """
+    def __init__(self, frame):
+        wx.FileDropTarget.__init__(self)
+        self.frame = frame
+
+    def OnDropFiles(self, x, y, filenames):
+        self.frame.open_file(filenames[0])
+        for filename in filenames[1:]:
+            frame = self.frame.cmd_new(None)
+            frame.open_file(filename)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.