7 September 2022
Project details:
Using PYQT I should create a window that should work out the logic gate simulation. For example, I should design a window inside that user should give the input, user should define which logic gate he/she wants the input. And after getting that details in that same window particular logic gate picture/animation should show+the output value of that particular gate should show
id 1350325116Project details:
Using PYQT I should create a window that should work out the logic gate simulation. For example, I should design a window inside that user should give the input, user should define which logic gate he/she wants the input. And after getting that details in that same window
look at WiredPanda, it's exacly what p2f wants.
FreyaThis chat is about PySide, not PyQt. Also, what do you even need help with? We won't write your code for you, so unless you have concrete questions, there really isn't much to say.
the names are too similar. :) (specially when Qt Company renamed pyside to Qt for Python.
tomaz canabravathe names are too similar. :) (specially when Qt Company renamed pyside to Qt for Python.
PySide is still PySide, Qt for Python is the umbrella term for more (PySide, Shiboken, the Python scripting for C++ thing, etc.)
id 1350325116Project details:
Using PYQT I should create a window that should work out the logic gate simulation. For example, I should design a window inside that user should give the input, user should define which logic gate he/she wants the input. And after getting that details in that same window
Ссылка
click to show
click to show
Not Qt but seems super related: https://github.com/SebLague/Digital-Logic-Sim
Sorry if this might sound silly but I can’t find a definitive answer to my problem online:
I have got a fairly complivate UI built with PySide6 that I use in my application to input data that is then used to calculate some results.
The computation itself is executed in a separate thread implementing a Qrunnable for it (to avoid blocking the UI while calculating).
I am at the point where the calculation are working as intended but I would like to perform profiling on the “long running” Qrunnable to see where most of the time is spent and to see if some refactoring could help in speeding up the code.
Is there a way to profile the calculation routine without having to abstract it from the UI? As I said the inputs are quite complicated and I would like to use the UI to set the desired values
ëRiCbuild everything so that you could run it from the commandline or an interactive python console. Even better: build a unittest for the whole backend functionality. Best: Build code and unittest side by side 🤓
then make minimal calls from your ui to the backend. Voilà
Fair enough, this was my thesis project and as a chemist I learned while doing what best practices in Software Dev are only by making errors… 🥲
ëRiChere's an idea: Make the the ui provide the data that you can input to your calculation code. Maybe:
• let UI write all settings into JSON
• load JSON with calculation code
Hah I was just going to suggest something like that, though I was going to suggest capnproto messages. But I guess that's probably overkill.
Lorenzo CastellinoFair enough, this was my thesis project and as a chemist I learned while doing what best practices in Software Dev are only by making errors… 🥲
Sounds like doing that separation would be a useful task now. Split the work into bitesized pieces so you're not overwhelmed.
ëRiChere's an idea: Make the the ui provide the data that you can input to your calculation code. Maybe:
• let UI write all settings into JSON
• load JSON with calculation code
Actually this isn’t that far away from what is going on now, I save project files as JSON so probably can adjust it to accept it as input
Keith KyzivatSounds like doing that separation would be a useful task now. Split the work into bitesized pieces so you're not overwhelmed.
My runnable as of now accepts a dict as input and reads it to retrieve the required data
Is there a better/preferred way to handle the matter?
Seems fine to do that. Perhaps just have a means of running your app so that it takes a json file as input, doesn't show the UI, and instead invokes the backend directly (just call the run() method instead of handing it to a QThreadPool). Then you should be able to use profiling tools without any (other) special handling.
ëRiCbtw: Is there something nice to profile with?
Valgrind with callgrind is what is most used I think.
That is what I have used.
If you just want to profile the QML, there is a QML profiler built into Qt Creator, and you can enable it with a few code changes to your python project.
Re: QRunnable - it makes it easier to schedule the tasks with a thread pool. Good if you have bounded tasks - with a clear end. So, you define a QRunnable and have the hard work done in the run(). If it's scheduled on a QThreadPool, it will run and clean up on its own. How you collect the results it generates is up to you to define. It means you can run a bunch of instances of the same runnable with different inputs, and the lifetime of the threads is managed by the thread pool for you.
To do QML profiling, you need to import QQmlDebuggingEnabler from PySide6.QtQml, instantiate a QQmlDebuggingEnabler sometime before the QML engine is instantiated. (I do it before QApplication is created), and have -qmljsdebugger=port:<some port>, block passed as an argument to QApplication:
from PySide6.QtQml import QQmlDebuggingEnabler
[...]
sys.argv.append("-qmljsdebugger=port:10002, block")
app = QApplication(sys.argv)
[...]
debugEnabler = QQmlDebuggingEnabler() # pylint: disable=unused-variable
engine = QQmlApplicationEngine()
Once you have that and you start your app, it will wait for the QML debugger or profiler to connect.
Open Qt Creator, Choose "Analyze->QML Profiler (Attach to Waiting Application)", make sure that the kit that is selected matches the PySide6 version that you are using, specify the same port you specified in the app, and then click "Ok". Your app should start up, and you can interact with it.
Back in Qt Creator the profiler panel will have opened, and it will look like no sampling is being done, but it actually is. There is a red circle tool button that I think is supposed to look like a recording light indicating that sampling is happening. Go back to your app and do whatever actions that you wish to profile, and when you're done and ready to look at the results, go back to Qt Creator and click the red "recording" tool button and it will stop sampling, and should show you some results.
I'm still getting a feel for how to actually use the results that it provides to do optimizations.