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.63k stars 669 forks source link

Background of the NodeEditor does not change #2234

Closed Den4ina closed 7 months ago

Den4ina commented 7 months ago

Hello, dear developers. I'm trying to make a light theme for my app. I managed to change the colors for all the elements except the node editor. I am using this code to change the background of the node editor:

with dpg.theme() as ne_white_theme:
            with dpg.theme_component(dpg.mvAll):
                dpg.add_theme_color(dpg.mvNodeCol_GridBackground, (255, 255, 255))

However, it doesn't work for me. I can change the color of text, windows, buttons and everything else, but the background of the node editor does not change.

When using the built-in style editing window, everything works and the color changes. However, I can't make it out of the code. Please help me figure out what I'm doing wrong

v-ein commented 7 months ago

How do you use your ne_white_theme then?

v-ein commented 7 months ago

Do you bind it directly to the node editor?

Den4ina commented 7 months ago

Do you bind it directly to the node editor?

I've tried: dpg.bind_theme(ne_white_theme)

And also: dpg.bind_item_theme(my_node_editor, ne_white_theme)

v-ein commented 7 months ago

That's interesting. The first line (bind_theme) should have worked.

Try to bind it to the parent widget of the node editor.

v-ein commented 7 months ago

Hmm... no, scratch that. It doesn't work.

v-ein commented 7 months ago

Okay, here's what you're missing: category=dpg.mvThemeCat_Nodes.

dpg.add_theme_color(dpg.mvNodeCol_GridBackground, (255, 255, 255), category=dpg.mvThemeCat_Nodes)

With that, it will work in bind_theme, and will also work if you do bind_item_theme on the parent of the node editor. It will not work on the node editor itself, because for some reason node editor ignores the theme bound to it.

v-ein commented 7 months ago

I think this ticket can be kept open so that somebody can add theme support to node editor itself. Or developers will close it if needed.

Den4ina commented 7 months ago

Okay, here's what you're missing: category=dpg.mvThemeCat_Nodes.

dpg.add_theme_color(dpg.mvNodeCol_GridBackground, (255, 255, 255), category=dpg.mvThemeCat_Nodes)

With that, it will work in bind_theme, and will also work if you do bind_item_theme on the parent of the node editor. It will not work on the node editor itself, because for some reason node editor ignores the theme bound to it.

Oh, it really worked for me. You need to understand how these categories work... for some reason, it's hard for me to understand this. Thank you very much! It really helped in my case.