[howto] dabo use py2exe to generate win32 gui e...

2023-11-11 09:31

本文主要是介绍[howto] dabo use py2exe to generate win32 gui e...,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

为什么80%的码农都做不了架构师?>>>   hot3.png

author: kjpioo2006 # the_gmail dot com

1环境:

  • dabo 版本信息
package_name = "dabo"
_version = "0.9.3"
_approximateRevision = "~6293"
  • python 2.7
  • 测试app名为webtest,用dabo的appWizard生成,使用sqlite3数据库,名为webtest.sqlite3。
  • webtest目录下已经自动产生了默认的 buildwin.bat 和setup.py
  • py2exe为dabo GUI应用软件生成win32 exe 文件,需要python安装这些module:  
  1. win32com

2生成 EXE

1) setup.py修改

根据 官方提供的 setup.py (官方用了3年都没出现问题),需要对appWizard生成的setup.py 适当修改(下面列出diff文件,左侧是默认setup.py,右侧是修正后的):

diff --git "a/C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\set477.tmp\\setup-HEAD-left.py" "b/D:\\tmp\\python\\daboframework\\test\\webtest\\setup.py"
index bef4677..86d6ede 100644
--- "a/C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\set477.tmp\\setup-HEAD-left.py"
+++ "b/D:\\tmp\\python\\daboframework\\test\\webtest\\setup.py"
@@ -23,23 +23,21 @@ import globif sys.platform.startswith("win"):from distutils.core import setupimport py2exe
-elif sys.platform.startswith("darwin"):
+else:from setuptools import setup
-	import py2app
-elif sys.platform.startswith("linux"):
-	from cx_Freeze import setup, Executable
+	if sys.platform.startswith("darwin"):
+		import py2appimport dabo.iconsfrom App import AppdaboDir = os.path.split(dabo.__file__)[0]-# Find the location of the dabo icons:iconDir = os.path.split(dabo.icons.__file__)[0]iconSubDirs = []def getIconSubDir(arg, dirname, fnames):
-	if ".svn" not in dirname and dirname[-1] != "\\":
+	if ".svn" not in dirname and "cards" not in dirname.lower() and dirname[-1] != "\\":icons = glob.glob(os.path.join(dirname, "*.png"))if icons:subdir = (os.path.join("resources", dirname[len(arg)+1:]), icons)
@@ -51,12 +49,12 @@ localeDir = "%s%slocale" % (daboDir, os.sep)#locales = [("dabo.locale", (os.path.join(daboDir, "locale", "dabo.pot"),))]locales = []def getLocales(arg, dirname, fnames):
-  if ".svn" not in dirname and dirname[-1] != "\\":
-    #po_files = tuple(glob.glob(os.path.join(dirname, "*.po")))
-    mo_files = tuple(glob.glob(os.path.join(dirname, "*.mo")))
-    if mo_files:
-      subdir = os.path.join("dabo.locale", dirname[len(arg)+1:])
-      locales.append((subdir, mo_files))
+	if ".svn" not in dirname and dirname[-1] != "\\":
+		#po_files = tuple(glob.glob(os.path.join(dirname, "*.po")))
+		mo_files = tuple(glob.glob(os.path.join(dirname, "*.mo")))
+		if mo_files:
+			subdir = os.path.join("dabo.locale", dirname[len(arg)+1:])
+			locales.append((subdir, mo_files))os.path.walk(localeDir, getLocales, localeDir)# The applications App object contains all the meta info:
@@ -64,26 +62,25 @@ app = App(MainFormClass=None)_appName = app.getAppInfo("appName")_appShortName = app.getAppInfo("appShortName")
+_appFileStem = _appShortName.lower().replace(" ", "_")_appVersion = app.getAppInfo("appVersion")_appDescription = app.getAppInfo("appDescription")_copyright = app.getAppInfo("copyright")
-_authorName = app.getAppInfo("authorName")
+_authorName = app.getAppInfo("authorName") _authorEmail = app.getAppInfo("authorEmail")_authorURL = app.getAppInfo("authorURL")_authorPhone = app.getAppInfo("authorPhone")-_appComments = ("This is custom software by %s.\r\n""\r\n"
-		"%s\r\n"
-		"%s\r\n"
+		"%s\r\n" 
+		"%s\r\n" "%s\r\n") % (_authorName, _authorEmail, _authorURL, _authorPhone)-# Set your app icon here:
-_appIcon = None
-#_appIcon = "./resources/stock_addressbook.ico"+_appIcon = None_script = "webtest.py"
+manifest = open("webtest.exe.manifest").read()class Target:
@@ -98,9 +95,9 @@ class Target:self.comments = _appCommentsself.script=_script
-		self.other_resources=[(24, 1, manifest)]
+		self.other_resources = [(24, 1, manifest)]if _appIcon is not None:
-			self.icon_resources=[(1, _appIcon)]
+			self.icon_resources = [(1, _appIcon)]data_files=[("db", ["db/default.cnxml"]),
@@ -133,22 +130,28 @@ if sys.platform.startswith("win"):data_files=data_files)+	# Write out the setup.iss file for inno:
+	#iss = open("setup.iss.txt").read() % locals()
+	#open("setup.iss", "wb").write(iss)
+elif sys.platform.startswith("darwin"):options = {"py2app":
-			{"includes": ["App", "__version__", "ui", "biz", "encodings",
-				"wx", "wx.lib.calendar", "wx.gizmos"],
-			"optimize": 2,
-			"excludes": ["matplotlib", "Tkconstants","Tkinter","tcl",
-				"_imagingtk", "PIL._imagingtk",
-				"ImageTk", "PIL.ImageTk", "FixTk", "wxPython",],
-			"argv_emulation": True,
-			"resources": data_files,
-			"plist": dict(CFBundleGetInfoString=_appVersion,
-				CFBundleIdentifier="com.example.webtest",
-				LSPrefersPPC=False,
-				NSHumanReadableCopyright=_copyright),
-			#"iconfile": "resources/logo_green.icns",
-			}}
+	              {"includes": ["App", "__version__", "constants", "db.updates", 
+	                            "ui", "biz", "ss_common.lib.floatcanvas",
+	                            "encodings", "wx", "wx.lib.calendar", "wx.gizmos"],
+	              "optimize": 2,
+	              "excludes": ["matplotlib", "Tkconstants","Tkinter","tcl", 
+	                          "_imagingtk", "PIL._imagingtk",
+	                          "ImageTk", "PIL.ImageTk", "FixTk", "wxPython",
+	                          ],
+	              "argv_emulation": True,
+	              "resources": data_files,
+	              "plist": dict(CFBundleGetInfoString=_appVersion,
+	                            LSPrefersPPC=False,
+	                            NSHumanReadableCopyright=_copyright
+	                           ),
+	              }
+	          }setup(name=_appName,app=[_script],
@@ -183,4 +186,3 @@ elif sys.platform.startswith("linux"):executables=[Executable(_script, compress=True,appendScriptToExe=True)],options=options)
-


2) buildwin.bat文件需要根据实际路径修改:

diff --git "a/C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\bui474.tmp\\buildwin-HEAD-left.bat" "b/D:\\tmp\\python\\daboframework\\test\\webtest\\buildwin.bat"
index f0733a6..131f6c3 100644
--- "a/C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\bui474.tmp\\buildwin-HEAD-left.bat"
+++ "b/D:\\tmp\\python\\daboframework\\test\\webtest\\buildwin.bat"
@@ -1,9 +1,11 @@del /q distrmdir /s /q dist build-python -OO setup.py py2exe --bundle 1
+rem --> must be --bundle 3 for pywincomm to work...
+python -OO setup.py py2exe --bundle 3 %1
+rem python -OO setup.py py2exe-copy c:\python26\lib\site-packages\wx-2.8-msw-unicode\wx\gdiplus.dll dist
+copy c:\python27\lib\site-packages\wx-2.8-msw-unicode\wx\gdiplus.dll distrem  You either need to have your users install the Microsoft Visual Studio 9.0 Runtimes,
@@ -16,10 +18,10 @@ rem  installation on XP and earlier. In addition, these requirements will probabrem  with new versions of Python and wxPython. My current setup is Python 2.6.5, rem  and wxPython 2.8.11.0.-copy win_todist\msvcr90.dll dist
-copy win_todist\msvcm90.dll dist
-copy win_todist\msvcp90.dll dist
-copy win_todist\Microsoft.VC90.CRT.manifest dist
+copy C:\WINDOWS\system32\msvcr90.dll dist
+copy C:\WINDOWS\system32\msvcm90.dll dist
+copy C:\WINDOWS\system32\msvcp90.dll dist
+copy C:\python27\Microsoft.VC90.CRT.manifest distrem Those 3 DLL's can be found in c:\Windows\WinSxS\x86_Microsoft.VC90.CRT_*\rem The Manifest is c:\Windows\WinSxS\Manifests\x86_Microsoft.VC90.CRT_*.manifest 

3) 生成( cmd.exe执行buildwin.bat)

D:\tmp\python\daboframework\test\webtest> .\buildwin.bat

D:\tmp\python\daboframework\test\webtest> dir .\dist

目录: D:\tmp\python\daboframework\test\webtest\distMode                LastWriteTime     Length Name
----                -------------     ------ ----
d----          2013-1-8     13:11            dabo.locale
d----          2013-1-8     13:11            db
d----          2013-1-8     13:11            reports
d----          2013-1-8     13:11            resources
-a---         2012-4-10     23:31      59904 bz2.pyd
-a---         2007-7-18     15:33    1700352 gdiplus.dll
-a---         2008-7-29      9:10       1857 Microsoft.VC90.CRT.manifest
-a---         2008-7-29      3:54     225280 msvcm90.dll
-a---         2008-7-29      8:05     572928 msvcp90.dll
-a---         2008-7-29      8:05     655872 msvcr90.dll
-a---         2012-4-10     23:31     103424 pyexpat.pyd
-a---         2012-4-10     23:31    2303488 python27.dll
-a---        2012-10-27     22:22     364544 pythoncom27.dll
-a---        2012-10-27     22:20     110080 pywintypes27.dll
-a---         2012-4-10     23:31       9728 select.pyd
-a---         2012-4-10     23:31     337920 sqlite3.dll
-a---          2013-1-8     13:12          0 TESTLOG.log
-a---         2012-4-10     23:31     686592 unicodedata.pyd
-a---        2008-10-21      9:42     216064 UxTheme.dll
-a---         2012-4-10     23:31      49664 w9xpopen.exe
-a---          2013-1-8     13:11    6327749 webtest.exe
-a---        2012-10-27     22:21      98816 win32api.pyd
-a---        2012-10-27     22:23     320512 win32com.shell.shell.pyd
-a---        2012-10-27     22:21      33792 win32evtlog.pyd
-a---        2012-10-27     22:21     167936 win32gui.pyd
-a---        2012-10-27     22:20      24064 win32pipe.pyd
-a---        2012-10-27     22:20      35840 win32process.pyd
-a---        2012-10-27     22:20      15872 win32trace.pyd
-a---        2012-10-27     22:26     778752 win32ui.pyd
-a---        2012-10-27     22:26      36864 win32uiole.pyd
-a---        2012-10-27     22:20      25088 win32wnet.pyd
-a---        2012-10-27     22:21     319488 winxpgui.pyd
-a---         2011-7-15     21:39     171008 wx._activex.pyd
-a---         2011-7-15     21:38      73216 wx._animate.pyd
-a---         2011-7-15     21:38     467456 wx._aui.pyd
-a---         2011-7-15     21:38      90624 wx._calendar.pyd
-a---         2011-7-15     21:38     146944 wx._combo.pyd
-a---         2011-7-15     21:38     966144 wx._controls_.pyd
-a---         2011-7-15     21:37     981504 wx._core_.pyd
-a---         2011-7-15     21:38     746496 wx._gdi_.pyd
-a---         2011-7-15     21:39     341504 wx._gizmos.pyd
-a---         2011-7-15     21:38      57856 wx._glcanvas.pyd
-a---         2011-7-15     21:38     395776 wx._grid.pyd
-a---         2011-7-15     21:38     346112 wx._html.pyd
-a---         2011-7-15     21:38      65024 wx._media.pyd
-a---         2011-7-15     21:38     674816 wx._misc_.pyd
-a---         2011-7-15     21:38     562176 wx._richtext.pyd
-a---         2011-7-15     21:39     448000 wx._stc.pyd
-a---         2011-7-15     21:38      74240 wx._webkit.pyd
-a---         2011-7-15     21:38     670720 wx._windows_.pyd
-a---         2011-7-15     21:38     109568 wx._wizard.pyd
-a---         2011-7-15     21:38     144896 wx._xrc.pyd
-a---         2011-7-15     21:33     122368 wxbase28uh_net_vc.dll
-a---         2011-7-15     21:33    1300992 wxbase28uh_vc.dll
-a---         2011-7-15     21:34     121856 wxbase28uh_xml_vc.dll
-a---         2011-7-15     21:34     730112 wxmsw28uh_adv_vc.dll
-a---         2011-7-15     21:34     325120 wxmsw28uh_aui_vc.dll
-a---         2011-7-15     21:34    3165184 wxmsw28uh_core_vc.dll
-a---         2011-7-15     21:34     146432 wxmsw28uh_gizmos_vc.dll
-a---         2011-7-15     21:34      37376 wxmsw28uh_gl_vc.dll
-a---         2011-7-15     21:34     479744 wxmsw28uh_html_vc.dll
-a---         2011-7-15     21:34     102912 wxmsw28uh_media_vc.dll
-a---         2011-7-15     21:34     774656 wxmsw28uh_richtext_vc.dll
-a---         2011-7-15     21:35     532992 wxmsw28uh_stc_vc.dll
-a---         2011-7-15     21:34     504320 wxmsw28uh_xrc_vc.dll
-a---         2012-4-10     23:31      74240 _ctypes.pyd
-a---         2012-4-10     23:31     285184 _hashlib.pyd
-a---         2012-4-10     23:31      40960 _socket.pyd
-a---         2012-4-10     23:31      41984 _sqlite3.pyd
-a---         2012-4-10     23:31     721920 _ssl.pyd
-a---        2012-10-27     22:21       8192 _win32sysloader.pyd
-a---        2012-10-27     22:21      16384 _winxptheme.pydD:\tmp\python\daboframework\test\webtest>

双击webtest.exe 出现GUI界面。


转载于:https://my.oschina.net/kjpioo/blog/100792

这篇关于[howto] dabo use py2exe to generate win32 gui e...的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/389122

相关文章

Java 创建图形用户界面(GUI)入门指南(Swing库 JFrame 类)概述

概述 基本概念 Java Swing 的架构 Java Swing 是一个为 Java 设计的 GUI 工具包,是 JAVA 基础类的一部分,基于 Java AWT 构建,提供了一系列轻量级、可定制的图形用户界面(GUI)组件。 与 AWT 相比,Swing 提供了许多比 AWT 更好的屏幕显示元素,更加灵活和可定制,具有更好的跨平台性能。 组件和容器 Java Swing 提供了许多

Golang GUI入门——andlabs ui

官方不提供gui标准库,只好寻求第三方库。 https://github.com/google/gxui 这个gui库是谷歌内部人员提供的,并不是谷歌官方出品,现在停止维护,只好作罢。 第三方gui库 找了好多,也比较了好多,最终决定使用的是还是 https://github.com/andlabs/ui 相信golang gui还会发展的更好,期待更优秀的gui库 由于andlabs

Win32函数调用约定(Calling Convention)

平常我们在C#中使用DllImportAttribute引入函数时,不指明函数调用约定(CallingConvention)这个参数,也可以正常调用。如FindWindow函数 [DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)]public static extern IntPtr FindWindow

GUI编程08:画笔paint

本节内容视频链接:10、画笔paint_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV1DJ411B75F?p=10&vd_source=b5775c3a4ea16a5306db9c7c1c1486b5 package com.yundait.lesson03;import java.awt.*;import java.awt.event.Wind

C++入门(06)安装QT并快速测试体验一个简单的C++GUI项目

文章目录 1. 清华镜像源下载2. 安装3. 开始菜单上的 QT 工具4. 打开 Qt Creator5. 简单的 GUI C++ 项目5.1 打开 Qt Creator 并创建新项目5.2 设计界面5.3 添加按钮的点击事件5.4 编译并运行项目 6. 信号和槽(Signals and Slots) 这里用到了C++类与对象的很多概念 1. 清华镜像源下载 https://

Git Gui 查看分支历史的时候中文显示乱码

如图所示 在Git Gui工具栏上选择-编辑-选项: 选择:Default File Contents Encoding, change为UTF-8 成功:

Tomcat启动报错:transport error 202: bind failed: Address already in use

Tomcat启动报错:transport error 202: bind failed: Address already in use 了,上网查找了下面这篇文章。也是一种解决办法。 下文来自:http://blog.csdn.net/sam031503/article/details/7037033 tomcat 启动日志报出以下错误:  ERROR: transport err

结合Python与GUI实现比赛预测与游戏数据分析

在现代软件开发中,用户界面设计和数据处理紧密结合,以提升用户体验和功能性。本篇博客将基于Python代码和相关数据分析进行讨论,尤其是如何通过PyQt5等图形界面库实现交互式功能。同时,我们将探讨如何通过嵌入式预测模型为用户提供赛果预测服务。 本文的主要内容包括: 基于PyQt5的图形用户界面设计。结合数据进行比赛预测。文件处理和数据分析流程。 1. PyQt5 图形用户界面设计

Unity Adressables 使用说明(五)在运行时使用 Addressables(Use Addressables at Runtime)

一旦你将 Addressable assets 组织到 groups 并构建到 AssetBundles 中,就需要在运行时加载、实例化和释放它们。 Addressables 使用引用计数系统来确保 assets 只在需要时保留在内存中。 Addressables 初始化 Addressables 系统在运行时第一次加载 Addressable 或进行其他 Addressable API 调

Python GUI入门详解-学习篇

一、简介 GUI就是图形用户界面的意思,在Python中使用PyQt可以快速搭建自己的应用,自己的程序看上去就会更加高大上。 有时候使用 python 做自动化运维操作,开发一个简单的应用程序非常方便。程序写好,每次都要通过命令行运行 python 程序,就不是那么人性化了。为了更方便的操作,使用 Python GUI 编写界面程序,方便后续程序的操作。 二、安装PyQt5和配置可视化界面