def SaveAs(self, position): """ Trigger save procedure for selected item. Parameters: position - item position (int) """ dlg = wx.FileDialog(self, "Choose output file", os.getcwd(), "", files.save_wildcards(allfiles=False), wx.SAVE | wx.CHANGE_DIR) if dlg.ShowModal() == wx.ID_OK: arr = self.list.GetItemPyData(position) save_modules = [x for x in files.modules if x().can_save] flt = save_modules[dlg.GetFilterIndex()]() flt.save(dlg.GetPath(),self.list.GetItemPyData(position)) plt = arr.plot n = 0 while len(plt.children)>0: if flt.multi_data: flt.save(dlg.GetPath(),plt.children[0].GetData(),name="PP_"+str(n)) else: path = dlg.GetPath().split(".") path[-2] = path[-2] + "_PP_" + str(n) path = ".".join(path) flt.save(path,plt.children[0].GetData()) n+=1 plt = plt.children[0] dlg.Destroy()
def edit_label(self, event, pos): from terapy import files if pos == 0: br = self.host.GetBoundingRect(self.get_property_node(0)) w = ChoicePopup( self.host, -1, choices=[x().desc + " (" + ", ".join(x().ext) + ")" for x in files.modules if x().can_save], pos=br.GetPosition(), size=br.GetSize(), style=wx.CB_DROPDOWN | wx.CB_READONLY, ) w.SetSelection([x.__name__ for x in files.modules if x().can_save].index(self.fclass)) w.Bind(wx.EVT_CHOICE, self.onSelectFilter) w.SetFocus() if wx.Platform == "__WXMSW__": w.Bind(wx.EVT_KILL_FOCUS, self.onSelectFilter) elif pos == 1: event.Veto() dlg = wx.FileDialog( self.host, "Choose output file", os.getcwd(), self.filename, files.save_wildcards(allfiles=False), wx.SAVE, ) if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetPath() self.autoname = False self.filter = files.modules[dlg.GetFilterIndex()]() self.fclass = self.filter.__class__.__name__ dlg.Destroy() elif pos == 2: event.Veto() self.autoname = not (self.autoname) elif pos == 3: event.Veto() self.backup = not (self.backup) self.refresh() self.propNodes = [ self.fclass, os.path.basename(self.filename), ["No", "Yes"][self.autoname], ["No", "Yes"][self.backup], ] self.set_property_nodes(True)
def OnFilenameButton(self, event = None): """ Actions triggered by "..." button press. Parameters: event - wx.Event """ from terapy import files dlg = wx.FileDialog(self, "Choose output file", os.getcwd(),"", files.save_wildcards(allfiles=False), wx.SAVE) dlg.SetFilterIndex(self.choice_modules.GetPosition()) if dlg.ShowModal()==wx.ID_OK: self.input_filename.SetValue(dlg.GetFilename()) self.fname = dlg.GetPath() self.choice_modules.SetPosition(dlg.GetFilterIndex()) dlg.Destroy()