Pythonizing Imgui (feat. Cython) and contributing to open source.

Поділитися
Вставка
  • Опубліковано 23 січ 2025

КОМЕНТАРІ • 178

  • @KinxKlark
    @KinxKlark 2 роки тому +516

    Hey, youtube just suggested me that, I didn't realize you were making videos. Great stuff and thanks again for the help! Indeed pyimgui is currently too close to the cpp dearimgui and would gain to be more inline with the python way. I am hoping to push it in this diretion. :)

    • @mCoding
      @mCoding  2 роки тому +184

      For anyone who doesn't know, Kinox is the maintainer of pyimgui, so show your thanks!

    • @SpaghettDev
      @SpaghettDev 2 роки тому +19

      thank you so much for this awesome module!

    • @john.dough.
      @john.dough. 2 роки тому +16

      omg thanks for all your hard work

    • @DiddleDangle
      @DiddleDangle 2 роки тому +4

      What an absolute beast.

  • @ciscoortega9789
    @ciscoortega9789 2 роки тому +303

    Awesome video! I genuinely feel like this is something most programmers need to see demoed for them. It's such a vital process that I suppose most people just try to "figure out" on their own and end up making many embarrassing mistakes.
    Great resource video, and I'm pretty sure I will be referring people to it when they ask about the process of contributing to open-source projects :))

    • @ciscoortega9789
      @ciscoortega9789 2 роки тому +69

      I wonder if perhaps this could benefit from being more explicit in the title that this is about the process of contributing to open-source projects? I clicked on this thinking that it would just be a showcase of Imgui and its features (ty for the recommendation btw)

    • @mCoding
      @mCoding  2 роки тому +62

      Good point! Done

  • @Josh-ui7nq
    @Josh-ui7nq 2 роки тому +112

    Great, love to see the process of suggesting and implementing a new and useful feature

  • @alperengencoglu5367
    @alperengencoglu5367 2 роки тому +21

    7:15 I really would like to see some videos about Cython from you in the future. Great video as always, thanks!

  • @sgazda_
    @sgazda_ 2 роки тому +68

    There's also DearPyGui.
    " Dear PyGui is NOT a wrapping of Dear ImGui in the normal sense. It is a library built with Dear ImGui."

  • @jecaballeror
    @jecaballeror 2 роки тому +60

    You're a true MVP. Also, I cracked at the end with that jk. I can only imagine the pain when seeing how much of those there were. As always, great content!
    A couple if days ago, i sent some of my students your way, i hope they see the Light with your Teachings

    • @mCoding
      @mCoding  2 роки тому +14

      Many thanks! Glad you enjoyed.

  • @viliamklein
    @viliamklein 2 роки тому +8

    I really like how this video includes subtle (and direct) hints on how to behave in the open source community.

  • @coarse_snad
    @coarse_snad 2 роки тому +102

    The fact that I now feel really motivated to contribute to something open source is evidence of a well structured video.
    I also feel a sudden urge to convert my work project from a CLI to a GUI application... Not sure if that is such a necessary thing though :|

    • @coarse_snad
      @coarse_snad 2 роки тому +3

      Also, is the purpose of Cython to compile C/C++ code with the syntax of Python so that people unfamiliar with such languages get an easier introduction? Or is it perhaps something more subtle?

    • @mCoding
      @mCoding  2 роки тому +25

      Cython serves a dual purpose of allowing you to write Python C extensions using Pythonish syntax, as well as allowing you to easily interface with native C and C++ code. The reason for wanting to write Python C extensions is to take advantage of the fact that C compilers do optimization, whereas the Python compiler basically does not.

    • @coarse_snad
      @coarse_snad 2 роки тому +4

      @@mCoding Interesting... How much usage does Cython see? I've sadly never heard about it before, so I'm presuming it's quite niche? Or maybe I have a talent for avoiding interesting things.

    • @SkrtlIl
      @SkrtlIl 2 роки тому +7

      @@coarse_snad It finds heavy usage in tons of frameworks for the given two use cases, but is typically implemented privately with a public interface (like shown here) so you don't notice it as a regular user/non contributor.

    • @tobiasbergkvist4520
      @tobiasbergkvist4520 2 роки тому +1

      @@coarse_snad You don't need to do manual reference counting in Cython (Py_INCREF/Py_DECREF), as compared to when writing Python C extensions. There is also less boilerplate.

  • @Cookie-mv2hg
    @Cookie-mv2hg 2 роки тому +5

    This is the first time I see how library is developed with random people online and I'm impressed!!

    • @mCoding
      @mCoding  2 роки тому +4

      Welcome to the club! I hope I've set a decent example for you.

  • @weekendforever
    @weekendforever 2 роки тому +40

    Just the other day I was wondering why I still haven't seen some code-UA-camr who was applying what they want to show to a open source project.
    I hope you get many internet points for this.

  • @mathijsdejong6416
    @mathijsdejong6416 2 роки тому +9

    Great video! As mentioned by others in the comments, it's very useful to be able to follow your thought process when encountering a problem in software and how you solved it. Really enjoying and learning a ton from your amazing videos!

    • @mCoding
      @mCoding  2 роки тому +1

      Thanks so much!

  • @nothingiseverperfect
    @nothingiseverperfect 2 роки тому +20

    Wow, I hardly understand what’s going on, but it is all super interesting.
    I especially enjoyed the part at 6:00 of how you showed how you submitted a pull request, and how you documented your new implementation idea. This was incredible insightful and your documentation of your process and what you hope to do was fantastic.
    Also loved how you mentioned how you tested your code. The process of implementing your code was so through. Hope go get where you are! Thank you for this! I’ve got a lot to learn 😭😭

  • @Omaryllo
    @Omaryllo 2 роки тому +3

    Yes please i want a Cython tutorial. There is no other place to find knowledge this densely packed and valuable

  • @pratikmahamuni4856
    @pratikmahamuni4856 2 роки тому +1

    A great tutorial not just for Cython, ImGUI but also how to contribute to open source projects! Kudos. Thank you.

  • @dharma4248
    @dharma4248 2 роки тому +1

    I've used imgui pretty often with C++ projects and I never knew I could use it with python too. Now even more easily! Thank you

  • @paulhemebert496
    @paulhemebert496 2 роки тому +4

    Awesome video!
    A Cython introduction would be very cool.

  •  2 роки тому +1

    Amazing work, man. They should have made it like this from the outset, and it's great to see you helped them check that box. This video is also a great promo for Pyimgui; although I never consider making guis in Python, now you made me want to try. Keep up the great work.

  • @Tomyb15
    @Tomyb15 2 роки тому +14

    This is the second time I've seen great developers that I trust recommend Dear I'm Gui (first one was from The Cherno's channel!)
    But I have to say, I'm still not sold on Immediate GUIs. Having to do every little thing seems to go against the idea of having a library to abstract away the logic.
    I will nonetheless still give it a try because the end result looks very good.

    • @erfer
      @erfer 2 роки тому +10

      I find that immediate mode GUI's are most useful when you are already doing quite a bit of things yourself or are doing something with many updates (e.g. games / rendering) so that you can integrate it closely with the actual data

  • @oeerturk
    @oeerturk 2 роки тому

    open source contribution videos are reeaaalllllllly appreciated and needed imo

  • @PeterSeres
    @PeterSeres 2 роки тому +2

    Hey James!! Great video, great resource and I've finally got a little bit of understanding of what Cython is. Just letting you know that I would really appreciate a Cython overview if one day you have the time and patience. Cheers!!!

  • @dennyw17
    @dennyw17 2 роки тому +1

    Very cool walk through of both the module and the contribution!

  • @TheMcSebi
    @TheMcSebi 2 роки тому +2

    wow, I just learned about Imgui through this video and it actually made me consider using this for my next project that requires a gui.

    • @masheroz
      @masheroz 2 роки тому

      I'm trying to learn c++and have a project planned out. Imgui and implot will feature.

  • @vt2788
    @vt2788 2 роки тому

    Great stuff! This is what separates the top programmers from the rest of us ;)

  • @bettercalldelta
    @bettercalldelta 2 роки тому +2

    Thanks to you, I successfully made "with" support for my project

  • @AngryArmadillo
    @AngryArmadillo 2 роки тому +1

    Excellent video! Excited to see this get merged. I’ll definitely try out pyimgui

  • @abismayn
    @abismayn 2 роки тому

    way more than i expected from just reading the title :) Great job!

  • @rishabhanand4270
    @rishabhanand4270 2 роки тому +1

    damn it's so easy to use this library. plus, contributing to open source is always great, although I feel you did a lot for one PR (but it kinda checks out i would say)

  • @mattiasbermellrudfeldt570
    @mattiasbermellrudfeldt570 2 роки тому

    Great video, thanks!
    I've used cython to speed up the slowest part of a open source project I'm contributing to. I struggled a lot getting started and still do from time to time. I'd love to see your take on it!
    All the best! :)

  • @Phaust94
    @Phaust94 Рік тому

    Thanks James! Great content, as always! It doesn't seem that daunting to contribute to open source projects anymore

  • @Khushpich
    @Khushpich 2 роки тому

    Great content as always. Best non trivial python content on UA-cam.

  • @joffreybluthe7906
    @joffreybluthe7906 2 роки тому +1

    Some of your stuff is too advanced for me, but my goodness your channel is gold
    This is exactly the kind of material I was looking for to become a better programmer (citizen 😉)

    • @mCoding
      @mCoding  2 роки тому +2

      You will get there in time :) just keep at it!

    • @joffreybluthe7906
      @joffreybluthe7906 2 роки тому

      @@mCoding thx man :)

  • @lepsycho3691
    @lepsycho3691 2 роки тому

    That's amazing! It shed light on a problem when I had when I tried to use the with context manager with a python program that did not implement it!

  • @ohwow2074
    @ohwow2074 2 роки тому +1

    Please please make more videos about advanced C++ techniques. The last one you did was an eye opener 🙂.

  • @ConstantlyDamaged
    @ConstantlyDamaged 2 роки тому +10

    As someone who mostly does web-dev that others build the interfaces for, let me just hide in the corner and reeeee-but still admire your use of pythonic ideals.

  • @aaronm6675
    @aaronm6675 2 роки тому

    Love to see this kind of instructive and compelling stuff. Thx!

  • @UnexpectedMaker
    @UnexpectedMaker 2 роки тому

    Great stuff, and a much needed addition to the library! Also very well explained.

  • @embeddor3023
    @embeddor3023 2 роки тому +4

    4:33 Everytime I talk with a C programmer about RAII.

  • @Rohrschacht
    @Rohrschacht 2 роки тому +1

    C++ fan commenting now as requested! Python is also awesome though :D

  • @zacharymiller7573
    @zacharymiller7573 2 роки тому

    This is so sweet I love imgui in C++ but now I’ll have to try it in python

  • @scottk3292
    @scottk3292 Рік тому

    Major LOL on updating the docs later! Reminds me of my contract work at Google. My team manager wouldn't approve any code pushes until we'd verified that we'd updated the docs.

  • @prawnydagrate
    @prawnydagrate 2 роки тому

    you deserve more recognition

  • @roryglenn3612
    @roryglenn3612 2 роки тому

    Always a great time James!

  • @sadhlife
    @sadhlife 2 роки тому +2

    Afaik there's no proper tutorials for cython on youtube. An in-depth course be a really good resource.

  • @drygordspellweaver8761
    @drygordspellweaver8761 Рік тому +2

    James, can you please elaborate on what you feel is the best practice for implementing multi-threaded functionality with the imGUI event loop in Python?
    For example, say I have a UI for managing multiple servers and I am using the select module to check for socket read/writes. I press a button and send a command to one of the servers etc.
    Should the imGUI event loop be run in its own separate Thread from the socket loop? (PyQT incessantly crashed when I tried this). If so, what would the best method of 'communication' be between these two loops? IPC? Or adding commands to a queue then processing this in a third event loop separate from both imGUI and the socket loop?
    On that note, should any performant task be handled in the imGUI loop or will that slow down the rendering? I am assuming most people just call a function and that command gets passed to another thread where it can run asynchronously from the rendering?
    Thanks in advance!

    • @mCoding
      @mCoding  Рік тому

      Hi Drygord, great question! Typically the imgui event loop runs on the main thread, as is typical for most guis. Waiting on sockets using select (or more commonly the higher-level interface in the selectors module) should be done off the main thread. When the socket thread has some data for the main thread, set an Event and if it is set, have the main thread grab a Lock and take ownership of the data. I'm available for consulting :) mcoding.io.

    • @drygordspellweaver8761
      @drygordspellweaver8761 Рік тому

      @@mCoding Hey thanks for the reply! I will keep your consulting services in mind, as you seem like a great tutor. Cheers!

  • @Omaryllo
    @Omaryllo 2 роки тому

    I made a PR once for a change i needed without asking. It would fail many tests and the syntax was newer JS code that they didn't support. I got it at the end and it was actually merged after 3 tries though. Don't be a knucklehead like me :D

  • @babatona
    @babatona 2 роки тому

    Thanks, I never seen such cool C++ Ui library and what is even more cooler is that you made a video on it with python
    Edit: I have 140+ errors. I imported the library and everything but it says that for example it can't find imgui.io or something method

  • @antoniolewis1016
    @antoniolewis1016 2 роки тому

    You earned my sub. Thank you for your clear presentation!!

  • @97jackroma
    @97jackroma 2 роки тому

    This made me very interested about Cython

  • @philosophiabme
    @philosophiabme 2 роки тому +4

    Great video!!! We need more emphasis on code literacy and comprehension skills. To write code you have to be able to read code!

  • @Alche_mist
    @Alche_mist 2 роки тому

    Nice, this PyImgui thing seems like a useful alternative to my beloved PySimpleGUI (which is a nice pythonic wrapper around tkinter, PyQt, WxPython or Remy).

  • @Firigion
    @Firigion 2 роки тому

    My exact thoughts when I saw the begin and end statements! That is begging for a context manager.

  • @__jan
    @__jan 2 роки тому

    A showcase of Cython would be really nice!

  • @cefqrn9494
    @cefqrn9494 2 роки тому +4

    1:16 Consolas?

  • @ltc0060
    @ltc0060 2 роки тому +1

    This is a great video. I really appreciate it, thanks! I want to contribute to open source, but I have no idea how (or even where to start). If you can invest your time into how-to videos of contributing to open-source (the way it should be), that I believe, would be very beneficial to our community. Even if you don't have the time for other videos, thank you for this one!

  • @yash1152
    @yash1152 9 місяців тому

    10:52 > _"__repr__()"_
    what does that do?

  • @Epinardscaramel
    @Epinardscaramel 2 роки тому

    0:39 love the Python emoji mashup 😅

  • @tytywuu
    @tytywuu 2 роки тому

    I see you are low-key adding more humor in your video haha

  • @PetrSUsername
    @PetrSUsername 2 роки тому

    Great video. You covered quite many topics. :D

  • @danielrhouck
    @danielrhouck 2 роки тому +3

    Why didn’t you inherit from `tuple` or a non-typing `collections.namedtuple`? That way you don’t have to manually write (part) of the tuple functionality, and miss other parts. Is that harder in Cython?

    • @mCoding
      @mCoding  2 роки тому +2

      Tuple's elements are not named and i dont think i can expose them easily with names. Even if i could like namedtuple, namedtuple stores pyobject*s, not C bools so it wont be as efficient, and i dont want other tuple functionality like all the comparison operations. Theoretically it would have been fine to use tuple or namedtuple, they just didnt quite fit my needs.

    • @danielrhouck
      @danielrhouck 2 роки тому +1

      @@mCoding You were careful to allow iterating though; I guess that’s used somewhere?
      Edit: oops I missed where you mentioned it’s for unpacking

    • @mCoding
      @mCoding  2 роки тому +1

      Yes, the idea was that even though I don't want this object to have tuple semantics, previously it did and i don't want too break much old code, which very commonly does things like opened, selected = imgui.begin(...)

  • @giosen1817
    @giosen1817 Рік тому

    What if I wanted to view imgui windows in notepad-type software instead of a window generated as a background?

  • @cleverclover7
    @cleverclover7 2 роки тому

    lol at the end! i typically used tkinter for stuff like this in the past, but imgui seems way cooler, especially now that you can use it more pythonically.

  • @SkyFly19853
    @SkyFly19853 2 роки тому +1

    I hope you will make more videos on Cython.

  • @adamhenriksson6007
    @adamhenriksson6007 2 роки тому

    Looks like streamlit. I really like that style of GUI programming

  • @TheCosmicBuffet
    @TheCosmicBuffet 2 роки тому

    Excellent work and video :)

  • @meirzilkha
    @meirzilkha Рік тому

    do you have intelisense auto complete when working with this library. It does not work wiht the latest pip install

  • @whamer100
    @whamer100 2 роки тому

    you just made my one reason i didnt want to use pyimgui the reason i want to use pyimgui now 👀

  • @Scranny
    @Scranny 2 роки тому +2

    Yes! Please do a Cython tutorial. As a longtime Python programmer, I would like to know in which use cases it might be useful to me to write my code in Cython instead.

  • @novoehuevoe9340
    @novoehuevoe9340 2 роки тому +1

    Oh, man. I really want to see Cython tutorial

  • @comradestinger
    @comradestinger 2 роки тому

    Really great video! love the idea of using the 'with' for making sure end() gets called
    I know it's not the point of the video, but here's a tiiiiny nitpick (I couldn't help myself I'm sorry, feel free to ignore xD)
    I think you got Imperative and Declarative the wrong way around at 2:50?
    Dear Imgui runs from start to end, "one thing after another", IE, Imperative.
    While the initializing everything at startup, "Declaring" the behaviour then letting it do its thing on its own, would be a declarative style.

  • @TheChemicalWorkshop
    @TheChemicalWorkshop 2 роки тому

    finally a pythonic gui... other ones were ehhh, not so pythonic

  • @SkyFly19853
    @SkyFly19853 2 роки тому

    Cython!
    One of my favorites!
    Wonderful for video game development.
    ✅✅✅✅✅✅

  • @jti107
    @jti107 2 роки тому +2

    what are your thoughts on pyside?

    • @mCoding
      @mCoding  2 роки тому +1

      Never used it!

  • @vxsniffer
    @vxsniffer 2 роки тому

    I've discovered DearPyGUI recently, and have to admit, GUIs were never so easy before (with Tkinter, PyQt or else)... big thumbs up for Jonathan Hoffstadt and Preston Cothren for making imGui framework available in Python!

  • @mme725
    @mme725 2 роки тому +1

    Random question about PyImgui, but can a Pyimgui be compiled to an executable? Was a bit fuzzy on the line between "This is an interpreter program, using C++ extensions like Numpy" and "This is a program deeply integrated with C++, and is just a pretty transpiler for GUI writing".
    Assuming it was more like the Numpy scenario, but figured I'd ask because making portable little GUI applications with this sounded really neat. (Admittedly even if it didn't compile down, there is always the PyInstaller route. I'm just asking for hobbyist reasons rather than anything serious.)

    • @mme725
      @mme725 2 роки тому

      Oh second note! Really appreciate this video! Really good dive into a neat topic, but also the casual-but-educational dive into contributing to open source projects never hurts. :)

    • @mCoding
      @mCoding  2 роки тому +4

      Good question and thank you! Yes pyimgui is more like numpy. There is the core imgui library written in cpp, then the pyimgui module is a compiled python c extension that calls out to the imgui cpp functions at runtime. It is only portable because the pyimgui maintainer builds binary wheels of the package that include the pre-built c extension and compiled imgui library so you dont need cython or a c compiler to pip install it.

  • @mystisification
    @mystisification 2 роки тому +2

    very informative, thanks James! Seems like you had to do a lot of legwork just to run the tests, why is that?

    • @mCoding
      @mCoding  2 роки тому +7

      Good question! Because Cython code must be compiled like C or C++ code, I can't just make a change in the code and re run the tests immediately. I have to recompile the library and install it again after every change (that's what pip install -e . -v does in this case). That actually involves recompiling the 11k lines of Pyimgui code as well as the even larger imgui C++ code, which is why it took so long.

    • @mystisification
      @mystisification 2 роки тому +1

      @@mCoding But that's strange, isn't there a build file à la Makefile/CMake to only rebuild the relevant parts?

  • @royz_1
    @royz_1 2 роки тому

    I am intrigued to give this a try. It's far better than tkinter in terms of developer experience (even though it's a bit hacky). Pyqt5 still holds the first place in my opinion.

  • @marcusmanmarcus
    @marcusmanmarcus 2 роки тому

    Hi, can you make on tutorial on injecting a gui like this into a selenium browser instance?

  • @krishnamenon6288
    @krishnamenon6288 2 роки тому +3

    1:16 Jetbrains Mono? Just a shot in the dark ;)

  • @bennguyen1313
    @bennguyen1313 Рік тому

    Do the python bindings also work for imPlot or only the base imGui?
    I'm looking to write a simple one-window gui (no floating/docking etc) just a couple textboxes/labels, some pushbuttons... perhaps a few red/green led-like indicators.
    ImGui looks very clean, but does it lend itself can it do such an app?

  • @ugurunver2403
    @ugurunver2403 2 роки тому

    So those if's just for serializing async events in a sync flow, right? I mean, the library calls frame_commands function for every event happened in window and we just select the event with those if's?

    • @mCoding
      @mCoding  2 роки тому

      There's no async here, it's all synchronous. The frame commands get called once per frame, not once per event. It's some kind of magic that imgui figures out what to draw from just one pass through the render commands!

  • @cub1cc
    @cub1cc 2 роки тому +1

    1:16 JetBrains Mono😁

  • @nimerkees7907
    @nimerkees7907 2 роки тому

    Besides the superb content you create. I watch your videos a lot, and every time I get this question popping in my head …
    Are you peter from spider man? But like the bad ass version of him?

    • @mCoding
      @mCoding  2 роки тому

      Haha which spiderman do I look like?

    • @nimerkees7907
      @nimerkees7907 2 роки тому

      images.app.goo.gl/KwnscCFE7D47zss9A
      Am I right or it’s just me with some 3 AM ideas?😅
      I gotta say lately abstractions and inheritance concepts may have got into me and took you as a parent class which peter in spider man inherits from … but it may be just me
      Either way,
      Love your content, I learned so much from you :) Thank you!

  • @HoSza1
    @HoSza1 Рік тому

    Hey mCoding! I'd like to ask if you have any experience with kivy? And if so, how do they compare to each other. Imgui has a main drawback in my view, that it intermingles logic and presentation and I doubt that it would scale very well without any problems when creating more complex applications.

    • @mCoding
      @mCoding  Рік тому

      Hello! I don't have any experience with kivy. Imgui is great for rapid development, but I can see it being too simple for a large application. For medium sized it works fine though :)

  • @jurebajic6844
    @jurebajic6844 2 роки тому

    I just love the end! 😂

    • @mCoding
      @mCoding  2 роки тому +1

      Haha thanks I still havent written the docs yet 😅

  • @thomasbates9189
    @thomasbates9189 2 роки тому

    Can you create a video guide to install imgui and dear imgui? There is no material for this on UA-cam.

    • @mCoding
      @mCoding  2 роки тому

      It's actually in the video at 0:59 if you don't blink: pip install imgui[full]

    • @thomasbates9189
      @thomasbates9189 2 роки тому

      ​@@mCoding Thanks for the reply. I had tried installing this on my other machine that has an intel processor and it had trouble creating the wheel (I don't know enough to understand what that is or how it works.) I was thinking I needed some c++ related dependency to install imgui. I just installed it on my laptop now when I saw your comment and it works although my laptop has an arm processor and a different setup. So perhaps I changed something on my other machine that was causing the issue? It works now so thanks for replying!

    • @thomasbates9189
      @thomasbates9189 2 роки тому

      @@mCoding Your technical videos on python are amazing btw! Thank you so much!

    • @mCoding
      @mCoding  2 роки тому

      Hmm hard to say what the diff could be. Thanks for watching!

  • @freddupont3597
    @freddupont3597 2 роки тому +1

    LOL the documentation got the usual treatm

  • @this_is_japes7409
    @this_is_japes7409 2 роки тому

    13:07 would be nice if you did videos on PEP8 and maybe just on how to document code properly, maybe you have? i should look for that, new to the channel. and love the content.

  • @simplevc2980
    @simplevc2980 2 роки тому

    one of C++'s ImGui user here xD

  • @Epinardscaramel
    @Epinardscaramel 2 роки тому

    Damn that's high level 😲

  • @yash1152
    @yash1152 9 місяців тому

    8:37 > _"do docs count as LOC?"_
    in adsence of stub files? yes, yes they unfortunately do.

    • @yash1152
      @yash1152 9 місяців тому

      13:06 oh lol

  • @0xCAFEF00D
    @0xCAFEF00D 2 роки тому

    Isn't the idea of explicitly beginning and ending something to have it represent itself more visually in the code? In most python code that uses with there's a variable that's invalid when you drop out of the with (and sadly it's not undeclared, but that's another issue, you can't use a file after close anyhow). I think the with statement can work as it's quite explicit too but the structure may simply be better represented by having it be entirely explicit since you're going to call member functions on imgui literally everywhere. I could easily see myself writing imgui.button outside a with unknowingly. But writing it on the wrong side of an end is harder.
    I've been using a similar structure for generating html documents through yattag. It effectively asks you to nest everything in with statements. Which would get very deep nesting very quickly but you obviously use your own helper functions which alleviates that slightly. It's mostly fine since that's the nature of html. But there were instances where I wished I could have explicit begin and end statements.
    Also notice how a missing end isn't a silent problem. The exception (control flow breaking) case is the only case where you have an issue that isn't an immediate runtime issue, the moment you test your gui even once it appears. It's hard to imagine this reaching production for me.
    It never hurts to extend the interface of course. Since it's entirely optional. But I don't think it will be the primary use. The C++ version of the library didn't do it with constructors/destructors either I presume?

    • @sodiboo
      @sodiboo 2 роки тому +1

      Missing end CAN be a silent problem if it's nested deep in some UI that's only visible under some obscure condition. You could have a menu that worked just fine, and without any changes to it directly it breaks and throws an exception because of changes somewhere else to code it relies on. In a complex application, you might not think to check that menu again, because you've never changed any code in that menu, and this is how such issues make it to prod. The with statement helps the UI block close anyways, even if the programmer never expected an exception to be thrown there.
      I'd imagine the reason the C++ library didn't use constructors/destructor is because creating a new object takes memory that is slow to then release since it's not on the stack. In python, this is less of an issue, because the function returns a tuple which has the same drawbacks, so creating a class that works with "with" doesn't have the same problems for performance.
      I do agree with you though that this pattern easily leads to huge indents in complex UIs, because especially for buttons and drop owns, one block suddenly indents 2 levels because you need to check that the menu is actually open before rendering.

    • @0xCAFEF00D
      @0xCAFEF00D 2 роки тому +1

      @@sodiboo I'm pretty sure your constructor/destructor pair in C++ would just be a thin wrapper around two function calls. I can't imagine a compiler failing to optimize that into just calling both functions in an optimized build. But I guess you'd have to test it to really know.

    • @sodiboo
      @sodiboo 2 роки тому +1

      @@0xCAFEF00D You're right, i'm used to C# with a garbage collector. Looking back i have no idea why i thought that was a concern for C++ and i think i agree with you

  • @oida10000
    @oida10000 2 роки тому

    Can you do a Cython (beginer's) tutorial in the future?

  • @terrapin-yob
    @terrapin-yob 2 роки тому

    I've always wanted to contribute to open source projects, but it's hard to find a project you know you can work on, you're allowed to work on, you know you can commit to the project, you know you can do things correctly, etc....

  • @el_chivo99
    @el_chivo99 2 роки тому +3

    I’ve always wondered how numpy implements the @ operator for matrix multiplication. It’s not a symbol you can normally use in python. would be awesome if you used this example to dig more into python that wraps C!

  • @cristinocanga
    @cristinocanga 2 роки тому

    Can you make a video
    Talking about de cython and cpython

  • @yash1152
    @yash1152 9 місяців тому

    8:47 > _"out parameters"_
    niiice

  • @bosch5303
    @bosch5303 2 роки тому +2

    Please show dearpygui

  • @RyanMorey1
    @RyanMorey1 2 роки тому

    “For sneaky reasons this is going to be faster” lol

  • @thethiny
    @thethiny 2 роки тому

    It's called I'm Gui, hence the name "Dear I'm Gui".

  • @_Skire
    @_Skire 10 місяців тому

    wheres the code to copy and paste?

    • @mCoding
      @mCoding  10 місяців тому

      Check the github!