Coder Social home page Coder Social logo

pyimgui-colortextedit's Introduction

pyimgui-colortextedit

A Python wrapper for ColorTextEdit widget

Requirements

  • Cython >= 0.29.21

Note

  • We are not using the latest versions of ColorTextEdit and imgui since this wrapper is targeted to be compatiable with pyimgui which is still working on imgui v1.65.

  • Most of the implementation in this wrapper follow the style/layout of pyimgui, but there are still something worth noting:

    • Since this wrapper is not developed directly under pyimgui, some internal states used by imgui won't be shared between the dll/so files built from pyimgui and this wrapper. (see also this comment)

    • To solve the above-mentioned issue, we have to access the context created by a main application running pyimgui by get_current_context(), then use set_current_context() to set the shared context going to be used by this wrapper. However, since we cannot access cdefed attributes of a object wrapped by Python object, we have to rely on passing pointer as an argument to set_current_context_ptr() to achieve this goal.

    • Even though we can successfully get the ImGuiContext used by the main process, it still failed to render the TextEditor. See also issue #1.

pyimgui-colortextedit's People

Contributors

naleraphael avatar

Watchers

 avatar

pyimgui-colortextedit's Issues

Assertion error raised in `imgui` side after `imgui.render()` is called

  • description
    Even though we've successfully set the context with the same one used in pyimgui by our implementation of colortextedit.set_current_context_ptr(), it still failed to render TextEditor by the following setup.

  • possible solution

    • Since we mainly rely on imgui.render() to render the content, we might need to rewrite TextEditor::Render() to make it works like a normal imgui component.
  • package versions

    • ocornut/imgui: e0cab566 (same as the version used by pyimgui)
    • BalazsJako/ImGuiColorTextEdit: ea516e0 (we use a eariler version in order to make it compatible with the version of ocornut/imgui we used)
  • code snippet

    # ... other setup just like the code in `https://github.com/NaleRaphael/codememo/blob/6ae07b5/codememo/app.py`
    
    class Application(object):
      # ...
    
      def update(dt):
        imgui.new_frame()
        text_editor = colortextedit.TextEditor.create()
        text_editor.render('foobar', 100, 100, False)
    
      # ...
  • traceback

    Traceback (most recent call last):
      File ".../py37/lib/python3.7/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File ".../envs/py37/lib/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File ".../project/codememo/codememo/__main__.py", line 11, in <module>
        launch_app()
      File ".../project/codememo/codememo/__main__.py", line 7, in launch_app
        app.run()
      File ".../project/codememo/codememo/app.py", line 136, in run
        pyglet.app.run()
      File ".../envs/py37/lib/python3.7/site-packages/pyglet/app/__init__.py", line 107, in run
        event_loop.run()
      File ".../envs/py37/lib/python3.7/site-packages/pyglet/app/base.py", line 167, in run
        timeout = self.idle()
      File ".../envs/py37/lib/python3.7/site-packages/pyglet/app/base.py", line 243, in idle
        window.dispatch_event('on_draw')
      File ".../envs/py37/lib/python3.7/site-packages/pyglet/window/__init__.py", line 1333, in dispatch_event
        if EventDispatcher.dispatch_event(self, *args) != False:
      File ".../envs/py37/lib/python3.7/site-packages/pyglet/event.py", line 408, in dispatch_event
        if handler(*args):
      File ".../project/codememo/codememo/app.py", line 81, in on_draw
        imgui.render()
      File "imgui/core.pyx", line 1848, in imgui.core.render
    imgui.core.ImGuiError: ImGui assertion error (draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size) at imgui-cpp/imgui.cpp:3376
    

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.