def _watchPathsThread(self): supported_extensions = meshLoader.loadSupportedExtensions() while True: path = getPreference('last_file_path', '') fileList = [] try: for file in os.listdir(path): _, ext = os.path.splitext(file) if ext.lower() not in supported_extensions: continue try: info = os.stat(os.path.join(path, file)) fileList.append((info.st_mtime, os.path.join(path, file))) except: pass except: pass fileList.sort(reverse=True) wx.CallAfter(self._updateFileList, map(lambda n: n[1], fileList[:20])) self._timeout = 50 while self._timeout > 0: sleep(0.1) if not self: return self._timeout -= 1
def onBrowse(self, e): ctrl = e.GetEventObject() dlg = wx.FileDialog(self, _("Open 3D model"), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) wildcardList = ';'.join(map(lambda s: '*' + s, meshLoader.loadSupportedExtensions())) wildcardFilter = "All (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) wildcardList = ';'.join(map(lambda s: '*' + s, meshLoader.loadSupportedExtensions())) wildcardFilter += "|Mesh files (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) dlg.SetWildcard(wildcardFilter) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return ctrl.setting.setValue(dlg.GetPath()) dlg.Destroy()
def _onLoadFile(self, e): dlg = wx.FileDialog(self, _("Open 3D model"), style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE) wildcardList = ';'.join(map(lambda s: '*' + s, meshLoader.loadSupportedExtensions())) wildcardFilter = "All (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) wildcardList = ';'.join(map(lambda s: '*' + s, meshLoader.loadSupportedExtensions())) wildcardFilter += "|Mesh files (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) dlg.SetWildcard(wildcardFilter) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return filenames = dlg.GetPaths() dlg.Destroy() if len(filenames) < 1: return for filename in filenames: self._app.getScene().loadFile(filename)
def getSupportedLoadExtensions(self): return meshLoader.loadSupportedExtensions()