twn39 / code

:memo: 代码笔记,通过 issue 的方式记录日常遇到的问题和学习笔记
13 stars 1 forks source link

Dearpygui 设置中文 #430

Open twn39 opened 4 months ago

twn39 commented 4 months ago
import dearpygui.dearpygui as dpg

dpg.create_context()

with dpg.font_registry():
    with dpg.font(r"font/YaHeiConsolas.ttf", 20) as default_font:
        dpg.add_font_range_hint(dpg.mvFontRangeHint_Chinese_Full)
dpg.bind_font(default_font)

with dpg.window(label="GUI 演示", height=200, width=200):
    dpg.add_text("你好,世界!")

dpg.create_viewport(title='你好', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()