ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

7 September 2022
2022-09-07×
7 September 2022
Currently I am doing internship in p2f semiconductor, I have assignment based PyQt. I need help in that project
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
I
Kindly please help me
F
This 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.
K
I just happened to be looking at some of Cristiáns talks and spotted this blurb that relates, so i thought I'd clip and post it.
L
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
Well you should ALWAYS build your code to have ui and backend separated.
Specifically for these reasons 😉
build 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à
Ë
here'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
K
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.
btw: Is there something nice to profile with?
I'm separating things mainly for staying sane, unittesting and debuggability not yet for profiling
Ë
by the other way: I NEVER used QRunnable so far but QThreads only so keep ui responsive. What's the difference? Is there a comparison?
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.
K
As for QML debugging — while I have things set to where the QML debugger should be able to connect and start debugging, the app seems to always immediately quit once I connect the debugger.. so, so far I have been unable to do any QML debugging of a Qt for Python application.
Calendar: September 2022
MoTuWeThFrSaSu12341567338191011121314215161171018193720921322232462512262728291302
Archive by month
Open in Telegram Каталог площадок Искать в ChatCrawler

A snapshot of an open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog