文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>gui2exe

gui2exe

时间:2010-08-23  来源:菜刀大侠

简介wxPython wxPython是Python编程语言的一个GUI工具箱。他使得Python程序员能够轻松的创建具有健壮、功能强大的图形用户界面的程序。它是Python语言对流行的wxWidgets跨平台GUI工具库的绑定。而wxWidgets是用C++语言写成的。 和Python语言与wxWidgets GUI工具库一样,wxPython是开源软件。这意味着任何人都可以免费地使用它并且可以查看和修改它的源代码,或者贡献补丁,增加功能。   wxPython是跨平台的。这意味着同一个程序可以不经修改地在多种平台上运行。现今支持的平台有:32位微软Windows操作系统、大多数Unix或类Unix系统、苹果Mac OS X。  由于使用Python作为编程语言,wxPython编写简单、易于理解。

第一步下载gui2exe,wxpython,python2.7,py2exe

第二步安装gui2exe,直接双击GUI2Exe.py打开界面如下:

第三步:找到根据

We will build the sample file that comes with py2exe, on: /site-packages/py2exe/sample/singlefile/gui/test_wx.py

With the GUI opened, hit Ctrl+N or choose File => New project... ;

Enter a name for the new project, i.e. "pyexe sample file";

In the central window that appears, under the Target Class box, right click on the list control and select "Add item(s)";

 Left click on the new item in Exe Kind column and select "windows";

 Left click on the new item in the Python Main Script column and browse to search for the aforementioned file;

On the Optimize, Compressed and Bundle Files drop down choices, choose 2, 2, 1 respectively;

Scroll down the central window to the bottom and check the XP Manifest File option;

Click on the Compile button. And you're done.

 You can follow the compilation steps in the bottom log window as py2exe builds your executable. 就可以转化成exe了。

import sys import wx sys.path.append('c:/Program Files/Microsoft Visual Studio 9.0/VC/redist/x86/Microsoft.VC90.CRT') //增加这一行 # By default the executables created by py2exe write output to stderr # into a logfile and display a messagebox at program end when there # has been any output. This logger silently overrides the default # behaviour by silently swallowing everything. if hasattr(sys, "frozen"): class logger: def write(self, text): pass # silently ignore everything sys.stdout = sys.stderr = logger() class MyFrame(wx.Frame): def __init__(self, parent, ID, title, pos=wx.DefaultPosition, size=(200, 200), style=wx.DEFAULT_FRAME_STYLE): wx.Frame.__init__(self, parent, ID, title, pos, size, style) panel = wx.Panel(self, -1) button = wx.Button(panel, 1003, "Close Me") button.SetPosition(wx.Point(15, 15)) wx.EVT_BUTTON(self, 1003, self.OnCloseMe) wx.EVT_CLOSE(self, self.OnCloseWindow) button = wx.Button(panel, 1004, "Press Me") button.SetPosition(wx.Point(15, 45)) wx.EVT_BUTTON(self, 1004, self.OnPressMe) def OnCloseMe(self, event): self.Close(True) def OnPressMe(self, event): # This raises an exception x = 1 / 0 def OnCloseWindow(self, event): self.Destroy() class MyApp(wx.App): def OnInit(self): frame = MyFrame(None, -1, "Hello from wxPython") frame.Show(True) self.SetTopWindow(frame) return True if __name__ == "__main__": app = MyApp(0) app.MainLoop()
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载