1. $ pip install wxPython
  1. import wx
  2. class MyFrame(wx.Frame):
  3. def __init__(self, parent, title):
  4. super(MyFrame, self).__init__(parent, title=title, size= (600, 400))
  5. panel = wx.Panel(self)
  6. vbox = wx.BoxSizer(wx.VERTICAL) # 垂直布局
  7. row1 = wx.StaticText(panel, label = "Log in")
  8. vbox.Add( row1, flag = wx.ALIGN_CENTER)
  9. vbox.AddSpacer(10)
  10. row2 = wx.BoxSizer(wx.HORIZONTAL)
  11. row2.Add( wx.StaticText(panel, label = "Username") )
  12. row2.AddSpacer(10)
  13. self.username = wx.TextCtrl(panel)
  14. row2.Add( self.username )
  15. vbox.Add(row2, flag = wx.ALIGN_CENTER)
  16. vbox.AddSpacer(10)
  17. row3 = wx.BoxSizer(wx.HORIZONTAL)
  18. row3.Add( wx.StaticText(panel, label = "Password") )
  19. row3.AddSpacer(10)
  20. self.password = wx.TextCtrl(panel, style = wx.TE_PASSWORD)
  21. row3.Add( self.password )
  22. vbox.Add(row3, flag = wx.ALIGN_CENTER)
  23. vbox.AddSpacer(10)
  24. row4 = wx.Button(panel, label = "Submit")
  25. row4.Bind(wx.EVT_BUTTON, self._submit)
  26. vbox.Add(row4, flag = wx.ALIGN_CENTER)
  27. panel.SetSizer(vbox) # 设置布局
  28. # 提交
  29. def _submit(self, e):
  30. print("Username is (%s)" % (self.username.GetValue()))
  31. print("Password is (%s)" % (self.password.GetValue()))
  32. result = wx.MessageBox(
  33. message = "Username is: %s \nPassword is: %s" % (self.username.GetValue(), self.password.GetValue()),
  34. caption = "登录信息",
  35. style = wx.OK | wx.CANCEL | wx.ICON_NONE
  36. )
  37. print(result)
  38. # app
  39. class MyApp(wx.App):
  40. def OnInit(self):
  41. self.frame = MyFrame(None, "hello world")
  42. self.frame.Show()
  43. return True
  44. app = MyApp()
  45. app.MainLoop()

build

  1. $ pip install pyinstaller
  • 简单的打包:
  1. $ pyinstaller main.py -w -F -n demo -i ./logo.ico // 这会生成一个demo.exe的可执行文件 (dll全部被打包到一起,如果要分离dll取消-F选项)

help:

  1. usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME] [--add-data <SRC;DEST or SRC:DEST>]
  2. [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR] [--hidden-import MODULENAME]
  3. [--additional-hooks-dir HOOKSPATH] [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
  4. [--key KEY] [-d {all,imports,bootloader,noarchive}] [-s] [--noupx] [--upx-exclude FILE] [-c] [-w]
  5. [-i <FILE.ico or FILE.exe,ID or FILE.icns>] [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
  6. [--uac-admin] [--uac-uiaccess] [--win-private-assemblies] [--win-no-prefer-redirects]
  7. [--osx-bundle-identifier BUNDLE_IDENTIFIER] [--runtime-tmpdir PATH] [--bootloader-ignore-signals]
  8. [--distpath DIR] [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a] [--clean] [--log-level LEVEL]
  9. scriptname [scriptname ...]
  10. positional arguments:
  11. scriptname 要处理的脚本文件的名称,也就是一个.spec文件。如果指定了.spec文件,大多数选项都是不必要的,将被忽略。
  12. optional arguments(可选参数):
  13. --distpath DIR DIR放置捆绑的应用程序的位置 (default: .\dist)
  14. --workpath WORKPATH 放置所有临时工作文件 .log .pyz等的位置 (default: .\build)
  15. -y, --noconfirm 替换输出目录 (default: SPECPATH\dist\SPECNAME) without asking for confirmation
  16. --upx-dir UPX_DIR Path to UPX utility (default: search the execution path)
  17. -a, --ascii 不包括unicode编码支持 (default: 包括 如果可用)
  18. --clean 在构建之前清理PyInstaller缓存并删除临时文件
  19. --log-level LEVEL 生成时控制台消息中的详细信息量。 LEVEL可能是TRACEDEBUGINFOWARNERROR, CRITICAL (default: INFO).
  20. What to generate(产生什么):
  21. -D, --onedir 创建一个包含可执行文件的单文件夹捆绑包 (default)
  22. -F, --onefile 创建一个文件捆绑可执行文件
  23. --specpath DIR 用于存储生成的规范文件 (default: 当前目录)
  24. -n NAME, --name NAME 分配给捆绑的应用程序和规范文件的名称 (default: 第一个脚本的基本名称)
  25. What to bundle, where to search:
  26. --add-data <SRC;DEST or SRC:DEST>
  27. Additional non-binary files or folders to be added to the executable. The path separator is
  28. platform specific, ``os.pathsep`` (which is ``;`` on Windows and ``:`` on most unix systems)
  29. is used. This option can be used multiple times.
  30. --add-binary <SRC;DEST or SRC:DEST>
  31. Additional binary files to be added to the executable. See the ``--add-data`` option for more
  32. details. This option can be used multiple times.
  33. -p DIR, --paths DIR A path to search for imports (like using PYTHONPATH). Multiple paths are allowed, separated by
  34. ';', or use this option multiple times
  35. --hidden-import MODULENAME, --hiddenimport MODULENAME
  36. Name an import not visible in the code of the script(s). This option can be used multiple
  37. times.
  38. --additional-hooks-dir HOOKSPATH
  39. An additional path to search for hooks. This option can be used multiple times.
  40. --runtime-hook RUNTIME_HOOKS
  41. Path to a custom runtime hook file. A runtime hook is code that is bundled with the executable
  42. and is executed before any other code or module to set up special features of the runtime
  43. environment. This option can be used multiple times.
  44. --exclude-module EXCLUDES
  45. Optional module or package (the Python name, not the path name) that will be ignored (as
  46. though it was not found). This option can be used multiple times.
  47. --key KEY The key used to encrypt Python bytecode.
  48. How to generate:
  49. -d {all,imports,bootloader,noarchive}, --debug {all,imports,bootloader,noarchive}
  50. Provide assistance with debugging a frozen
  51. application. This argument may be provided multiple
  52. times to select several of the following options.
  53. - all: All three of the following options.
  54. - imports: specify the -v option to the underlying
  55. Python interpreter, causing it to print a message
  56. each time a module is initialized, showing the
  57. place (filename or built-in module) from which it
  58. is loaded. See
  59. https://docs.python.org/3/using/cmdline.html#id4.
  60. - bootloader: tell the bootloader to issue progress
  61. messages while initializing and starting the
  62. bundled app. Used to diagnose problems with
  63. missing imports.
  64. - noarchive: instead of storing all frozen Python
  65. source files as an archive inside the resulting
  66. executable, store them as files in the resulting
  67. output directory.
  68. -s, --strip Apply a symbol-table strip to the executable and shared libs (not recommended for Windows)
  69. --noupx Do not use UPX even if it is available (works differently between Windows and *nix)
  70. --upx-exclude FILE Prevent a binary from being compressed when using upx. This is typically used if upx corrupts
  71. certain binaries during compression. FILE is the filename of the binary without path. This
  72. option can be used multiple times.
  73. Windows and Mac OS X specific options(WindowsMac OS X特定选项):
  74. -c, --console, --nowindowed
  75. 打开用于标准I/O的控制台窗口(默认)。 Windows上,此选项无效
  76. 如果第一个脚本是“.pyw”文件。
  77. -w, --windowed, --noconsole
  78. WindowsMacOS X:不提供标准I/O的控制台窗口。 MacOS X上,这也是
  79. 触发构建OS X .app捆绑包。 Windows上,如果第一个脚本
  80. 是一个“.pyw”文件。 在* NIX系统中,此选项被忽略
  81. -i <FILE.ico or FILE.exe,ID or FILE.icns>, --icon <FILE.ico or FILE.exe,ID or FILE.icns>
  82. FILE.ico:将该图标应用于Windows可执行文件。 FILE.exeID,从中提取具有ID的图标
  83. 一个exe文件。 FILE.icns:将图标应用于Mac OS X上的.app捆绑包
  84. Windows specific options(Windows特定选项):
  85. --version-file FILE 将版本资源从FILE添加到exe
  86. -m <FILE or XML>, --manifest <FILE or XML>
  87. 将清单文件或XML添加到exe
  88. -r RESOURCE, --resource RESOURCE
  89. Windows可执行文件添加或更新资源。资源是一到四个项目,
  90. FILE[,TYPE[,NAME[,LANGUAGE]]]. FILE can be a data file or an exe/dll. For data files, at least
  91. TYPE and NAME must be specified. LANGUAGE defaults to 0 or may be specified as wildcard * to
  92. update all resources of the given TYPE and NAME. For exe/dll files, all resources from FILE
  93. will be added/updated to the final executable if TYPE, NAME and LANGUAGE are omitted or
  94. specified as wildcard *.This option can be used multiple times.
  95. --uac-admin 使用此选项创建清单,该清单将在应用程序重新启动时请求提升。
  96. --uac-uiaccess 使用此选项可以使高级应用程序与远程桌面一起使用。
  97. Windows Side-by-side Assembly searching options (advanced)(Windows并排程序集搜索选项 高级):
  98. --win-private-assemblies
  99. 捆绑到应用程序中的任何共享程序集都将更改为私有程序集。
  100. 这意味着将始终使用这些程序集的确切版本,以及任何较新的版本
  101. 安装在用户计算机上的系统级别的文件将被忽略。
  102. --win-no-prefer-redirects
  103. 在搜索共享或专用程序集以捆绑到应用程序中时,PyInstaller
  104. 宁愿不遵循重定向到较新版本的策略,也将尝试捆绑程序集的确切版本。
  105. Mac OS X specific options:
  106. --osx-bundle-identifier BUNDLE_IDENTIFIER
  107. Mac OS X .app bundle identifier is used as the default unique program name for code signing
  108. purposes. The usual form is a hierarchical name in reverse DNS notation. For example:
  109. com.mycompany.department.appname (default: first script's basename)
  110. Rarely used special options:
  111. --runtime-tmpdir PATH
  112. Where to extract libraries and support files in `onefile`-mode. If this option is given, the
  113. bootloader will ignore any temp-folder location defined by the run-time OS. The
  114. ``_MEIxxxxxx``-folder will be created here. Please use this option only if you know what you
  115. are doing.
  116. --bootloader-ignore-signals
  117. Tell the bootloader to ignore signals rather than forwarding them to the child process. Useful
  118. in situations where e.g. a supervisor process signals both the bootloader and child (e.g. via
  119. a process group) to avoid signalling the child twice.

wxPython 创建基本窗口的更多相关文章

  1. Duiib 创建不规则窗口(转载)

    方法一: 转载:http://blog.csdn.net/chenlycly/article/details/46447297 转载:http://blog.csdn.net/harvic880925 ...

  2. win32手动创建windows窗口的,小记

    摘抄自文档,其中的函数需要以后花时间看 向 WinMain 添加功能 首先,在 WinMain 函数内部创建 WNDCLASSEX 类型的窗口类结构. 此结构包含有关窗口的信息,如应用程序图标.窗口的 ...

  3. 转-JS子窗口创建父窗口操作父窗口

    Javascript弹出子窗口  可以通过多种方式实现,下面介绍几种方法 (1) 通过window对象的open()方法,open()方法将会产生一个新的window窗口对象 其用法为: window ...

  4. iOS 学习笔记 九 (2015.04.02)IOS8中使用UIAlertController创建警告窗口

    1.IOS8中使用UIAlertController创建警告窗口 #pragma mark - 只能在IOS8中使用的,警告窗口- (void)showOkayCancelAlert{    NSSt ...

  5. opener 属性是一个可读可写的属性,可返回对创建该窗口的 Window 对象的引用

    opener 属性是一个可读可写的属性,可返回对创建该窗口的 Window 对象的引用

  6. IE 中创建 子窗口 传值 与接收值 【window.showModalDialog】

    父窗口 创建一个窗口 var backinfo = window.showModalDialog('UserSelect.aspx', '', 'dialogHeight=600px; dialogW ...

  7. 使用jQuery创建模态窗口登陆效果

    日期:2013-8-22  来源:GBin1.com 隐藏模态窗口技术是一种很好的解决方案,用于处理不是特有必要出现在网页上的界面元素.社交网络可以使用模态窗口传达私人讯息以及只针对会员才能看 到的表 ...

  8. win32 htmlayout点击按钮创建新窗口,以及按钮图片样式

    最近在做一个C++ win32的桌面图形程序,我不是C++程序员,做这个只是因为最近没什么java的活. windows api,之前接触的时候,还是大学,那时用这个开发打飞机游戏纯粹是娱乐.现在基本 ...

  9. Android创建窗口(一)创建应用窗口

    所谓的窗口(Window)就是一个显示在手机屏幕上可视化视图的一片区域.在Android中窗口是一个抽象的概念,每一个Activity就对应着一个窗口,而所有的窗口都是由视图(View)来呈现,而我们 ...

随机推荐

  1. 单点登录(SSO)的设计与实现

    一.前言 1.SSO说明 SSO英文全称Single Sign On,单点登录.SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统.https://baike.baidu.c ...

  2. 强连通分量 与 2-SAT

    近期一直在刷这方面的题 因为没法学新知识 但又想写点什么 就水篇博文吧 引理 简单来说,在一个有向图中,若所有点之间两两互相直接可达,则将这个图成为强连通分量 强连通分量可以是某个有向图中的子图 求强 ...

  3. 详述C++casting操作

    Casting----类型转换,也就是将数据从一种类型转换到另一种类型的操作.本文首先给出两种类型转换的方式:隐式转换和显式转换,然后简单介绍一下C语言常用的类型转换方式,最后详细叙述C++中常用的三 ...

  4. Jenkins ( jenkins+harbor)

    Harbor 是咱们国产的docke仓库具体详细了解请参考以下连接 https://blog.csdn.net/csdn_duomaomao/article/details/78036331 http ...

  5. Centos7 yum 安装 oracle-rdbms-server-11gR2-pre

    Oracleyum官方网站 http://yum.oracle.com/ 一.下载yum源 根据自己需求下载相应的yum源 http://yum.oracle.com/getting-started. ...

  6. 将插件绑定在某个phase执行,推送镜像

    文章目录 将插件绑定在某个phase执行 推送镜像 将插件绑定在某个phase执行 需求:在执行mvn clean package 时,插件自动为构建Docker镜像. 实现:将插件的的goal绑定在 ...

  7. 虚拟局域网(VLAN)__语音VLAN

    1.语音VLAN特性使得访问端口能够携带来自IP电话的IP语音流量.当交换机连接到Cisco IP电话时,IP电话就用第3层IP优先级(precedence)和第2层服务级别(class of ser ...

  8. Rsync同步工具

    1.Rsync介绍 1.1 什么是Rsync? Rsync,remote synchronize顾名思意就知道它是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限.时间.软硬链接 ...

  9. Codeforces Round #589 (Div. 2) D. Complete Tripartite(模拟)

    题意:给你n个点 和 m条边 问是否可以分成三个集合 使得任意两个集合之间的任意两个点都有边 思路:对于其中一个集合v1 我们考虑其中的点1 假设点u和1无边 那么我们可以得到 u一定和点1在一个集合 ...

  10. Codeforces Round #666 (Div. 2)

    比赛链接:https://codeforces.com/contest/1397 A. Juggling Letters 题意 给出 $n$ 个字符串,可在字符串间任意移动字母,问最终能否使这 $n$ ...