Python 官方文档:入门教程 => 点击学习
本篇内容介绍了“python静态编译器的用法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!代码如下: &n
本篇内容介绍了“python静态编译器的用法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
代码如下:
def OnBuildOne(self, event): if self.paths.count != 0: self.Report.AppendText(self.CompileInfoHead("File")) path = self.paths[self.List.GetSelection()] print "Building " + path + " ..." try: py_compile.compile(path, None, None) except py_compile.PyCompileError, ex: print ex self.Report.AppendText("=-- Build Finished.\n\n") def OnBuildAll(self, event): if self.paths.count != 0: self.Report.AppendText(self.CompileInfoHead("File(s)")) for path in self.paths: print "Building " + path + " ..." try: py_compile.compile(path, None, None) except py_compile.PyCompileError, ex: print ex self.Report.AppendText("=-- Build Finished.\n\n") def OnBuildDirectory(self, event): dlg = wxDirDialog(self, "Select a directory for build", self.cfg[2]) if dlg.ShowModal() == wxID_OK: path = dlg.GetPath() self.Report.AppendText(self.CompileInfoHead("Directory:", path)) compile_dir(path, 10, None, 1, None) self.Report.AppendText("=-- Build Finished.\n\n") self.cfg[2] = dlg.GetPath() dlg.Destroy() def OnAbout(self, event): dlg = wxMessageDialog(self, "Present by Dracula 2005\n" "Build 2005.05.05\n", "About", wxOK | wxICON_INFORMATION) dlg.ShowModal() dlg.Destroy() def OnResize(self, event): sizeClient = self.GetClientSize() self.List.SetSize(sizeClient) sizeList = self.List.GetClientSize() self.Report.SetSize(wxSize(sizeClient.width, sizeClient.height-sizeList.height)) def OnClose(self, event): try: f = open("config.cfg", "w") f.write(self.cfg[0]) if self.cfg[0][-1] != '\n': f.write("\n") f.write(self.cfg[1]) if self.cfg[1][-1] != '\n': f.write("\n") f.write(self.cfg[2]) f.close() except IOError: pass sys.path = self.save_sys_path[:] self.timer.Stop() del self.timer del self.icon self.Destroy() def OnQuit(self, event): self.Close(true) def PyCheck(self, argv): argv2 = ['pychecker'] argv2.append(argv) pychecker.checker2.main(argv2) #reload(pychecker.checker2) def AddPath(self, path): curdir = path system_dir = curdir + '\\data\\script' system_core_dir = curdir + '\\data\\script\\core' subsystem_dir = curdir + '\\data\\subsystem' subsystem_trashbin_dir = curdir + '\\data\\subsystem\\trashbin' sys.path = self.save_sys_path[:] sys.path.append(curdir) sys.path.append(system_dir) sys.path.append(system_core_dir) sys.path.append(subsystem_dir) sys.path.append(subsystem_trashbin_dir) def CompileInfoHead(self, str1, str2=""): return "=-- %s %s Compile %s %s ...\n" % (self.Date(), self.Time(), str1, str2) def Error(self, error): self.Report.AppendText(error) def Output(self, info): self.Report.AppendText(info) def Date(self): t = time.localtime(time.time()) strDate = time.strftime("%Y.%m.%d", t) return strDate def Time(self): t = time.localtime(time.time()) strTime = time.strftime("%I:%M:%S", t) return strTime def Notify(self): self.statusbar.SetStatusText(self.Date() + " " + self.Time(), 1) class MyApp(wxApp): def OnInit(self): self.frame = MyFrame(NULL, -1, "cd2Py Compiler") self.frame.Show(true) return true cd2Py = MyApp(0) import sys class errCatcher: def __init__(self): pass def write(self, stuff): cd2Py.frame.Error(stuff) class outCatcher: def __init__(self): passdef write(self, stuff): cd2Py.frame.Output(stuff) sys.stderr = errCatcher() sys.stdout = outCatcher() cd2Py.MainLoop()
“Python静态编译器的用法”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!
--结束END--
本文标题: Python静态编译器的用法
本文链接: https://lsjlt.com/news/290922.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0