zoukankan      html  css  js  c++  java
  • PyQt学习笔记(二)将PyQt项目转化为WIN下的可执行程序

    将PyQt项目转化为WIN下的可执行程序
    对于这个问题,自己也尝试了不少的安装方法,现将成功的一条记录如下,供参考。
    1.先下载与安装:Microsoft Visual C++ 2008 Redistributable Package (x86),从这里:http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en
    或者将msvcp90.dll直接放到如下目录内:C:\Python26\DLLs。
    2.写一个最简单的例子如下,命名为:test.py
    """
    This is a template for PyQt4 Pragram based QDialog
    """

    from PyQt4 import QtGui
    from PyQt4 import QtCore
    import sys


    class Form(QtGui.QDialog):

        def __init__(self, parent = None):
            super(Form, self).__init__(parent)
            #~ layout = QtGui.QVBoxLayout()
            #~ self.setLayout(layout)


    def main():
        """
        The Pragram main port
        """
        app = QtGui.QApplication(sys.argv)
        form = Form()
        form.show()
        app.exec_()


    if __name__ == '__main__':
        main()
     
    3.写一个安装脚本如下,命名为:setup.py

    from distutils.core import setup
    import py2exe
    import sys

    # If run without args, build executables, in quiet mode.
    if len(sys.argv) == 1:
        sys.argv.append("py2exe")
        sys.argv.append("--includes")
        sys.argv.append("sip")
       
       
    class Target:
        def __init__(self, **kw):
            self.__dict__.update(kw)
            # for the versioninfo resources
            self.version = "0.5.0"
            self.company_name = "No Company"
            self.copyright = "no copyright"
            self.name = "py2exe sample files"

    test = Target(
        # used for the versioninfo resource
        description = "A sample GUI app",

        # what to build
        script = "test.py",
        #~ other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="test_wx"))],
        icon_resources = [(1, "editra.ico")]
        #~ dest_base = "test_wx"
        )
    setup(
        # The first three parameters are not required, if at least a
        # 'version' is given, then a versioninfo resource is built from
        # them and added to the executables.
        #~ version = "0.5.0",
        #~ description = "py2exe sample script",
        #~ name = "py2exe samples",

        # targets to build
        windows = [test]
        #~ console = ["hello.py"],
        )

    4.执行你的setup.py脚本,看是否生成了你想要的东西。
    据说(我没有测试)发布是不要忘记了文件:msvcp90.dll。

  • 相关阅读:
    centos6 LVS-DR模式---分析
    centos6.6 安装 LXC
    Amoeba-mysql读写分离实战
    keepalived +mysql 实战
    nginx添加sticky模块-cookie保持会话
    haproxy转发真实IP给web
    Mysql-如何正确的使用索引以及索引的原理
    Mysql-自带的一些功能,基本用法(视图,触发器,事务,存储过程,函数,流程控制)
    Mysql-常用数据的基本操作和基本形式
    Mysql-多表连接的操作和用法
  • 原文地址:https://www.cnblogs.com/huangliujing/p/1558724.html
Copyright © 2011-2022 走看看