def on_save(self, event): """ save elements to a file """ # all of the patches are going to have 2D vertices el = wxgeom.patches_to_elist(self.spec.selections) if el: outfile = os.path.splitext(self.filename)[0] + _el_ext el.write(outfile) self.status.SetStatusText("Wrote %d elements to %s" % (len(el), outfile))
def on_calc_pitch(self, event): """ This function takes all the selected elements, or all of them if none are selected, and calculates the pitch for each. """ elems = self.get_selected() if len(elems) < 1: elems = self.spec.selections if len(elems) < 1: elems = None else: elems = wxgeom.patches_to_elist(elems) try: self.status.SetStatusText("Calculating pitch...") wx.BeginBusyCursor() sig, Fs = self.spec.handler.signal, self.spec.handler.Fs self.spec.plot_calcd_pitch(sig, Fs, elems) self.status.SetStatusText("Calculating pitch...done") except Exception, e: self.status.SetStatusText("Error calculating pitch: %s" % e)