使用 Python 创建可直接执行的跨平台 GUI 应用程序 [英] Create a directly-executable cross-platform GUI app using Python
问题描述
Python 适用于多种平台,可用于桌面和 Web 应用程序,因此我得出结论,有某种方法可以将其编译为适用于 Mac、Windows 和 Linux 的可执行文件.
Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux.
问题是我不知道从哪里开始或如何用它编写 GUI,有人可以对此有所了解并指出正确的方向吗?
The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?
推荐答案
首先,您需要一些带有 Python 绑定的 GUI 库,然后(如果需要)一些将 Python 脚本转换为独立可执行文件的程序.
First you will need some GUI library with Python bindings and then (if you want) some program that will convert your python scripts into standalone executables.
具有 Python 绑定的跨平台 GUI 库(Windows、Linux、Mac)
当然,有很多,但我在野外见过的最流行的是:
Of course, there are many, but the most popular that I've seen in wild are:
- Tkinter - 基于 Tk GUI 工具包(事实上的 Python 标准 GUI 库,商业项目免费)
- WxPython - 基于 WxWidgets(流行,免费用于商业项目)
- Qt 使用 PyQt 绑定 或 Qt for Python.前者对于商业项目不是免费的.后者不太成熟,但可以免费使用.
- Tkinter - based on Tk GUI toolkit (de-facto standard GUI library for python, free for commercial projects)
- WxPython - based on WxWidgets (popular, free for commercial projects)
- Qt using the PyQt bindings or Qt for Python. The former is not free for commercial projects. The latter is less mature, but can be used for free.
完整列表位于 http://wiki.python.org/moin/GuiProgramming
单个可执行文件(所有平台)
- PyInstaller - 最活跃的(也可以与
PyQt
一起使用) - fbs - 如果您在上面选择了 Qt
- PyInstaller - the most active(Could also be used with
PyQt
) - fbs - if you chose Qt above
单个可执行文件 (Windows)
- py2exe - 曾经是最受欢迎的
- py2exe - used to be the most popular
单个可执行文件 (Linux)
- Freeze - 与 py2exe 的工作方式相同,但针对 Linux 平台
- Freeze - works the same way like py2exe but targets Linux platform
单个可执行文件 (Mac)
- py2app - 同样,像 py2exe 一样工作,但针对 Mac OS
- py2app - again, works like py2exe but targets Mac OS
这篇关于使用 Python 创建可直接执行的跨平台 GUI 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!