Closed bgribble closed 7 months ago
I use get_style()
and has no problem, but you will need to set x
, y
, z
, w
one by one in python as no API binding for python for direct assignment:
padding_list = [1.0,1.0,1.0,1.0]
style = ed.get_style()
style.node_padding.x = padding_list[0]
style.node_padding.y = padding_list[1]
style.node_padding.z = padding_list[2]
style.node_padding.w = padding_list[3]
Hello,
node_padding is a ImVec4, thus you should use
ed.push_style_var(ed.StyleVar.node_padding, ImVec4(1, 1, 1, 1))
or
style = ed.get_style()
style.node_padding = ImVec4(8, 8, 8, 8)
Thanks @pthom , if ImVec4
is prefered. I would recommend update some of the imgui API (example below) from List[float]
to ImVec4
. Otherwise conversion between them is required, that would be redundant:
@hugle: This example is different. Here you are trying to edit a list of float. In the ImGui code, the declaration is as below:
bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags)
It is true that in some cases you can see C++ code like this
ImGui::DragFloat4(const char* label, &someImVec4Value)
However, this uses the fact that the memory layout of ImVec4 and float[4] happens to be the same in C and C++. There is no such thing in Python, and IMHO this is for the better
Attempting to set any value for
StyleVar.node_padding
throws an error from a null pointer assert.This may be because the enum value for
node_padding
is 0?