midjji / convenient_multithreaded_qt_gui

MIT License
4 stars 0 forks source link

Questions #1

Open bsobhani opened 3 years ago

bsobhani commented 3 years ago

1) Is it possible to run a gui in a secondary thread with this if there is already an unrelated gui running in the main thread?

2) Do you know if it is possible to run a gui this way in PyQt5? I can run a gui from a secondary thread in PyQt, but only if there isn't some other PyQt program already running in the main thread. Apparently, PyQt marks the thread where PyQt is first imported as the "main thread" and forcibly runs the event loop there even if you try to do it from another thread.

midjji commented 3 years ago

Hi, 1) Yes, If the main thread is something else it just runs in parallel. If it is a qapplication, any command you send it will be run in that qapplications thread, whatever that may be. So you can use this to do separate GUI widgets regardless.

2) I haven't made pybinding for this, I wouldn't know how with the closures to be honest. But I think pyqt already does something like this, since it does not require that you run a qapp.exec() yet does not lock the global interpreter right?

By the way, from what I have seen, plain qt5 apps written in c++ are far less verbose than pyqt. It's mostly the same commands you give, there is just five times more boilerplate in pyqt. It's faster too ofc, but mostly on startup if you do pyqt right.

On Fri, 27 Nov 2020, 17:18 bsobhani, notifications@github.com wrote:

1.

Is it possible to run a gui in a secondary thread with this if there is already an unrelated gui running in the main thread? 2.

Do you know if it is possible to run a gui this way in PyQt5? I can run a gui from a secondary thread in PyQt, but only if there isn't some other PyQt program already running in the main thread. Apparently, PyQt marks the thread where PyQt is first imported as the "main thread" and forcibly runs the event loop there even if you try to do it from another thread.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/midjji/convenient_multithreaded_qt_gui/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJQYJKCZJNUZNEQJ3A5T63SR7GM7ANCNFSM4UFCXUOQ .

GiorgosXou commented 2 months ago

@bsobhani check this