简单的Python GUI应用程序(tkinter包装器)
easy-gui的Python项目详细描述
易逖贵
easy_gui是一个高级Python库,旨在通过包装tkinter简化创建gui应用程序的过程。解决问题很棘手。。。使用我们的解决方案应该很容易!在
快速启动
- 安装easy_gui非常简单。只需使用pip:
pip install easy_gui
- 在
要使用easy_gui创建应用程序,请将easy子类化_gui.EasyGUI类并在init方法中添加元素。在
在 - 在
下面是一个最简单的例子:
在
- 现在来看一个更实际的例子,它也展示了CSS样式的布局功能。参见脚本示例/simple_图形用户界面.py对于带有附加解释性注释的代码:
import easy_gui
class GUI(easy_gui.EasyGUI):
def __init__(self):
self.title('Animal Diet Generator')
self.geometry("425x170")
section = self.add_section('example_section')
section.configure_grid(['title title output',
'label1 entry1 output',
'label2 entry2 output',
'run_button run_button output'])
section.add_widget(type='label', text='Animal Diet Generator!', grid_area='title')
section.add_widget(type='label', text='Animal:', grid_area='label1')
self.animal = section.add_widget(type='entry', grid_area='entry1')
section.add_widget(type='label', text='Food:', grid_area='label2')
self.food = section.add_widget(type='entry', grid_area='entry2')
section.add_widget(type='stdout', grid_area='output')
section.add_widget(type='button', text='Generate Diet!', grid_area='run_button', command_func=self.diet)
def diet(self, event):
print(f'The {self.animal.get()} likes to eat {self.food.get()}!')
application = GUI()
当前特性
- 通过子类化easy快速而轻松地构建GUI_gui.EasyGUI. 在
- 创建一个或多个节(包括嵌套节)来组织GUI元素。在
- 将easy_gui小部件对象添加到节:
- 按钮,标签,条目,复选框,下拉列表,列表框,树,MatplotlibPlot,ProgressBar,滚动文本,StdOutBox
- CSS网格样式布局。在
- 轻松地使用多线程处理以提高GUI响应能力(在创建按钮小部件时设置“separate_thread=True”)
许可证
麻省理工学院
- 项目
标签: