Chinese path support for select_directory_dialog
Version of Dear PyGui: [DearPyGui Version] 0.5.53 [Python Version] 3.9.0 [DearImGui Version] 1.79 [Compiler] MSVC version 1927
OS
Operating System: Windows 10
My Issue/Question
You can see the path with Chinese character is appear as ?? even I tried
add_additional_font('WeiRuanYaHei.ttf', 18, glyph_ranges='chinese_simplified_common')
which only solve the main interface supporting not the select_directory_dialog.
if path with this is selected, DPG will exit without raising any Exception.
I try to dig into the source code of select_directory_dialog in dearpygui, but could not found it.

A clear and concise description of what the issue/question is. Please provide as much context as possible.
To Reproduce
try to create a director with charactor "我的程序", and using select_directory_dialog to select it and press OK.
Expected behavior
normal
Screenshots/Video
see above
Standalone, minimal, complete and verifiable example:
# Here's some code anyone can copy and paste to reproduce your issue
def directory_picker(sender, data):
select_directory_dialog(callback=apply_selected_directory)
def apply_selected_directory(sender, data):
# log_debug(data) # so we can see what is inside of data
directory = data[0]
folder = data[1]
set_value("directory", directory)
set_value("folder", folder)
set_value("folder_path", f"{directory}\\{folder}")`
with window('test):
add_button("Folder", callback=directory_picker)
start_dearpygui()
add_additional_font('WeiRuanYaHei.ttf', 18, glyph_ranges='chinese_simplified_common')
to clarify. I've add this in front of all my code.
this seems to be the problem of ImGui, I found a solution of this from :https://www.joven.top/archives/192
But I don't know how to implement this.
ImGuiIO& io = ImGui::GetIO();
ImFont* font = io.Fonts->AddFontFromFileTTF("Resources/Fonts/zhankuwenyiti.ttf", 22.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
Looking into it but we already do the solution you mentioned.
This appears to be an issue related to ImGuiFileDialog. Still looking into it more.
Should work in 0.7!
Unfortunately, I think it remains 0.8.0.
My system info is
DearPyGui Version: 0.8.0 (pip install) Operating System: macOs Big Sur 11.4
To reproduce, share my code
import os
import dearpygui.dearpygui as dpg
dir_name = os.path.dirname(__file__)[:-7]
def update_file_list(sender, data):
pass
def file_upload(sender, data):
os.chdir(dir_name) # Due to working directory problem on macOS, change working directory to path of current source file
dpg.add_file_dialog(callback=update_file_list, directory_selector=True)
with dpg.font_registry():
with dpg.font(f'{dir_name}/resource/fonts/NotoSansCJKkr-DemiLight.otf', size=25, default_font=True):
dpg.add_font_range_hint(dpg.mvFontRangeHint_Default)
dpg.add_font_range_hint(dpg.mvFontRangeHint_Korean)
with dpg.window(label = 'test') as window:
dpg.set_primary_window(window, True)
with dpg.menu_bar():
with dpg.menu(label = 'Data'):
dpg.add_menu_item(label = '파일 업로드', callback=file_upload)
if __name__ == '__main__':
dpg.start_dearpygui()
I think i used "font", "font_registry" and "add_font_range_hint" to use Korean characters properly.
But the Korean characters disappeared in "add_file_dialog".
ttf or otf formats had a same issue.
Will look into it again!
Switched to high priority.
changing this
https://github.com/hoffstadt/DearPyGui/blob/bb4d8265d7044f565b956fc65a203f0b1e4ac08d/thirdparty/ImGuiFileDialog/ImGuiFileDialog.cpp#L1286
to this
auto fileName = file.path().filename().u8string();
solves the issue although we have to make the decision to fix it on our branch or do a PR on ImGuiFileDialog.
example code
with dpg.font_registry():
with dpg.font("../../assets/NotoSerifCJKjp-Medium.otf", 20, tag="custom font"):
dpg.add_font_range_hint(dpg.mvFontRangeHint_Chinese_Full)
dpg.bind_font(dpg.last_container())
def callbackhere(sender, app_data, user_data):
print("Sender: ", sender)
print("App Data: ", app_data)
with dpg.file_dialog(directory_selector=False, show=False, callback=callbackhere, id="file_dialog_id"):
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]")
with dpg.window(label="Tutorial 我是中文", width=800, height=300):
dpg.add_text("我是中文")
dpg.add_button(label="File Selector", callback=lambda: dpg.show_item("file_dialog_id"))
dpg.add_button(label="Directory Selector", callback=lambda: dpg.show_item("file_dialog_id"))
and youll have to make a text file somewhere in your directory to navigate to "test-副本.txt"

@Pcothren Thanks for your solution. When I modify it in your way, the FileDialog can display the Chinese language normally. But when I went into a folder with Chinese characters it still crashed. I guess it's because the path above the FileDialog contains Chinese charactor.
@hoffstadt Thanks for @Pcothren 's solution. When I modify it in your way, the FileDialog can display the Chinese language normally. But when I went into a folder with Chinese characters it still crashed. I guess it's because the path above the FileDialog contains Chinese charactor. Could you check it for me?Thx
@hoffstadt Thank you for reopening this issue.Is there any chance to solve this now? I am really appreciated.
I now using xdialog as an instead method.Those who has the same problem can check this. https://github.com/xMGZx/xdialog
Regarding the crashes I've added some info to #2057.
@hoffstadt Thanks for @Pcothren 's solution. When I modify it in your way, the FileDialog can display the Chinese language normally. But when I went into a folder with Chinese characters it still crashed. I guess it's because the path above the FileDialog contains Chinese charactor. Could you check it for me?Thx
MARK! Waiting for response...
@hoffstadt Thanks for @Pcothren 's solution. When I modify it in your way, the FileDialog can display the Chinese language normally. But when I went into a folder with Chinese characters it still crashed. I guess it's because the path above the FileDialog contains Chinese charactor. Could you check it for me?Thx
Waiting for solution too.