[FR] Real-time GUI updates from code
Is your feature request related to a problem? Please describe. I find it really hard to build GUIS in my large codebase and it would be nice if there was a mode where the gui automatically updates as soon as it sees a code change
Describe the solution you'd like a dev mode where the gui automatically updates as soon as it sees a code change, sorta like a dev mode, this would allow for easier GUI updates and building
Describe alternatives you've considered i tried making this myself using a threading system but it kept crashing
Hey, I built a plugin system with reload because I also found it annoying to have to reload the whole app for every change.
https://github.com/awcook97/Pure-Python-Back-SEO/blob/main/PluginController.py#L33-L61
There's the link to the relevant code
Hey, I built a plugin system with reload because I also found it annoying to have to reload the whole app for every change.
https://github.com/awcook97/Pure-Python-Back-SEO/blob/main/PluginController.py#L33-L61
There's the link to the relevant code
hey sorry for late reply, how was this implemented by you? is there anything special i need to do?
hey sorry for late reply, how was this implemented by you? is there anything special i need to do?
If you take a look around how I implemented plugins, you'll get a better idea of the specifics, but here's the high level.
The PluginController class scans the plugins located in the plugins folder (any file that starts with "back_" should be considered a plugin), then activates/deactivates them depending on you clicking/checking them in the application. They default as deactivated.
When you activate the plugin, it basically unhides all of the stuff that was init'd in the plugin.
When you deactivate the plugin, it hides all of the stuff that the plugin imported (plugins all have a _window, _tab, _menu, and _activate function that basically show/hide the stuff that it creates)... the magic really happens in lines 44-46 of the PluginController:
_module = importlib.reload(self._modules[plugin])
# print(f"self._plugins[{plugin}] = {_module}.{plugin}()")
exec(f"self._plugins[plugin] = _module.{plugin}()"
What this basically does is reimports the original YourPlugin class then re-executes the plugin again, and if the plugin was active before, reactivates the plugin.
If you want to, you can pull down the Pure Python Back SEO repo and build out using that, since creating the plugin system for the entire application was kinda complex and it has been a few years since I have worked on the project. The relevant files you'll be looking at are:
- core.py (this shows how to call it the plugin controller)
- PluginController.py (this handles the plugins, both compiled & uncompiled (Note: uses .pyd, not .so, so compiled only works for Windows))
- Plugins/__init__.py (how the plugins are implemented)
- Plugins/back_Base.py (an example plugin)
The code was all written to be compatible with the Back SEO application, I didn't write it to be used across applications, but after reviewing the code, it honestly should be mostly plug & play.
Hope this helps. It took me a long time to figure it out, but the code is all there and the plugin system should still work :)
awesome cheers