PySimpleGUI - 環境設定



PySimpleGui 支援 Python 3.x 版本和 Python 2.7 版本。主埠 PySimpleGui 沒有外部依賴項,因為它基於 Tkinter(它基於該庫),Tkinter 是 Python 標準庫的一部分,因此無需單獨安裝它。透過 PIP 安裝程式在當前 Python3 環境中安裝它,如下所示

pip3 install PySimpleGUI

要驗證庫是否正確安裝,輸入以下語句:-

>>> import PySimpleGUI
>>> PySimpleGUI.version
'4.60.1 Released 22-May-2022'

如果 PIP 安裝不起作用,你可以從 Github 儲存庫 (https://github.com/PySimpleGUI/PySimpleGUI) 下載 "pysimplegui.py",並將其與應用程式一同放在你的資料夾中匯入。

pysimplegui.py 檔案具有 "main()" 函式。從 Python 提示符呼叫時,它會生成以下視窗以確認包已正確安裝。

>>> 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 視窗如下所示

Environment Setup

如果你使用早於 3.4 的 Python3 版本,則可能需要安裝 "typing" 模組,因為它未包含在相應的標準庫中。

pip3 install typing

對於 Python 2.7,請將名稱更改為 PySimpleGUI27。

pip3 install PySimpleGUI27

你可能還需要為版本 2.7 安裝 "future"

pip3 install future

但是,請務必注意,Python 軟體基金會並不正式支援 Python 2.x 分支。

廣告