1.获取PySimpleGUI库的方法:
在命令提示符即cmd下输入如下命令即可:
pip install PySimpleGUI
2.实现简易计算器框架:
#fusangzhuren
import PySimpleGUI as fs
def button(text):
return fs.Button(text,pad=(2,2),size=(4,2),font=("黑体",18),button_color="black")
layout=[
[fs.T("")],
[fs.In("",size=(28,3),font=("黑体",30))],
[button(i) for i in "123+"],
[button(i) for i in "456-"],
[button(i) for i in "789X"],
[button(i) for i in "0.=/"]
]
window=fs.Window("fs计算器",layout)
while True:
event,values=window.read()
if event==None:
break;
window.close()
效果如图: