Pysimplegui 简明教程
PySimpleGUI - Environment Setup
PySimpleGui 支持 Python 3.x 版本和 Python 2.7 版本。主端口 PySimpleGui 没有任何外部依赖关系,因为它基于 Tkinter - Tkinter 是 Python 标准库的一部分 - 因此不必单独安装它。按如下步骤使用 PIP 安装程序在当前 Python3 环境中安装:
PySimpleGui supports both Python 3.x versions as well as Python 2.7 version. The main port, PySimpleGui doesn’t have any external dependencies, as Tkinter - on which it is based - is a part of Python’s standard library, and hence it needn’t be installed separately. Install it in the current Python3 environment by the PIP installer as follows
pip3 install PySimpleGUI
要验证该库是否正确安装,请输入以下语句 -
To verify if the library is correctly installed, enter the following statement −
>>> import PySimpleGUI
>>> PySimpleGUI.version
'4.60.1 Released 22-May-2022'
如果 PIP 安装不起作用,您可以从 Github 存储库 (https://github.com/PySimpleGUI/PySimpleGUI) 下载 "pysimplegui.py",并将其与导入它的应用程序一同放置在文件夹中。
In case, the PIP installation doesn’t work, you can download "pysimplegui.py" from the Github repository (https://github.com/PySimpleGUI/PySimpleGUI) and place it in your folder along with the application that is importing it.
pysimplegui.py 文件具有 "main()" 函数。当从 Python 提示符调用时,它会生成以下窗口来肯定该程序包安装正确。
The pysimplegui.py file has the "main()" function. When called from Python prompt, it generates the following window to affirm that the package is correctly installed.
>>> import PySimpleGUI as psg
>>> psg.main()
Starting up PySimpleGUI Diagnostic & Help System
PySimpleGUI long version = 4.60.1 Released 22-May-2022
PySimpleGUI Version 4.60.1
tcl ver = 8.6 tkinter version = 8.6
Python Version 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018,
00:16:47) [MSC v.1916 64 bit (AMD64)]
tcl detailed version = 8.6.6
PySimpleGUI.py location F:\python36\lib\sitepackages\PySimpleGUI\PySimpleGUI.py
GUI 窗口如下所示:
The GUI window appears as below:
如果您使用的是早于 3.4 的 Python3 版本,则可能需要安装 "typing" 模块,因为它没有包含在相应的标准库中
If you are using Python3 version earlier than 3.4, you may need to install the "typing" module since it is not shipped in the corresponding standard library
pip3 install typing
对于 Python 2.7,将名称更改为 PySimpleGUI27。
For Python 2.7, change the name to PySimpleGUI27.
pip3 install PySimpleGUI27
您可能还需要为 2.7 版安装 "future"
You may need to also install "future" for version 2.7
pip3 install future
但是,需要注意的是,Python 软件基金会不正式地支持 Python 2.x 分支。
However, it is important to note that Python Software Foundation doesn’t officially support Python 2.x branches.