Pysimplegui 简明教程

PySimpleGUI - Introduction

Python GUIs for Humans

PySimpleGui 项目最初是 TKinter 包的包装器,该包捆绑在 Python 的标准库中,其目标是简化 GUI 构建过程。

The PySimpleGui project started as a wrapper around TKinter package, which is bundled with Python’s standard library, with the objective to simplify the GUI building process.

PySimpleGui 随后添加了基于 PySide 库(该库本身将最初用 C++ 编写的 Qt GUI 工具包移植到了 Python)和 WxPython(该库移植了另一个流行的 GUI 工具包 WxWidgets)设计桌面 GUI 的功能。这些库分别称为 PySimpleGUIQtPySimpleGUIWx

PySimpleGui subsequently added the ability to design desktop GUIs based on PySide library (which itself ports Qt GUI toolkit, originally written in C++, to Python) and WxPython (which ports another popular GUI toolkit called WxWidgets). These libraries are called PySimpleGUIQt and PySimpleGUIWx respectively.

PySimpleGui 系列的最新成员是 PySimpleGUIWeb 包,该包使用 Remi(远程接口库)构建在网页中呈现的 GUI 设计。

The latest addition to the PySimpleGui family is the PySimpleGUIWeb package which uses the Remi (REMote Interface Library) to construct GUI design that is rendered in a web page.

PySimpleGui 组中的所有包都遵循类似的 API,这意味着 GUI 元素、它们的属性和方法在所有四个包中都是相同的。因此,只需替换导入语句(并保持代码其余部分不变),就可以获得相应的 GUI 设计渲染。这实际上是 PySimpleGui 最重要的特性。这就是它被称为 Python GUIs for Humans. 的原因

All the packages in the PySimpleGui group follow the similar API, which means the names of GUI elements, their properties and methods are same in all the four packages. As a result, just by replacing the import statement (and keeping the rest of the code unchanged), one can get the corresponding GUI design rendered. This is in fact the most important feature of PySimpleGui. That’s why, it is known as Python GUIs for Humans.

Comparison with other GUI Frameworks

Python 程序员可以从各种 GUI 框架中进行选择来开发 GUI 应用程序。TKinter 是正式包含在 Python 标准库中的一个。其他的,其中大多数都是开源的,必须显式安装。

A Python programmer has a variety of GUI frameworks to choose from, to develop a GUI application. TKinter is the one which is officially included in Python’s standard library. Others, most of them are open source, have to be explicitly installed.

Sr.No.

Library & Description

1

*TkInter*Included in Python standard library

2

*PyQt*Python 3 bindings for the Qt application framework.

3

*PySide*Qt for Python (formerly known as PySide) offers the official Python bindings for the Qt cross-platform application and UI framework.

4

*PySimpleGUI*Wraps tkinter, Qt (pyside2), wxPython and Remi (for browser support) in a non-OOP API

5

*wxPython*Supports Windows/Unix/Mac. Supports Python 2.7 and >=3.4. Wraps & extends the wxWidgets toolchain.

6

*PyGObject*PyGObject is a Python package which provides bindings for GObject based libraries such as GTK Replacement for PyGtk.

7

*PyForms*A Python framework to develop GUI application, which promotes modular software design and code reusability with minimal effort.