import dearpygui.dearpygui as dpg def print_me(sender,app_data): print(f"Menu Item: {sender} value={dpg.get_value(sender)} app_data={app_data}") dpg.create_context() # add a font registry with dpg.font_registry(): with dpg.font("simfang.ttf", 20) as font1: # add the default font range dpg.add_font_range_hint(dpg.mvFontRangeHint_Default) # helper to add range of characters # Options: # mvFontRangeHint_Japanese # mvFontRangeHint_Korean # mvFontRangeHint_Chinese_Full # mvFontRangeHint_Chinese_Simplified_Common # mvFontRangeHint_Cyrillic # mvFontRangeHint_Thai # mvFontRangeHint_Vietnamese dpg.add_font_range_hint(dpg.mvFontRangeHint_Chinese_Full) # add specific range of glyphs dpg.add_font_range(0x3100, 0x3ff0) # add specific glyphs dpg.add_font_chars([0x3105, 0x3107, 0x3108]) # remap や to % dpg.add_char_remap(0x3084, 0x0025) # set font of specific widget dpg.bind_font(font1) with dpg.window(tag="Primary Window"): dpg.add_text("Hello, world") dpg.add_button(label="保存",callback=print_me) dpg.add_input_text(label="string", default_value="示例文本",callback=print_me) dpg.add_slider_float(label="float", default_value=0.273, max_value=1,callback=print_me) with dpg.menu_bar(parent="Primary Window"): with dpg.menu(label="文件"): dpg.add_menu_item(label="打开", callback=lambda : dpg.show_item('file_dialog')) dpg.add_menu_item(label="另存为", callback=print_me) with dpg.menu(label="设置"): dpg.add_menu_item(label="设置项1", callback=print_me, check=True) dpg.add_menu_item(label="设置项2", callback=print_me) dpg.add_menu_item(label="帮助", callback=print_me) with dpg.menu(label="窗口条目"): dpg.add_checkbox(label="勾选", callback=print_me) dpg.add_button(label="点击", callback=print_me) dpg.add_color_picker(label="选择颜色", callback=print_me) with dpg.file_dialog(label="选择文件", directory_selector=False, show=False, callback=print_me,width=700,height=500, file_count=1,default_path='./',tag='file_dialog'): dpg.add_file_extension(".*") dpg.add_file_extension("", color=(150, 255, 150, 255)) dpg.add_file_extension("Source files (*.cpp *.h *.hpp){.cpp,.h,.hpp}", color=(0, 255, 255, 255)) dpg.add_file_extension(".h", color=(255, 0, 255, 255), custom_text="[header]") dpg.add_file_extension(".py", color=(0, 255, 0, 255), custom_text="[Python]") dpg.create_viewport(title='Custom Title', width=1000, height=700, resizable=False) dpg.setup_dearpygui() dpg.show_viewport() dpg.set_primary_window("Primary Window", True) dpg.start_dearpygui() dpg.destroy_context()