def OnClose(self, event=None): if (self.IsShownOnScreen() and not self.IsMaximized() and not self.IsIconized()): x, y = self.GetScreenPosition() setcfg("position.reportframe.x", x) setcfg("position.reportframe.y", y) setcfg("size.reportframe.w", self.ClientSize[0]) setcfg("size.reportframe.h", self.ClientSize[1]) config.writecfg() if event: event.Skip()
def main(): config.initcfg("scripting-client") lang.init() app = BaseApp(0) app.TopWindow = ScriptingClientFrame() if sys.platform == "darwin": app.TopWindow.init_menubar() app.TopWindow.listen() app.TopWindow.Show() app.MainLoop() writecfg(module="scripting-client", options=("position.scripting", "size.scripting"))
def close_handler(self, event): if debug: safe_print("[D] measureframe_close_handler") if self.Parent: if self.Parent.worker.is_working(): self.Parent.worker.abort_subprocess(confirm=True) return self.Hide() self.Parent.Show() if getattr(self.Parent, "restore_measurement_mode"): self.Parent.restore_measurement_mode() if getattr(self.Parent, "restore_testchart"): self.Parent.restore_testchart() else: self.Hide() writecfg() self.Destroy() if MeasureFrame.exitcode != 255: MeasureFrame.exitcode = 0
def OnClose(self, event): config.writecfg() if not self.timer.IsRunning(): self.Destroy() else: self.keepGoing = False
def vrmlfile2x3dfile(vrmlpath=None, x3dpath=None, html=True, embed=False, view=False, force=False, cache=True, worker=None, gui=True): """ Convert VRML to HTML. Output is written to <vrmlfilename>.x3d.html unless you set x3dpath to desired output path, or False to be prompted for an output path. """ while not vrmlpath or not os.path.isfile(vrmlpath): if not gui: if not vrmlpath or vrmlpath.startswith("--"): safe_print("No filename given.") else: safe_print("%r is not a file." % vrmlpath) return False if not wx.GetApp(): app = BaseApp(0) defaultDir, defaultFile = config.get_verified_path("last_vrml_path") dlg = wx.FileDialog(None, lang.getstr("file.select"), defaultDir=defaultDir, defaultFile=defaultFile, wildcard=lang.getstr("filetype.vrml") + "|*.vrml;*.vrml.gz;*.wrl.gz;*.wrl;*.wrz", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) dlg.Center(wx.BOTH) result = dlg.ShowModal() vrmlpath = dlg.GetPath() dlg.Destroy() if result != wx.ID_OK: return config.setcfg("last_vrml_path", vrmlpath) config.writecfg(module="VRML-to-X3D-converter", options=("last_vrml_path", )) filename, ext = os.path.splitext(vrmlpath) if x3dpath is None: x3dpath = filename + ".x3d" if x3dpath: dirname = os.path.dirname(x3dpath) while not x3dpath or not waccess(dirname, os.W_OK): if not gui: if not x3dpath: safe_print("No HTML output filename given.") else: safe_print("%r is not writable." % dirname) return False if not wx.GetApp(): app = BaseApp(0) if x3dpath: defaultDir, defaultFile = os.path.split(x3dpath) else: defaultFile = os.path.basename(filename) + ".x3d" dlg = wx.FileDialog(None, lang.getstr("error.access_denied.write", dirname), defaultDir=defaultDir, defaultFile=defaultFile, wildcard=lang.getstr("filetype.x3d") + "|*.x3d", style=wx.SAVE | wx.FD_OVERWRITE_PROMPT) dlg.Center(wx.BOTH) result = dlg.ShowModal() dlg.Destroy() if result != wx.ID_OK: return x3dpath = dlg.GetPath() dirname = os.path.dirname(x3dpath) vrmlpath, x3dpath = [safe_unicode(path) for path in (vrmlpath, x3dpath)] if sys.platform == "win32": vrmlpath = make_win32_compatible_long_path(vrmlpath) x3dpath = make_win32_compatible_long_path(x3dpath) if html: finalpath = x3dpath + ".html" if sys.platform == "win32": finalpath = make_win32_compatible_long_path(finalpath) x3dpath = finalpath[:-5] else: finalpath = x3dpath if worker: worker.clear_cmd_output() worker.start( lambda result: show_result_dialog(result, wx.GetApp().GetTopWindow()) if isinstance(result, Exception ) else result and view and launch_file(finalpath), x3dom.vrmlfile2x3dfile, wargs=(vrmlpath, x3dpath, html, embed, force, cache, worker), progress_title=lang.getstr("vrml_to_x3d_converter"), progress_start=1, resume=worker.progress_wnd and worker.progress_wnd.IsShownOnScreen(), fancy=False) else: result = x3dom.vrmlfile2x3dfile(vrmlpath, x3dpath, html, embed, force, cache, None) if not isinstance(result, Exception) and result: if view: launch_file(finalpath) else: return False return True