Unsolved Compile Qt into Python, for MainWindow, how to add widget from python side dynamically?
-
I compiled all my Qt code into a python library, and have a mainWindow, and from python side, how to let user add buttons, toolbars, menus dynamically from python side?
-
@student What exactly is your question?
How to create widgets dynamically?
Or something else? -
-
@jsulm let's say, I wrote code using Qt in C++ and compile it into python shared library, then we can use it from python side. This shared library has a mainWindow, assume people are using it, and want to add his own menu or buttons from python. for example, one user have a function in python named "my_print", and want to add a button named "Test", and bind this button to "my_print", that means, when click "Test" button, call "my_print".
How to achieve? -
@student said in Compile Qt into Python, for MainWindow, how to add widget from python side dynamically?:
How to achieve?
I'm not completely sure about your use case. Why don't you use PyQt or PySide?
-
@student
Not only "should" you do as @jsulm says and be using PyQt5 or PySide2, I would suspect in practice you "must" do things that way. These have all the code for bindings, management etc. to access C++ Qt objects from Python, without that if you try to do it yourself directly I think you'll find it very hard to access Qt objects from Python correctly. -
@JonB I dont think PyQt or PySide can meet the performance requirement.
Also, now I am saying python, if I want to use perl or tcl. how to do? -
@student
Maybe you should be looking in on another topic currently being discussed, https://forum.qt.io/topic/115972/exposing-my-c-function-to-a-python-script.I don't know where your "performance requirement" bottleneck lies. The Qt GUI side is going to run at the same approximate speed for Python or C++, I imagine. UI is mostly sitting around doing nothing.
I have not seen a usable Perl binding fro Qt5. I don't know about tcl.
-
@student said in Compile Qt into Python, for MainWindow, how to add widget from python side dynamically?:
I dont think PyQt or PySide can meet the performance requirement
You can always implement performance critical stuff in C or C++ and use that in Python.
-
@JonB almost all EDA tools's interface is TCL, and core code should be Qt. and people can add custom menu/button/... from tcl side. even we can bind custom tcl proc to the menu or button.
-
@student
I don't do "EDA" so I wouldn't know. If you state that "ore code should be Qt" etc., then presumably someone has already addressed the interface between TCL & Qt, else there would be a problem.