wxPython制作跑monkey工具(Python3)(3)


        sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6)
        sizer.AddMany([PackageLabel,packageText,MTLabel,MTText,MCLabel,MCText,MonkeyLogName,logNameST,button1,button2,button3])
        panel.SetSizer(sizer)


    def runMonkey(self, event):
        RunMonkeyThread()

def killMonkey(self,event):
        KillMonkeyThread()

def exportLog(self,event):
        ExportLogThread()

def OnCloseMe(self, event):
        self.Close(True)
   
    def OnCloseWindow(self,event):
        self.Destroy()


class App(wx.App):


    def __init__(self,redirect=True, filename=None):
        wx.App.__init__(self,redirect,filename)


    def OnInit(self):
        print("Program Startup:")
        self.frame = InsertFrame(parent=None,id=-1)  #创建框架
        self.frame.Show()
        self.SetTopWindow(self.frame)
        print(sys.stderr)  #输出到stderr
        return True


    def OnExit(self):
        print("Program running complete.")
        return True

if __name__=="__main__":
    app = App(redirect=True)  #1.文本重定向从这开始
    app.MainLoop()

二. 将py脚本文件打包成可执行的exe文件命令:

pyinstaller -F -w -i 1.ico --version-file file_version_info.txt "Run Monkey.py"

ico图片生成:

将一般格式的图片(例如png、jpg)转换为ico图片网址:https://www.converticon.com/

版本信息文件内容file_version_info.txt如下:

# UTF-8
#
# For more details about fixed file info 'ffi' see:
#
VSVersionInfo(
  ffi=FixedFileInfo(
    # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
    # Set not needed items to zero 0.
    filevers=(2, 0, 0, 0),
    prodvers=(2, 0, 0, 0),
    # Contains a bitmask that specifies the valid bits 'flags'r
    mask=0x0,
    # Contains a bitmask that specifies the Boolean attributes of the file.
    flags=0x0,
    # The operating system for which this file was designed.
    # 0x4 - NT and there is no need to change it.
    OS=0x4,
    # The general type of file.
    # 0x1 - the file is an application.
    fileType=0x1,
    # The function of the file.
    # 0x0 - the function is not defined for this fileType
    subtype=0x0,
    # Creation date and time stamp.
    date=(0, 0)
    ),
  kids=[
    StringFileInfo(
      [
      StringTable(
        u'080403a8',
        [StringStruct(u'Comments', u'RunMonkey v2.0'),
        StringStruct(u'CompanyName', u''),
        StringStruct(u'FileDescription', u'RunMonkey Application'),
        StringStruct(u'FileVersion', u'2.0.0.0'),
        StringStruct(u'LegalCopyright', u''),
        StringStruct(u'ProductName', u'RunMonkey'),
        StringStruct(u'ProductVersion', u'2.0.0.0'),
        StringStruct(u'SpecialBuild', u'000000')])
      ]),
    VarFileInfo([VarStruct(u'Translation', [2052, 936])])
  ]
)

pyinstaller打包工具安装命令:pip install pyinstaller

pyinstaller打包工具安装完成后,查看安装版本号命令:pyinstaller --version

安装wxpython命令:pip install wxPython

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/fa209430e5d2d3c4e2b62c108018d36b.html