[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Show QDialog and execute code after
From:       Barry Scott <barry () barrys-emacs ! org>
Date:       2018-04-15 15:01:26
Message-ID: 05E2907D-DCA8-470F-9704-390A27FC153B () barrys-emacs ! org
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> On 15 Apr 2018, at 13:20, Kyle Altendorf <sda@fstab.net> wrote:
> 
> 
> 
> On April 15, 2018 3:55:14 AM EDT, Barry <barry@barrys-emacs.org \
> <mailto:barry@barrys-emacs.org>> wrote:
> > 
> > 
> > > On 14 Apr 2018, at 20:46, Ricardo Araoz <ricaraoz@gmail.com> wrote:
> > > 
> > > > On 14/04/18 15:46, Kyle Altendorf wrote:
> > > > On April 14, 2018 2:01:36 PM EDT, Maurizio Berti
> > <maurizio.berti@gmail.com> wrote:
> > > > > > I making an update app that shows a QTextEdit object and starts
> > > > > (should)
> > > > > start to get information from the system before
> > > > > > ask the user what to do, it does that but if now but only after
> > the
> > > > > function get all the system info and the it draws the QDialog.
> > > > > > It's something like a Debian apt-get where the terminal is showing
> > > > > what
> > > > > is appending before and after each operation.
> > > > > 
> > > > > If that's the case, you should use a separate QObject that collects
> > the
> > > > > output of apt-get and emits a signal every time it has something to
> > > > > show.
> > > > > That QObject has to be moved to a new QThread, so that the apt-get
> > > > > process
> > > > > will not block the GUI interaction and painting.
> > 
> > Is there any advantage to using QThread over python threads?
> 
> They get you an event loop in the thread (so long as you use them properly for \
> that) which is required to receive signals (along with not blocking the event loop, \
> just as you shouldn't in the main thread).

That is useful to know. I have always been sending signals from the background thread \
and not thought of going the other way.

> 
> Mostly I look for options other than threads. There are various for various needs \
> between Qt and Python. This includes async/inlineCallbacks functions which allow \
> you to write async code without breaking it up and connecting with signals and \
> slots which is a pain when sequencing stuff.

Threads has it drawbacks as does async. As with all things pick the best solution \
from your available design choices.

Barry


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html; \
charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; line-break: after-white-space;" class=""><br class=""><div><br \
class=""><blockquote type="cite" class=""><div class="">On 15 Apr 2018, at 13:20, \
Kyle Altendorf &lt;<a href="mailto:sda@fstab.net" class="">sda@fstab.net</a>&gt; \
wrote:</div><br class="Apple-interchange-newline"><div class=""><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: \
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; \
font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline \
!important;" class="">On April 15, 2018 3:55:14 AM EDT, Barry &lt;</span><a \
href="mailto:barry@barrys-emacs.org" style="font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; \
-webkit-text-stroke-width: 0px;" class="">barry@barrys-emacs.org</a><span \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; \
float: none; display: inline !important;" class="">&gt; wrote:</span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; \
-webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""><br \
class=""><blockquote type="cite" class="">On 14 Apr 2018, at 20:46, Ricardo Araoz \
&lt;<a href="mailto:ricaraoz@gmail.com" class="">ricaraoz@gmail.com</a>&gt; wrote:<br \
class=""><br class=""><blockquote type="cite" class="">On 14/04/18 15:46, Kyle \
Altendorf wrote:<br class="">On April 14, 2018 2:01:36 PM EDT, Maurizio Berti<br \
class=""></blockquote></blockquote>&lt;<a href="mailto:maurizio.berti@gmail.com" \
class="">maurizio.berti@gmail.com</a>&gt; wrote:<br class=""><blockquote type="cite" \
class=""><blockquote type="cite" class=""><blockquote type="cite" \
class=""><blockquote type="cite" class="">I making an update app that shows a \
QTextEdit object and starts<br class=""></blockquote>(should)<br class="">start to \
get information from the system before<br class=""><blockquote type="cite" \
class="">ask the user what to do, it does that but if now but only after<br \
class=""></blockquote></blockquote></blockquote></blockquote>the<br \
class=""><blockquote type="cite" class=""><blockquote type="cite" \
class=""><blockquote type="cite" class="">function get all the system info and the it \
draws the QDialog.<br class=""><blockquote type="cite" class="">It's something like a \
Debian apt-get where the terminal is showing<br class=""></blockquote>what<br \
class="">is appending before and after each operation.<br class=""><br class="">If \
that's the case, you should use a separate QObject that collects<br \
class=""></blockquote></blockquote></blockquote>the<br class=""><blockquote \
type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" \
class="">output of apt-get and emits a signal every time it has something to<br \
class="">show.<br class="">That QObject has to be moved to a new QThread, so that the \
apt-get<br class="">process<br class="">will not block the GUI interaction and \
painting.<br class=""></blockquote></blockquote></blockquote><br class="">Is there \
any advantage to using QThread over python threads?<br class=""></blockquote><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none; float: none; display: inline !important;" class="">They get \
you an event loop in the thread (so long as you use them properly for that) which is \
required to receive signals (along with not blocking the event loop, just as you \
shouldn't in the main thread).</span><br style="caret-color: rgb(0, 0, 0); \
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: \
normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: \
0px; text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""></div></blockquote><div><br class=""></div>That is useful to know. I have \
always been sending signals from the background thread and not thought of going the \
other way.</div><div><br class=""></div><div><blockquote type="cite" class=""><div \
class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: \
Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; \
font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline \
!important;" class="">Mostly I look for options other than threads. There are various \
for various needs between Qt and Python. This includes async/inlineCallbacks \
functions which allow you to write async code without breaking it up and connecting \
with signals and slots which is a pain when sequencing stuff.</span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""></div></blockquote><div><br class=""></div><div>Threads has it drawbacks as \
does async. As with all things pick the best solution from your available design \
choices.</div><div><br class=""></div><div>Barry</div><div><br \
class=""></div></div></body></html>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic