def on_import_ascii(self): dlg = wx.FileDialog(self._widget, message="Choose a file", defaultDir=os.getcwd(), defaultFile="", wildcard="All Files|*.*|Projects|*.gt", style=wx.OPEN | wx.CHANGE_DIR) if dlg.ShowModal() == wx.ID_OK: ws = self.project.new(Worksheet, None, self.project.here) path = dlg.GetPaths()[0] ws.array, ws._header = import_ascii(path) dlg.Destroy()
def on_dropped(self, item, data): if 'grafit-object' in data.formats: parent = self.list.model[item] for d in data.get('grafit-object').split('\n'): self.project.items[d].parent = parent return True elif 'filename' in data.formats and item == -1: # import ascii for path in data.get('filename'): ws = self.project.new(Worksheet, str(os.path.basename(path).split('.')[0]), self.project.here) ws.array, ws._header = import_ascii(path) return False else: return False
def import_ascii(self, filename, **kwds): self.array, self._header = import_ascii(filename, **kwds)