From: daid303 Date: Fri, 19 Apr 2013 08:13:14 +0000 (+0200) Subject: Add SD card selection if multiple SD cards are found. X-Git-Tag: 13.05~78 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9ee7970f36d1b30bbef5876d51eede8f58f54c11;p=cura.git Add SD card selection if multiple SD cards are found. --- diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index 448191fb..374a0016 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -131,35 +131,49 @@ class SceneView(openglGui.glGuiPanel): elif len(removableStorage.getPossibleSDcardDrives()) > 0: drives = removableStorage.getPossibleSDcardDrives() if len(drives) > 1: - drive = drives[0] + dlg = wx.SingleChoiceDialog(self, "Select SD drive", "Multiple removable drives have been found,\nplease select your SD card drive", drives) + if dlg.ShowModal() != wx.ID_OK: + dlg.Destroy() + return + drive = drives[dlg.GetSelection()] + dlg.Destroy() else: drive = drives[0] filename = os.path.basename(profile.getPreference('lastFile')) filename = filename[0:filename.rfind('.')] + '.gcode' try: - shutil.copy(self._slicer.getGCodeFilename(), drive[1] + filename) + shutil.copy(self._slicer.getGCodeFilename(), drive + filename) except: self.notification.message("Failed to save to SD card") else: - self.notification.message("Saved as %s" % (drive[1] + filename)) + self.notification.message("Saved as %s" % (drive + filename)) else: - defPath = profile.getPreference('lastFile') - defPath = defPath[0:defPath.rfind('.')] + '.gcode' - dlg=wx.FileDialog(self, 'Save toolpath', defPath, style=wx.FD_SAVE) - dlg.SetFilename(defPath) - dlg.SetWildcard('Toolpath (*.gcode)|*.gcode;*.g') - if dlg.ShowModal() != wx.ID_OK: - dlg.Destroy() - return - filename = dlg.GetPath() - dlg.Destroy() + self._showSaveGCode() + if button == 3: + menu = wx.Menu() + self.Bind(wx.EVT_MENU, lambda e: printWindow.printFile(self._slicer.getGCodeFilename()), menu.Append(-1, 'Print with USB')) + self.Bind(wx.EVT_MENU, lambda e: self._showSaveGCode(), menu.Append(-1, 'Save GCode...')) + self.PopupMenu(menu) + menu.Destroy() + + def _showSaveGCode(self): + defPath = profile.getPreference('lastFile') + defPath = defPath[0:defPath.rfind('.')] + '.gcode' + dlg=wx.FileDialog(self, 'Save toolpath', defPath, style=wx.FD_SAVE) + dlg.SetFilename(defPath) + dlg.SetWildcard('Toolpath (*.gcode)|*.gcode;*.g') + if dlg.ShowModal() != wx.ID_OK: + dlg.Destroy() + return + filename = dlg.GetPath() + dlg.Destroy() - try: - shutil.copy(self._slicer.getGCodeFilename(), filename) - except: - self.notification.message("Failed to save") - else: - self.notification.message("Saved as %s" % (filename)) + try: + shutil.copy(self._slicer.getGCodeFilename(), filename) + except: + self.notification.message("Failed to save") + else: + self.notification.message("Saved as %s" % (filename)) def OnToolSelect(self, button): if self.rotateToolButton.getSelected():