PySimpleGUI

看了大神的文章,自己修改修改,选择有用的留下:
使用手册(官方手册):https://pysimplegui.readthedocs.io/en/latest/cookbook/
参考文件:https://linux.cn/article-10027-1.html
在window10下面要制作一个简单的小程序,需要一个输入,显示,以及按钮,看了菜鸟编程以及网络上的的一些资料,果断舍弃Tkinter ,使用上PySimpleGUI,主要是本人是个小白,花太多的时间精力来做个一个界面没有必要,
PySimpleGUI 提供了一种简单明了、易于理解、方便自定义的 GUI 接口。如果使用 PySimpleGUI,很多复杂的 GUI 也仅需不到 20 行代码。

PySimpleGUI 什么时候有用呢?显然,是你需要 GUI 的时候。仅需不超过 5 分钟,就可以让你创建并尝试 GUI。最便捷的 GUI 创建方式就是从 PySimpleGUI 经典实例中拷贝一份代码。具体操作流程如下

  • 找到一个与你需求最接近的 GUI
  • 从经典实例中拷贝代码
  • 粘贴到 IDE 中并运行

具体参考的代码如下,可以实现简单的代码来实现比较不错的图形界面:

import PySimpleGUI as sg
form = sg.FlexForm('My first GUI')
layout = [ [sg.Text('Enter your name'), sg.InputText()],
               [sg.OK()] ]
button, (name,) = form.Layout(layout).Read()

就可以得到如下的简单窗口
PySimpleGUI_第1张图片
这里简单的解释一下:
form 就是显示form,layout就是自动化布局,button以及name就是其中的返回值。

如果还要更多的例子建议参考如下的使用手册:
使用手册:https://pysimplegui.readthedocs.io/en/latest/cookbook/

为了使用方便,把大多数使用的格式放在如下位置,


   import PySimpleGUI as sg
             sg.ChangeLookAndFeel('GreenTan')
             form = sg.FlexForm('Everything bagel', default_element_size=(40, 1))
            column1 = [[sg.Text('Column 1', background_color='#d3dfda', justification='center', size=(10,1))],
                           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')],
                           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')],
                           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]]
            layout = [
                    [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))],
                    [sg.Text('Here is some text.... and a place to enter text')],
                    [sg.InputText('This is my text')],
                    [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)],
                    [sg.Radio('My first Radio!     ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")],
                    [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)),
                     sg.Multiline(default_text='A second multi-line', size=(35, 3))],
                    [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)),
                     sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)],
                    [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)),
                     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25),
                     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75),
                     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10),
                     sg.Column(column1, background_color='#d3dfda')],
                    [sg.Text('_'  * 80)],
                    [sg.Text('Choose A Folder', size=(35, 1))],
                    [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'),
                     sg.InputText('Default Folder'), sg.FolderBrowse()],
                    [sg.Submit(), sg.Cancel()]
                     ]
                button, values = form.Layout(layout).Read()
                sg.MsgBox(button, values)

这样就可以得到如下的图形界面,然后根据自己的代码要求对其中的文件进行内容的修改就可以了。
PySimpleGUI_第2张图片
附上自己依据文件修改的两个界面,确实用个10min左右时间,看看说明就可以使用,自动进行布局,超级方便,特别适用于只要个简单的界面。做好了之后美美的。。。。
就是不知道在插入中需
PySimpleGUI_第3张图片
PySimpleGUI_第4张图片

你可能感兴趣的:(python,PySimpleGui,python,GUI)