zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python的GUI工具dearpygui入门指南

Python工具入门 指南 GUI
2023-09-11 14:17:10 时间
一 概念
1.dearpygui
它是一个易于使用的、动态的、GPU加速的、跨平台的、适用于Python的图形用户界面工具包(GUI)。
2.特性
  • GPU 渲染
  • 简单的内置异步功能支持
  • 完整的主题和样式控制
  • 简单的内置日志窗口
  • 70多个小部件具有数百种小部件组合
  • 详细的文档,示例和无与伦比的支持
3.它是谁的菜?
想用python做界面数据显示的话,想要快速上手,它一个很好的选择。
二 安装方式
1.pip安装
#
$ pip install dearpygui
三 实例解析
1.基本IO实现
import dearpygui.dearpygui as dpg

dpg.create_context()

def change_text(sender, app_data):
    dpg.set_value("text item", f"Mouse Button ID: {app_data}")

def visible_call(sender, app_data):
    print("I'm visible")

with dpg.item_handler_registry(tag="widget handler") as handler:
    dpg.add_item_clicked_handler(callback=change_text)
    dpg.add_item_visible_handler(callback=visible_call)

with dpg.window(width=500, height=300):
    dpg.add_text("Click me with any mouse button", tag="text item")
    dpg.add_text("Close window with arrow to change visible state printing to console", tag="text item 2")

# bind item handler registry to item
dpg.bind_item_handler_registry("text item", "widget handler")
dpg.bind_item_handler_registry("text item 2", "widget handler")

dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
三 参考
1.中文教程链接:
 
https://www.osgeo.cn/dearpygui/tutorials/first-steps.html
 
2.英文教程链接:
https://dearpygui.readthedocs.io/en/latest/documentation/plots.html