GithubHelp home page GithubHelp logo

Comments (7)

swistakm avatar swistakm commented on July 22, 2024 2

It is definitely a good idea to have the extra functions and utilities that do not exist in C++ API in separate module. It will improve code organization and help in documenting it properly. We already have few of such functions e.g. font, styled, istyled, vertex_buffer_*.

Still I would not care much about developer confusion at this moment. I think that benefits of having them importable from one place instead of multiple submodules outweights the cons. This is also in spirit of the one-header libraries like ImGui itself.

My idea is to have at least two Cython modules:

  • core.pyx - for everything that exists directly in core C++ API
  • extras.pyx - for anything extra (python-specific helpers, context managers) that is not part of C++ API

But combine them in __init__.py in following way:

from imgui.core import *  # noqa
from imgui import core
from imgui.extras import *  # noqa
from imgui import extras

That way we will help to maintain backwards compatibility, make possible for some developers to be very specific about core/extras usage, and also make possible for other developers to have very simpe one-import code.

from pyimgui.

overdev avatar overdev commented on July 22, 2024

Off-topic: Good to have you back. I was beginning to think you gave up on pyimgui.

This happens only in pyimgui? I mean, it does not occur in C++'s imgui?

from pyimgui.

swistakm avatar swistakm commented on July 22, 2024

Oh, I didn't gave up on this project :). I simply had a very intense period at work so had to put few open source projects on hiatus. But I'm trying to get back to them.

Regarding the issue. I'm pretty sure this happens in barre C++ ImGui too because the this is the way how most immediate-mode GUIs are implemented i.e. every widget get's it's unique and (usually) explicit identifier. In this case the labels are used as identifiers. Usually this is acceptable simplification because it isn't common to have multiple same-labelled widgets in the same context (window, modal etc.)

from pyimgui.

pconerly avatar pconerly commented on July 22, 2024

I like the idea of imgui.scope, but I wonder if we should put it into a different namespace? Having the python imgui module be a combination of imgui-cpp methods and pyimgui helpers might be confusing for coders?

Maybe imgui.helpers.scope ? or imgui.py_scope? I don't know; naming is hard.

from pyimgui.

602p avatar 602p commented on July 22, 2024

I've submitted a PR for a patch to expose PushID and PopID and a context wrapper as discussed.

It's also possible to append some unique text to a name after ## to make ids not collide. E.g. imgui.button('foo##1') and imgui.button('foo##2') don't collide, but are both displayed as foo.

from pyimgui.

swistakm avatar swistakm commented on July 22, 2024

Closing this as we already have imgui.extra submodule and I have added new scoped context manager.

from pyimgui.

swistakm avatar swistakm commented on July 22, 2024

Feature available in 1.2.0.

from pyimgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.