创建gui窗口

This commit is contained in:
ranchuan
2025-06-17 19:11:48 +08:00
commit 2be23d5540
5 changed files with 141 additions and 0 deletions

30
dpg_main.py Normal file
View File

@@ -0,0 +1,30 @@
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title='Custom Title', width=600, height=200)
def print_me(sender):
print(f"Menu Item: {sender}")
with dpg.window(label="Tutorial"):
with dpg.menu_bar():
with dpg.menu(label="File"):
dpg.add_menu_item(label="Save", callback=print_me)
dpg.add_menu_item(label="Save As", callback=print_me)
with dpg.menu(label="Settings"):
dpg.add_menu_item(label="Setting 1", callback=print_me, check=True)
dpg.add_menu_item(label="Setting 2", callback=print_me)
dpg.add_menu_item(label="Help", callback=print_me)
with dpg.menu(label="Widget Items"):
dpg.add_checkbox(label="Pick Me", callback=print_me)
dpg.add_button(label="Press Me", callback=print_me)
dpg.add_color_picker(label="Color Me", callback=print_me)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()