Closed dcnieho closed 1 year ago
To add, I guess you do not have to add classes like GlfwRenderer in pyimgui, but it would be nice if you could wrap the supported backend, so that you can write code very similar to C++, where i in python could call the equivalent of:
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
That also raises the question if there should perhaps be a bit more hierarchy in the lib, e.g., should imgui_bundle.imgui_internal
be imgui_bundle.imgui.internal
? Somehow cleaner to me, to have constituents of imgui as a submodule of imgui. Here it would then be imgui_bundle.imgui.implGlfw
(or impl_glfw
). Its ok of course to only support a subset of backends, but would be very nice to have. Again, final goal here is to be able to use your imgui without hello_imgui, for those wanting to make a switch and more advanced use cases as i am running into.
I can give you access to the now private repo of my program by the way, should you find that helpful.
Thanks for the detailed comments! This is the kind of feedback I appreciate.
For the moment, I am busy solving a weird windows issue (see last comments in https://github.com/pthom/imgui_bundle/issues/7).
That said, this naming is not ideal I think and we have some freedom here since in C++ you’d simply directly use ImGuiTableFlags_ScrollX. imgui.TableFlags.scroll_x would be nice, or imgui.table_flags.scroll_x to be more pythonic and have consistent change from camel to snake case. So that’s no double imgui, and no trailing underscore.
Hum, I need to ponder whether it is feasible and/or desirable. In the meantime, I added a warning in the readme, that says Warning : The API might evolve a bit during the month of November 2022. I'll remove this warning once it is more stable.
Relatedly, autocomplete works very nicely
Thanks, that was definitely one of the main goals, as well as to keep the header file documentation intact (can you see it?)
but is a little confusing as you have each enum twice (e.g. imgui.ImGuiTableFlags and imgui.ImGuiTableFlags_. The former is just an int if I understand correctly. Shall we just have the latter (ideally renamed like above)?
Hum, I think not, since users might want to do flags manipulations like:
flags: ImGuiTableFlags = ImGuiTableFlags_.flag_a | ImGuiTableFlags_.flag_b
I have no equivalent of from imgui.integrations.glfw import GlfwRenderer in imgui_bundle. I use glfw callbacks for my app, but can’t access those.
Hum, this one is not easy. For the moment, glfw is statically linked into the library. However, I am studying a possibility which would be:
Are you planning to also bundle your immvision library? I’m not exactly sure on what it does, but the description is interesting!
Definitely, and I think it will be awesome. I will keep you posted once it is ready.
but it would be nice if you could wrap the supported backend, so that you can write code very similar to C++, where i in python could call the equivalent of
ImGui_ImplOpenGL3_NewFrame()
and its companions?
Hum, I had not thought of that. Would you be willing to do some tests on this on your side?
For the tests, you can just add the bindings manually into pybind_imgui.cpp
at this location:
void py_init_module_imgui_main(py::module& m)
{
// Add your manual bindings there, before the autogenerated code
v0.6.6 is out. Wheels will be available in a few hours. However you can compile it from source right now (on the "main" branch).
Support for callbacks was added Immvision was added (although it still requires polishing). It is not enabled by default. To have it, you need to pip install from source, after having installed and configured conan
(see links in release notes)
Please tell me if it works.
Have a nice day!
Hi Pascal,
I just looked through the diffs a bit, super cool! I really look forward to trying this out, hopefully still today.
A debate: should imgui_backends
be imgui.backends
? One the one side its part of dear imgui proper, on the other side its a bit like an addon. I'm voting imgui.backends
for that first reason.
Feedback soon!
I see the enums still have an ImGui prefix. Did you run into some issue changing that?
edit removed the pip install -v .
error, worked fine now...
However, both pip install -v .
and building the visual studio project generated with CMake fail because SDL cannot be found. Errors like C:\Users\huml-dkn\Desktop\imgui_bundle\external\hello_imgui\src\hello_imgui\..\hello_imgui/hello_imgui.h(70): fatal error C1083: Cannot open include file: 'SDL_main.h': No such file or directory
Did you git submodule update —init?
Did it to be sure. It doesn't fix the pip build, still get missing include
even though \imgui_bundle\external
is populated. But i'll wait for the
wheel.
On Mon, Nov 21, 2022 at 1:51 PM Pascal Thomet @.***> wrote:
Did you git submodule update —init?
— Reply to this email directly, view it on GitHub https://github.com/pthom/imgui_bundle/issues/14#issuecomment-1322021627, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANUOGPM2Q63RH77NGQLQ7TWJNV5NANCNFSM6AAAAAASBDBRUY . You are receiving this because you authored the thread.Message ID: @.***>
Humm.. Once again, I cannot reproduce the issue here. It does work on my windows virtual machine with msvc.
I messaged you by phone, tell me if you have a few minutes
I don't right now, on the way out. Will try a fresh clone first, to be sure.
On Mon, Nov 21, 2022 at 3:58 PM Pascal Thomet @.***> wrote:
Humm.. Once again, I cannot reproduce the issue here. It does work on my windows virtual machine with msvc.
I messaged you by phone, tell me if you have a few minutes
— Reply to this email directly, view it on GitHub https://github.com/pthom/imgui_bundle/issues/14#issuecomment-1322191545, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANUOGJF7KJVZ2CFAYE3JGLWJOEZFANCNFSM6AAAAAASBDBRUY . You are receiving this because you authored the thread.Message ID: @.***>
k
hmm, with clean clone and new venv it all builds just fine. Maybe some stale cache was left after i pulled the latest version?
There is a folder named _skbuild where some compilation artifacts are stored. May be it was the culprit
Should the all in __init__.py
be more something like
__all__ = [
"imgui",
"hello_imgui",
"implot",
"imgui_color_text_edit",
"imgui_node_editor",
"imgui_knobs",
"im_file_dialog",
"imspinner",
"imgui_md",
"immvision",
"imgui_backends",
"icons_fontawesome",
"run_anon_block",
"implot_create_global_context",
"ImVec2",
"ImVec4",
"ImColor",
"FLT_MIN",
"FLT_MAX",
"__version__",
]
? seems a lot is missing. But no idea if that matters.
Further things i ran into (some repeats):
imgui_internal.ImGuiSelectableFlagsPrivate_.im_gui_selectable_flags_select_on_click
is a bit over the top, some conversion error? More generally, flag naming is still long (imgui.ImGuiTableFlags_.scroll_x
-> imgui.table_flags_.scroll_x
)from imgui_bundle import imgui as imgui
imgui.create_context()
imgui.get_io().ini_filename = str(utils.get_data_path() / "imgui.ini")
# raises: AttributeError: can't set attribute
pyimgui
is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3)
, whereas now i need to spread this out over four different statements. Would it be possible to wrap these differently (perhaps opt-in), taking advantage of Python's named variable arguments?ImFontAtlas
. Specifically, the code i am porting uses GetTexDataAsRGBA32()
, but GetTexDataAsAlpha8()
, IsBuilt()
and SetTexID()
are also missing.imgui.ImWchar
is missing. It is defined in imgui_bundle\imgui\__init__.pyi
, but trying to use it in my code nets me AttributeError: module 'imgui_bundle._imgui_bundle.imgui' has no attribute 'ImWchar'
ImFontAtlas.add_font_from_file_ttf()
has the wrong signature. The glyph_ranges argument should take a list of ints (ImWchar actually, but see previous item), but only takes a single int. So passing, for instance, [0xf0000, 0xf2000, 0]
yields:
add_font_from_file_ttf(): incompatible function arguments. The following argument types are supported:
1. (self: imgui_bundle._imgui_bundle.imgui.ImFontAtlas, filename: str, size_pixels: float, font_cfg: imgui_bundle._imgui_bundle.imgui.ImFontConfig = None, glyph_ranges: int = None) -> ImFont
6 in particular is a blocking error for me, so i had to stop further porting. I have just committed step 2 (and hey, got a bunch further!) in my private repo that you have access to, so have a look what i did.
In imgui_example_glfw_opengl3.py
, should imgui.render_platform_windows_default(glfw.make_context_current(backup_current_context))
be
imgui.render_platform_windows_default()
glfw.make_context_current(backup_current_context)
?
thats what imgui example code does
In
imgui_example_glfw_opengl3.py
, shouldimgui.render_platform_windows_default(glfw.make_context_current(backup_current_context))
beimgui.render_platform_windows_default() glfw.make_context_current(backup_current_context)
?
thats what imgui example code does
Yes, I just corrected it; but this commit is on the dev branch
Should the all in init.py be more something like...
Done in dev branch. all is here to make mypy happy.
- The flag imguiinternal.ImGuiSelectableFlagsPrivate.im_gui_selectable_flags_select_onclick is a bit over the top, some conversion error? More generally, flag naming is still long (imgui.ImGuiTableFlags.scroll_x -> imgui.tableflags.scroll_x)
Automatic renaming requires more effort than I originally thought, one has to take care and differentiate variable name, type names, function names, class and enum names when renaming, since they have all different naming conventions...
- This should work, but doesn’t: ... imgui.get_io().ini_filename = ...
Well, an automatic generation for `const char * ImGuiIO::IniFilename" is hopeless, since it provides absolutely no storage. I had to do a manual patch: https://github.com/pthom/imgui_bundle/commit/6ef5df6447eb146fc89fc392618f89c0b0be4940
- imgui has a bunch of structs that have explicit or implicit zero argument constructors. Directly wrapping these makes them less convenient to use than is possible in Python (and also c++20 for that matter). E.g. with pyimgui is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3), whereas now i need to spread this out over four different statements. Would it be possible to wrap these differently (perhaps opt-in), taking advantage of Python's named variable arguments?
I did not study this yet, although I am also interested in it.
- Some member functions are missing from ImFontAtlas. Specifically, the code i am porting uses GetTexDataAsRGBA32(), but GetTexDataAsAlpha8(),
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);
Well, well, well. Those signatures with naked pointers and double pointers are hopeless for an autogenerated binding! If needed, a manual binding will be required. But what should the signature of the python function be? Should it return a numpy ndarray? If so, what shape?
I wrote a draft commit on the dev branch that adds font_atlas_get_tex_data_as_rgba32_experimental
as a global function.
Please try it. I have no client code to test it against on my side. If it works, can you please also add a signature for the Alpha and post it as a PR?
IsBuilt() and SetTexID() are also missing.
bool IsBuilt() const { return Fonts.Size > 0 && TexReady; } // Bit ambiguous: used to detect when
void SetTexID(ImTextureID id) { TexID = id; }
Well, those functions are not marked as part of the ImGui API (they are missing the IMGUI_API marker). So, a manual binding will be required.
imgui.ImWchar is missing. It is defined in imgui_bundle\imgui__init__.pyi, but trying to use it in my code nets me AttributeError: module 'imgui_bundle._imgui_bundle.imgui' has no attribute 'ImWchar' ImFontAtlas.add_font_from_file_ttf() has the wrong signature. The glyph_ranges argument should take a list of ints (ImWchar actually, but see previous item), but only takes a single int. So passing, for instance, [0xf0000, 0xf2000, 0] yields
incompatible function arguments.
I suppose you do not really need ImWchar, but you need to be able to specify glyph ranges when calling add_font_from_file_ttf
.
I made a draft commit for this in the dev branch. Can you please test it on your side (and may post a PR where you remove the experimental suffix if all goes well).
On small question: what did you mean when you wrote
I decided to port a project from pyimgui to imgui_bundle as I would like to post it to pypi and I can’t do that with direct dependencies (like pyimgui version 2.0)
Final note for today. If you add this
// </litgen_pydef> // Autogenerated code end
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! AUTOGENERATED CODE END !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
pyClassImFontAtlas.def("add_font_from_file_ttf_experimental", fontAtlas_AddFontFromFileTTF);
at the end of pybind_imgui.cpp, then you get an additional method for ImFontAtlas in python.
And if all goes well it might someday be a manual replacement of the autogenerated one.
On small question: what did you mean when you wrote
I decided to port a project from pyimgui to imgui_bundle as I would like to post it to pypi and I can’t do that with direct dependencies (like pyimgui version 2.0)
PyPI doesn't accept my current dependencies:
HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/ Invalid value for requires_dist. Error: Can't have direct dependency: 'PyOpenGL-accelerate @ git+https://github.com/mcfletch/pyopengl.git@227f9c66976d9f5dadf62b9a97 e6beaec84831ca#subdirectory=accelerate'
And same would happen for pyimgui as i want to use the 2.0 dev branch, which isn't a package on PyPI.
My port is now available publicly at https://github.com/dcnieho/glassesValidator/tree/imgui_bundle
Thanks for all the work you did with my comments! I'll have a good look at them in the next few days.
Message ID: @.***>
My port is now available publicly at https://github.com/dcnieho/glassesValidator/tree/imgui_bundle
Nice 🚀
Thanks for all the work you did with my comments! I'll have a good look at them in the next few days.
I was happy to help. I look forward to reading your feedback
Some other elements and questions:
(If I do rename the project, I will not remove the existing packages on pypi if you need them, of course, I will simply add a new one and mention the renaming in the readme)
immvision is available, as well as a first version of the functions composition I showed. Beware, the function composition API is highly experimental and may be moved into a different repo later (it is in the demo folder). I did a quick demo here: https://youtu.be/TLo0vNm0XF8 (sorry for the bad sound)
I'm currently working on generating named constructors at the moment, but it goes quite deep in the generator architecture, so it takes some time.
- About ImGuiBundle name: this is a name I selected without too much thinking of it. However, I fear it that it does not sound nice; and may be I should find another one. I though of names like "livegui", "imlive", "imlife", "immapp" (for immediate app), or the more controversial "immgui" (where the double m stands for immediate, but would remind of my module immvision). My current preference goes for immapp. What do you think?
(If I do rename the project, I will not remove the existing packages on pypi if you need them, of course, I will simply add a new one and mention the renaming in the readme)
I think the current name is best. It is clear and it contains imgui, which is the key part. If i see the name, i think "ah, imgui, and more". Isn't that just what you want? My vote is don't change.
- immvision is available, as well as a first version of the functions composition I showed. Beware, the function composition API is highly experimental and may be moved into a different repo later (it is in the demo folder). I did a quick demo here: https://youtu.be/TLo0vNm0XF8 (sorry for the bad sound)
This is so very cool!
- I'm currently working on generating named constructors at the moment, but it goes quite deep in the generator architecture, so it takes some time.
Thank you, that will be very nice to have.
imgui has a bunch of structs that have explicit or implicit zero argument constructors. Directly wrapping these makes them less convenient to use than is possible in Python (and also c++20 for that matter). E.g. with pyimgui is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3), whereas now i need to spread this out over four different statements. Would it be possible to wrap these differently (perhaps opt-in), taking advantage of Python's named variable arguments?
I will add named constructors when there is no user defined constructor.
However, when there is one such as for ImFontConfig, it is much too dangerous to provide a named constructor:
For example, let's look and ImFontConfig default constructor:
ImFontConfig::ImFontConfig()
{
memset(this, 0, sizeof(*this));
FontDataOwnedByAtlas = true;
OversampleH = 3; // FIXME: 2 may be a better default?
OversampleV = 1;
GlyphMaxAdvanceX = FLT_MAX;
RasterizerMultiply = 1.0f;
EllipsisChar = (ImWchar)-1;
}
==> If we create a named constructor that use default value for all params types, we end-up overwriting the carefully selected default values. I was bitten hard by this, here and also in the node editor. Note: the result would be the same if C++20 allowed to used designated designated initializers in the presence of a user defined ctor: we would end-up destroying the initial values.
I know I could may be investigate params being Optional[...], but I decided not to go into it. The generation is already complex and does enough on this side IMHO.
The flag imguiinternal.ImGuiSelectableFlagsPrivate.im_gui_selectable_flags_select_on_click is a bit over the top, some conversion error?
Hum, this is due to a trick in imgui code: ImGuiSelectableFlagsSelectOnClick is not a member of `enum ImGuiSelectableFlags` it is a member of a kind of "extension" defined in imgui_internal.h which defines another enum, but uses the same names prefix (this is legal in C++, since enum value are ints). This is too much of a hack, I will not be able to adapt the generator to this.
imgui.h says:
// Flags for ImGui::Selectable()
enum ImGuiSelectableFlags_
{
ImGuiSelectableFlags_None = 0,
ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window
ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column)
ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text
ImGuiSelectableFlags_AllowItemOverlap = 1 << 4 // (WIP) Hit testing to allow subsequent widgets to overlap this one
};
and imgui_internal says:
// Extend ImGuiSelectableFlags_
enum ImGuiSelectableFlagsPrivate_
{
// NB: need to be in sync with last value of ImGuiSelectableFlags_
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
ImGuiSelectableFlags_SelectOnNav = 1 << 21, // (WIP) Auto-select when moved into. This is not exposed in public API as to handle multi-select and modifiers we will need user to explicitly control focus scope. May be replaced with a BeginSelection() API.
ImGuiSelectableFlags_SelectOnClick = 1 << 22, // Override button behavior to react on Click (default is Click+Release)
ImGuiSelectableFlags_SelectOnRelease = 1 << 23, // Override button behavior to react on Release (default is Click+Release)
ImGuiSelectableFlags_SpanAvailWidth = 1 << 24, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
ImGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 25, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 26, // Set Nav/Focus ID on mouse hover (used by MenuItem)
ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 27 // Disable padding each side with ItemSpacing * 0.5f
};
More generally, flag naming is still long (imgui.ImGuiTableFlags_.scroll_x -> imgui.tableflags.scroll_x)
This is solved with:
This should work, but doesn’t:
imgui.get_io().ini_filename = str(utils.get_data_path() / "imgui.ini")
raises: AttributeError: can't set attribute
Solved inn 6ef5df64 : added imgui.set_io_ini_filename() & imgui.set_io_log_filename()
imgui has a bunch of structs that have explicit or implicit zero argument constructors. Directly wrapping these makes them less convenient to use than is possible in Python (and also c++20 for that matter). E.g. with pyimgui is can do config = imgui.ImFontConfig(merge_mode=True, oversample_h=3, oversample_v=3), whereas now i need to spread this out over four different statements. Would it be possible to wrap these differently (perhaps opt-in), taking advantage of Python's named variable arguments?
In f6ae2072, I added named constructors when there is no user defined constructor. This adds lots of named constructors.
However, when there is a user defined constructor such as for ImFontConfig, it is much too dangerous to provide a named constructor.
For example, let's look and ImFontConfig default constructor:
ImFontConfig::ImFontConfig()
{
memset(this, 0, sizeof(*this));
FontDataOwnedByAtlas = true;
OversampleH = 3; // FIXME: 2 may be a better default?
OversampleV = 1;
GlyphMaxAdvanceX = FLT_MAX;
RasterizerMultiply = 1.0f;
EllipsisChar = (ImWchar)-1;
}
==> If we create a named constructor that use default value for all params types, we end-up overwriting the carefully selected default values. Note: the result would be the same if C++20 allowed to used designated designated initializers in the presence of a user defined ctor: we would end-up destroying the initial values.
Some member functions are missing from ImFontAtlas. Specifically, the code i am porting uses GetTexDataAsRGBA32(), but GetTexDataAsAlpha8(), IsBuilt() and SetTexID() are also missing. imgui.ImWchar is missing. It is defined in imgui_bundle\imgui__init__.pyi, but trying to use it in my code nets me AttributeError: module 'imgui_bundle._imgui_bundle.imgui' has no attribute 'ImWchar' ImFontAtlas.add_font_from_file_ttf() has the wrong signature. The glyph_ranges argument should take a list of ints (ImWchar actually, but see previous item), but only takes a single int. IsBuilt() and SetTexID() are also missing.
From these remarks I suppose you want to be able to load custom font, but you actually don't care about IsBuilt, SetTexID, GetTexDataAsAlpha8 etc.
Support for loading custom fonts was added: see fa91994c and 23871b15
thanks very much for getting all these things done, i can't wait to test them out! I skimmed over the diffs and left one comment, hope you got notified of that. I hope to find a bit of time this weekend to take it all for a spin. Would you be willing and able to make a new release, say, on friday as that would make it greatly easier for me to test it all out if i can just pip install form pypi?
Thanks again!
Message ID: @.***>
Hi,
I am fighting with the CI at the time (wheels build fail in the CI). So, to test the version you will have to checkout the dev verison and pip install from sources.
If you want support for immvision, you need to install and setup conan
pip install .
is failing for me on the dev branch. I get errors like this (different executables, same error) each time i try, also with a completely fresh clone. I am not sure why glfw examples and tests are being built at all for a pip install.
[120/235] Building C object external\glfw\tests\CMakeFiles\glfwinfo.dir\glfwinfo.c.obj
[121/235] Building C object external\glfw\tests\CMakeFiles\iconify.dir\__\deps\glad_gl.c.obj
[122/235] Building CXX object CMakeFiles\_imgui_bundle.dir\bindings\pybind_imgui_node_editor.cpp.obj
[123/235] Linking C executable external\glfw\examples\offscreen.exe
[124/235] Linking C executable external\glfw\examples\heightmap.exe
[125/235] Linking C executable external\glfw\examples\gears.exe
FAILED: external/glfw/examples/gears.exe
cmd.exe /C "cd . && C:\Users\huml-dkn\AppData\Local\Temp\pip-build-env-e7g00p98\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=external\glfw\examples\CMakeFiles\gears.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe --manifests -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx86\x64\link.exe /nologo external\glfw\examples\CMakeFiles\gears.dir\gears.c.obj external\glfw\examples\CMakeFiles\gears.dir\glfw.rc.res external\glfw\examples\CMakeFiles\gears.dir\__\deps\glad_gl.c.obj /out:external\glfw\examples\gears.exe /implib:external\glfw\examples\gears.lib /pdb:external\glfw\examples\gears.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:windows /ENTRY:mainCRTStartup external\glfw\src\glfw3dll.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
MT: command "C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe /nologo /manifest external\glfw\examples\gears.exe.manifest /outputresource:external\glfw\examples\gears.exe;#1" failed (exit code 0x1f) with the following output:
mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "external\glfw\examples\gears.exe". The process cannot access the file because it is being used by another process.
[126/235] Linking C executable external\glfw\tests\events.exe
FAILED: external/glfw/tests/events.exe
cmd.exe /C "cd . && C:\Users\huml-dkn\AppData\Local\Temp\pip-build-env-e7g00p98\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=external\glfw\tests\CMakeFiles\events.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe --manifests -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx86\x64\link.exe /nologo external\glfw\tests\CMakeFiles\events.dir\events.c.obj external\glfw\tests\CMakeFiles\events.dir\__\deps\getopt.c.obj external\glfw\tests\CMakeFiles\events.dir\__\deps\glad_gl.c.obj /out:external\glfw\tests\events.exe /implib:external\glfw\tests\events.lib /pdb:external\glfw\tests\events.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console external\glfw\src\glfw3dll.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
MT: command "C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x86\mt.exe /nologo /manifest external\glfw\tests\events.exe.manifest /outputresource:external\glfw\tests\events.exe;#1" failed (exit code 0x1f) with the following output:
mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "external\glfw\tests\events.exe". The process cannot access the file because it is being used by another process.
[127/235] Linking C executable external\glfw\examples\boing.exe
FAILED: external/glfw/examples/boing.exe
......
Could you try adding this to cmake/add_hello_imgui.cmake:
# 2. Build glfw
if (IMGUI_BUNDLE_BUILD_PYTHON)
# Build glfw as a *shared* library:
# this is required if we want to be able to use python bindings
# for glfw, using https://github.com/FlorianRhiem/pyGLFW
# Note: the rpath is set by a call to
# lg_target_set_rpath(${python_native_module_name} ".")
# (inside add_imgui_bundle_bindings)
set(BUILD_SHARED_LIBS ON)
set(GLFW_BUILD_EXAMPLES OFF) # Add these lines
set(GLFW_BUILD_TESTS OFF)
set(GLFW_BUILD_DOCS OFF)
set(GLFW_INSTALL OFF)
add_subdirectory(external/glfw)
And tell me if it helps?
CMaking and building with visual studio does work fine, only functions_composition_graph
fails, because i do not have opencv available (will go there later, my first bridge to cross is getting that glassesValidator app ported, and that doesn't require immvision)
observations:
demo_guizmo_sequencer
GUI is a mess at hidpi, placement is not taking some scaling into account and everything overlaps or e.g. input boxes for frame atop the screen are too smalldemo_tex_inspect
: it gives me a window that is vertically so big it doesn't fit on my screen. It seems to work otherwise, but when running i do get an error:
ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile fragment shader!
ERROR: 1:23: 'function' : is removed in Forward Compatible context texture2D
ERROR: 1:23: 'texture2D' : no matching overloaded function found (using implicit conversion)
ERROR: 1:23: 'texture2D' : function is not known
ERROR: 1:23: '+' : wrong operand types no operation '+' exists that takes a left-hand operand of type '4X4 matrix of highp float' and a right operand of type 'uniform 4-component vector of highp float' (or there is no acceptable conversion)
ERROR: 1:23: '=' : cannot convert from '4X4 matrix of highp float' to '4-component vector of highp float'
ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link shader program! (with GLSL '#version 130
')
Attached fragment shader is not compiled.
Thanks!
demo_guizmo_sequencer GUI is a mess at hidpi, placement is not taking some scaling into account and everything overlaps or e.g. input boxes for frame atop the screen are too small
Argh... I hope this is not in the library code. If so, I might disable the sequencer for a while.
also some hidpi problem with haiku heart: the height of the plot window is too small, making it very horizontally stretched. Also, when making the window wider, the plot stretches horizontally with the window, but not vertically even though there is plenty of space, making it even more horizontally stretched out.
This one should be easy. I just need to find a way to change the implot's plot size
demo_tex_inspect: it gives me a window that is vertically so big it doesn't fit on my screen. It seems to work otherwise, but when running i do get an error:
I had a very similar same shader error when using imgui_tex_inspect on my Mac. I thought this was a mac only issue. Either I disable it or I contact the library author and hope he has a solution.
Did you try demo_guizmo (the one with the 3D gizmo manipulator). Does it work?
Please keep me informed about the pip building process :-)
Could you try adding this to cmake/add_hello_imgui.cmake:
# 2. Build glfw if (IMGUI_BUNDLE_BUILD_PYTHON) # Build glfw as a *shared* library: # this is required if we want to be able to use python bindings # for glfw, using https://github.com/FlorianRhiem/pyGLFW # Note: the rpath is set by a call to # lg_target_set_rpath(${python_native_module_name} ".") # (inside add_imgui_bundle_bindings) set(BUILD_SHARED_LIBS ON) set(GLFW_BUILD_EXAMPLES OFF) # Add these lines set(GLFW_BUILD_TESTS OFF) set(GLFW_BUILD_DOCS OFF) set(GLFW_INSTALL OFF) add_subdirectory(external/glfw)
And tell me if it helps?
That works! I have now run imgui_bundle_demo
after a successful pip install. observations:
imgui_example_glfw_opengl3
works, but opens a window that is not DPI scaled, everything is tiny. Not sure if you want to fix that. It also opens a popup with app code that i can't close again, only collapseI had a very similar same shader error when using imgui_tex_inspect on my Mac. I thought this was a mac only issue. Either I disable it or I contact the library author and hope he has a solution.
Well it does work and is nice to have (i see a popup indicating pixel color under my mouse), so despite shader error keep it? By the way, this is not in the pip-installed imgui_bundle_demo, right?
Did you try demo_guizmo (the one with the 3D gizmo manipulator). Does it work?
Yes, works fine. Takes a little (tiny) bit of getting used to, but that's imguizmo's UI itself.
Hopefully today i can try continuing my port, we should be very close if not all the way there now :)
Ah, i just see that something while running the imgui_bundle_demo also put ImGuiMd::OnOpenLink_Default url "images/world.jpg" should start with http!
on the command line. Perhaps you know what triggered that.
I ran into the next problem when porting my app. I manually modify the default style by modifying the values in the ImGuiStyle::Colors (imgui.get_style().colors
in pyimgui). This doesn't seem to exist in your port. How do i set specific colors/modify my current style?
And what would make the library a bit nicer to use would be some implicit conversions. For instance, i had imgui.get_style().item_spacing = (5,5)
which worked fine with pyimgui, but now i need to assign a imgui.ImVec2(5,5)
instead. It would be nice if such vectors would be transparently handled so users don't have to sprinkle ImVec2
s all over the code. I guess i'll run into a similar thing soon with colors. Right now my pyimgui code is imgui.get_style().colors[imgui.Col_.modal_window_dim_bg] = (0, 0, 0, 0.5)
, I guess the RHS will also be affected by need for some explicit construction of an ImVec4?
I wanted to test font_atlas_get_tex_data_as_rgba32
but i notice that it is only present (commented out) in the .pyi
file. Have you nixed it?
I ran into the next problem when porting my app. I manually modify the default style by modifying the values in the ImGuiStyle::Colors (
imgui.get_style().colors
in pyimgui). This doesn't seem to exist in your port. How do i set specific colors/modify my current style?
Same for KeysDown (should be imgui.get_io().keys_down
) and a bunch of other arrays in the ImGuiIO
struct. As these have known size, i guess there is a bigger chance they may be wrappable?
Another thing i ran into, might be user error. I have an image i want to draw. It is uploaded through OpenGL and i have a texture id. I then call draw_list.add_image_rounded(texture_id, pos, pos2, *args, flags=flags, **kwargs)
and get the following error
TypeError: add_image_rounded(): incompatible function arguments. The following argument types are supported:
1. (self: imgui_bundle._imgui_bundle.imgui.ImDrawList, user_texture_id: capsule, p_min: imgui_bundle._imgui_bundle.imgui.ImVec2, p_max: imgui_bundle._imgui_bundle.imgui.ImVec2, uv_min: imgui_bundle._imgui_bundle.imgui.ImVec2, uv_max: imgui_bundle._imgui_bundle.imgui.ImVec2, col: int, rounding: float, flags: int = 0) -> None
Invoked with: <imgui_bundle._imgui_bundle.imgui.ImDrawList object at 0x000001973685C630>, 2, <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x000001973685C0F0>, <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x000001973685C1B0>; kwargs: flags=<ImDrawFlags_.round_corners_all: 240>, rounding=6.0
Removing *args
from the call (its an empty tuple) and explicitly naming the other two arguments as p_min
and p_max
doesn't change this, same incompatible arguments error.
type(self.texture_id)
returns <class 'numpy.uintc'>
, as is (apparently) returned by gl.glGenTextures(1)
(import OpenGL.GL as gl
)
I think ImGuiTableSortSpecs
isn't wrapped correctly. specs
should be a list of TableColumnSortSpecs
, not a single one. My pyimgui code has for sort_spec in sort_specs_in.specs
, where sort_specs_in
is a ImGuiTableSortSpecs
gotten from imgui.table_get_sort_specs()
.
Ok, last comment for now. Nice work man on the wrapper, i got my first windows to show even though not everything works yet. Anyway, what i run in now is that there are two versions of ´imgui.selectable´ (and i guess there are more like this one) where one takes a bool and returns a bool, and the other takes a pointer to bool and returns a tuple of two bools. Here i made it error so you can see the signatures:
TypeError: selectable(): incompatible function arguments. The following argument types are supported:
1. (label: str, selected: bool = False, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EAB525F0>) -> bool
2. (label: str, p_selected: bool, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EA6D2770>) -> Tuple[bool, bool]
I want to use the latter, but get the former. Even though both are defined in the generated pybind code. I guess that is because their python function syntax is identical? Both just take a bool. Perhaps this is user error. How do i call the latter one with signature returning -> Tuple[bool, bool]
?
By the way, it would be nice to provide __str__()
for imgui.ImVec2
and co, would make the above output much nicer. And given how much ImVec2 is used and returned throughout the code, much more legible and usable.
Well, some more:
ini = imgui.save_ini_settings_to_memory()
fails even though the one input argument is optional:
TypeError: save_ini_settings_to_memory(): incompatible function arguments. The following argument types are supported:
1. (out_ini_size: int = None) -> str
Invoked with:
calling it with e.g. 1000 as argument works fine.
And in my port i don't get font loading to work. That is, my icons show up as question marks. I have tried adding
imgui_backends.opengl3_destroy_fonts_texture()
imgui_backends.opengl3_create_fonts_texture()
after the calls to imgui.font_atlas_add_font_from_file_ttf
which i think should be needed because else the new font texture doesn't get built (not needed in your demo though, as you call these before the very first frame is rendered, and fonts are set up in ImGui_ImplOpenGL3_CreateDeviceObjects()
which is called the first frame). So adding those calls didn't help. Guess i am doing something wrong as your demo does work. But what i have now worked with pyimgui, so i am wondering what the difference/my oversight is...
Ok, last comment for now. Nice work man on the wrapper, i got my first windows to show even though not everything works yet. Anyway, what i run in now is that there are two versions of ´imgui.selectable´ (and i guess there are more like this one) where one takes a bool and returns a bool, and the other takes a pointer to bool and returns a tuple of two bools. Here i made it error so you can see the signatures:
TypeError: selectable(): incompatible function arguments. The following argument types are supported: 1. (label: str, selected: bool = False, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EAB525F0>) -> bool 2. (label: str, p_selected: bool, flags: int = 0, size: imgui_bundle._imgui_bundle.imgui.ImVec2 = <imgui_bundle._imgui_bundle.imgui.ImVec2 object at 0x00000285EA6D2770>) -> Tuple[bool, bool]
I want to use the latter, but get the former. Even though both are defined in the generated pybind code. I guess that is because their python function syntax is identical? Both just take a bool. Perhaps this is user error. How do i call the latter one with signature returning
-> Tuple[bool, bool]
?
We had a closely related discussion about this before, IIRC. The two functions are redundant for the python binding, so we have to choose one style. for pyimgui compatibility (and because i know of no other good reason) and additional flexibility (this form is more informative) i vote to only expose version 2. I'm not sure if this case can be automatically detected (that two different c++ function lead to a python function with the same arguments) and the choice automated.
By the way, I'll go through all this and make separate issues of each thing, so its possible to track them. Right now its become a mess thanks to me.
I think i have now poored all this into separate issues. Hope i didn't miss anything. Thanks again for the hard work, i'm excited where this is heading!
Thanks for taking the time to separate this into issues, this is helpful!
I will answer in those
Thanks for looking at all the requests and your offers of help. I hope to look at them later today! Else probably friday or latest the weekend.
Message ID: @.***>
I get a whole bunch of compile errors right now, despite a completely clean
check out of dev. some excerpts of what pip install .
gives me (rather
baffling):
FAILED:
CMakeFiles/imgui_color_text_edit.dir/external/ImGuiColorTextEdit/TextEditor.cpp.obj
C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1434~1.319\bin\Hostx86\x64\cl.exe
/nologo /TP -DIMGUI_BUNDLE_BUILD_PYTHON -DIMGUI_BUNDLE_PYTHON_API
-DIMGUI_USER_CONFIG=\"C:/Users/huml-dkn/Desktop/imgui_bundle/cmake/imgui_bundle_config.h\"
-DImTextureID=int
-IC:\Users\huml-dkn\Desktop\imgui_bundle\external\ImGuiColorTextEdit\..
-IC:\Users\huml-dkn\Desktop\imgui_bundle\cmake\..\external
-IC:\Users\huml-dkn\Desktop\imgui_bundle\external\imgui /DWIN32 /D_WINDOWS
/GR /EHsc /O2 /Ob2 /DNDEBUG -MD -std:c++17 /showIncludes
/FoCMakeFiles\imgui_color_text_edit.dir\external\ImGuiColorTextEdit\TextEditor.cpp.obj
/FdCMakeFiles\imgui_color_text_edit.dir\imgui_color_text_edit.pdb /FS -c
C:\Users\huml-dkn\Desktop\imgui_bundle\external\ImGuiColorTextEdit\TextEditor.cpp
C:\Users\huml-dkn\Desktop\imgui_bundle\external\ImGuiColorTextEdit\TextEditor.h(75):
error C3861: 'assert': identifier not found
C:\Users\huml-dkn\Desktop\imgui_bundle\external\ImGuiColorTextEdit\TextEditor.cpp(228):
error C3861: 'assert': identifier not found
FAILED: CMakeFiles/imgui_bundle.dir/src/imgui_bundle/imgui_bundle.cpp.obj
[...]
C:\Users\huml-dkn\Desktop\imgui_bundle\external\imgui\imgui.h(3067):
warning C4297: 'ImGuiViewport::~ImGuiViewport': function assumed not to
throw an exception but does
C:\Users\huml-dkn\Desktop\imgui_bundle\external\imgui\imgui.h(3067): note:
destructor or deallocator has a (possibly implicit) non-throwing exception
specification
C:\Users\huml-dkn\Desktop\imgui_bundle\src\imgui_bundle\imgui_bundle.cpp(28):
error C2440: '=': cannot convert from 'int' to 'void *'
C:\Users\huml-dkn\Desktop\imgui_bundle\src\imgui_bundle\imgui_bundle.cpp(28):
note: Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or parenthesized function-style cast
FAILED: CMakeFiles/imgui_md.dir/external/imgui_md/imgui_md/imgui_md.cpp.obj
C:\Users\huml-dkn\Desktop\imgui_bundle\external\imgui_md\imgui_md\imgui_md.cpp(699):
error C3861: 'assert': identifier not found
Will try again later.
On Wed, Dec 7, 2022 at 9:01 AM Diederick C. Niehorster @.***> wrote:
Thanks for looking at all the requests and your offers of help. I hope to look at them later today! Else probably friday or latest the weekend.
Message ID: @.***>
It should be solved now. I don't know why suddenly this include became necessary, but it is cleaner with it.
This is using pip-installed v0.6.5
I decided to port a project from pyimgui to imgui_bundle as I would like to post it to pypi and I can’t do that with direct dependencies (like pyimgui version 2.0).
So, some observations from porting this program (not yet available online).
First it tried to simple replace
import imgui
withfrom pyimgui to imgui_bundle.imgui
. Obviously a bunch of code adjustments are needed, mostly for the different flags (e.g.imgui.TABLE_SCROLL_X
->imgui.ImGuiTableFlags_.scroll_x
). These all get a bit long, even if they are very tight to the original imgui header. That said, this naming is not ideal I think and we have some freedom here since in C++ you’d simply directly useImGuiTableFlags_ScrollX
.imgui.TableFlags.scroll_x
would be nice, orimgui.table_flags.scroll_x
to be more pythonic and have consistent change from camel to snake case. So that’s no double imgui, and no trailing underscore.Relatedly, autocomplete works very nicely, but is a little confusing as you have each enum twice (e.g.
imgui.ImGuiTableFlags
andimgui.ImGuiTableFlags_
. The former is just an int if I understand correctly. Shall we just have the latter (ideally renamed like above)? My biggest problem: how do I use imgui by itself? Or is that not the idea? I have no equivalent offrom imgui.integrations.glfw import GlfwRenderer
in imgui_bundle. Is the idea that you must use the hello_imgui wrapper? That makes it much less of a drop-in replacement. And I think I cannot use that, because I use glfw callbacks for my app, but can’t access those, I think? I have set up:And other interaction with glfw (such as window scaling when moving between dpi monitors). Can I set these up? How?
Does imgui_bundle also expose its opengl binding? Can I port
import OpenGL.GL as gl
to something in the imgui_bundle, or is that out of scope? I’m asking as my code for instance does:Some small observations:
imgui_internal.ImGuiSelectableFlagsPrivate_.im_gui_selectable_flags_select_on_click
is a bit over the top, some conversion error?FLT_MIN
(pyimgui:imgui.FLOAT_MIN
) is unavailable. Is ok, can be replaced withnp.finfo('single').tiny
(untested), but seems a bit heavy to require numpy for just that. That pyimgui provides imgui.FLOAT_MIN is a good solution I think. Users may well get this wrong otherwise, since a python float is a double.