hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
12.88k stars 671 forks source link

`add_file_extension` does not apply `color` when using multiple file types #1493

Open west-rynes opened 2 years ago

west-rynes commented 2 years ago

Version of Dear PyGui

DPG Version: 1.1.3 OS: macOS-10.15.7-x86_64-i386-64bit

My Issue/Question

When using the add_file_extension, the color argument only appears to work if the basic single extension method is used. If multiple extensions are supplied in the form shown on the tutorial https://dearpygui.readthedocs.io/en/latest/documentation/file-directory-selector.html it does not work as expected.

    dpg.add_file_extension(".py", color=(0, 255, 0, 255), custom_text="[Python]") # Works applies green color
    dpg.add_file_extension("Text Files (*.txt *.md *.rtf){.txt,.md,.rtf}", color=(255, 0, 0, 255)) # BUG red color does not apply to these, appear white

Screenshots/Video

Text files should be colored red in below screen shot:

file_picker_bug

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

import dearpygui

import platform
print(f"DPG Version: {dearpygui.__version__}")
print(f"OS: {platform.platform()}")

dpg.create_context()

def make_files():
    files = [
        'a.txt', # These should be red but appear white
        'b.txt',
        'a.md',
        'b.md',
        'a.rtf',
        'a.py'
        'b.py',
        'a.h',
        'b.h',
        'a.xyz',
        'b.xyz',
        'c.xyz', 

    ]
    for fname in files:
        with open(fname, 'w') as f:
            pass

def callback(sender, app_data, user_data):
    print("Sender: ", sender)
    print("App Data: ", app_data)

with dpg.file_dialog(directory_selector=False, show=False, callback=callback, id="file_dialog_id"):
    dpg.add_file_extension(".*", color=(255,255,0,255)) # BUG? default color does not appear to work, appear white
    dpg.add_file_extension("", color=(150, 255, 150, 128))
    dpg.add_file_extension("Text Files (*.txt *.md *.rtf){.txt,.md,.rtf}", color=(255, 0, 0, 255)) # BUG? red color does not apply to these, appear white
    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_button(label="Makes Sample Files", callback=make_files)
    dpg.add_button(label="File Selector", callback=lambda: dpg.show_item("file_dialog_id"))

dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
hoffstadt commented 2 years ago

Unfortunately, looking at the ImGuiFileDialog source, it appears that color only works for individual filters. We will do a pull request on the library and add this in.

west-rynes commented 2 years ago

Thanks for looking into it.

aiekick commented 1 year ago

Hello,

im working on a rewrite of filtering / coloring / styling for using advanced regex filtering.

maybe this will solve your issues :)

rageSpin commented 1 year ago

also custom_text doesn't work :(

pashog commented 11 months ago

Any progress on this?

aiekick commented 11 months ago

the advanced regex filtering is implemented on ImGuiFileDialog

zipy124 commented 1 month ago

The example shown in the Demo still does not display the colors.