$ pip install wxPython
import wx

class MyFrame(wx.Frame):
def __init__(self, parent, title):
super(MyFrame, self).__init__(parent, title=title, size= (600, 400))
panel = wx.Panel(self) vbox = wx.BoxSizer(wx.VERTICAL) # 垂直布局 row1 = wx.StaticText(panel, label = "Log in")
vbox.Add( row1, flag = wx.ALIGN_CENTER)
vbox.AddSpacer(10) row2 = wx.BoxSizer(wx.HORIZONTAL)
row2.Add( wx.StaticText(panel, label = "Username") )
row2.AddSpacer(10)
self.username = wx.TextCtrl(panel)
row2.Add( self.username )
vbox.Add(row2, flag = wx.ALIGN_CENTER)
vbox.AddSpacer(10) row3 = wx.BoxSizer(wx.HORIZONTAL)
row3.Add( wx.StaticText(panel, label = "Password") )
row3.AddSpacer(10)
self.password = wx.TextCtrl(panel, style = wx.TE_PASSWORD)
row3.Add( self.password )
vbox.Add(row3, flag = wx.ALIGN_CENTER)
vbox.AddSpacer(10) row4 = wx.Button(panel, label = "Submit")
row4.Bind(wx.EVT_BUTTON, self._submit)
vbox.Add(row4, flag = wx.ALIGN_CENTER) panel.SetSizer(vbox) # 设置布局 # 提交
def _submit(self, e):
print("Username is (%s)" % (self.username.GetValue()))
print("Password is (%s)" % (self.password.GetValue()))
result = wx.MessageBox(
message = "Username is: %s \nPassword is: %s" % (self.username.GetValue(), self.password.GetValue()),
caption = "登录信息",
style = wx.OK | wx.CANCEL | wx.ICON_NONE
)
print(result) # app
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, "hello world")
self.frame.Show()
return True app = MyApp()
app.MainLoop()

build

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

help:

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

    一概述 二Collection接口 List Set Queue 三Map接口 HashMap LinkedHashMap TreeMap 四其它集合类 Vector Stack HashTable ...

  2. 向数据库添加100W 条数据 性能测试

    向数据库添加100W 条数据 性能测试 : 参考的相关网站目录: JDBC实现往MySQL插入百万级数据 https://www.cnblogs.com/fnz0/p/5713102.html MyS ...

  3. 安装superset

    1.首先去Anaconda官网下载安装脚本 Anaconda3-2019.07-Linux-x86_64.sh 2.上传Anaconda3-2019.07-Linux-x86_64.sh 将Anaco ...

  4. PAT甲级—暴力搜索

    1091 Acute Stroke (30point(s)) 基础的搜索,但是直接用递归会导致段错误,改用队列之后就不会了,这说明递归调用在空间利用率上还是很吃亏的. #include <cst ...

  5. 2019牛客暑期多校训练营(第七场)H.Pair(数位dp)

    题意:给你三个数A,B,C 现在要你找到满足  A and B >C 或者 A 异或 B < C 的对数. 思路:我们可以走对立面 把既满足 A and B <= C 也满足 A 异 ...

  6. 【uva 1442】Cav(算法效率)

    题意:有一个由N个片段构成宽度的洞穴,已知洞顶 si 和洞底 pi 的高度,要求储存尽量多的燃料. 解法:O(n),分别从1到N和从N到1扫一遍,调整每个片段合法的最大高度,求出答案. 1 #incl ...

  7. Codeforces Round #645 (Div. 2) D. The Best Vacation (贪心,二分)

    题意:一年有\(n\)个月,每月有\(d_{i}\)天,找出连续的\(x\)天,使得这\(x\)天的日期总和最大,任意一年都能选. 题解:首先要先贪心,得到:连续的\(x\)天的最后一天一定是某个月的 ...

  8. Educational Codeforces Round 95 (Rated for Div. 2) A. Buying Torches (数学)

    题意:刚开始你有一个木棍,造一个火炬需要一个木根和一个煤块,现在你可以用一个木棍换取\(x\)个木棍,或者\(y\)根木棍换一个煤块,消耗一次操作,问最少需要操作多少次才能造出\(k\)把火炬. 题解 ...

  9. Codeforces Round #649 (Div. 2) A. XXXXX (贪心)

    题意:有一个长度为\(n\)的数组,找一段最长子数组,使得其元素和为\(x\),如果存在,输出子数组的长度,否则输出\(-1\). 题解:这题我们要从元素和\(sum\)来考虑,首先,如果原数组的所有 ...

  10. Codeforces Round #651 (Div. 2) A. Maximum GCD (思维)

    题意:在\(1\)~\(n\)中找两个不相等的数使得他们的\(gcd\)最大. 题解:水题,如果\(n\)是偶数,那么一定取\(n\)和\(n/2\),\(n\)是奇数的话,取\(n-1\)和\((n ...