<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">You are defining a specific signature in the signal:</div><div dir="ltr"><span style="font-family:monospace,monospace;font-size:12.8px"><br></span></div><div dir="ltr"><span style="font-family:monospace,monospace;font-size:12.8px">QtCore.pyqtSignal(int, str)</span><br></div><br>this means that, despite the types you set in the method (which Qt doesn't know anything of also, as you didn't use the Slot decorator), whenever you emit a None (which is a NoneType, not int, nor str) Qt will try to "translate" it to the valid signature you assigned.</div><div><br></div><div>I don't know exactly why the int is that a high number (always high and always random), but this probably makes sense for some C++ type signature, as it seems to me that the number is always 32bit long and, in my case, always negative.</div><div><br></div><div>Anyway, if you really need to send None, you can use the generic "object" signature in the signal definition, or, in your case, just go with this, assuming the progress will never use negative numbers.</div><div><br></div><div><span style="font-family:monospace,monospace;font-size:12.8px">def updateProgress(self, val: int=-1, text: str=''):</span><br></div><span style="font-family:monospace,monospace;font-size:12.8px"> </span><span style="font-family:monospace,monospace;font-size:12.8px">if val is >= 0:</span><br style="font-family:monospace,monospace;font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px"> </span><span style="font-family:monospace,monospace;font-size:12.8px"> self.progressBar.pb.setValue(</span><wbr style="font-family:monospace,monospace;font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">val)</span><br style="font-family:monospace,monospace;font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px"> </span><span style="font-family:monospace,monospace;font-size:12.8px">if text:</span><br style="font-family:monospace,monospace;font-size:12.8px"><div><span style="font-family:monospace,monospace;font-size:12.8px"> </span><span style="font-family:monospace,monospace;font-size:12.8px"> </span><span style="font-family:monospace,monospace;font-size:12.8px"> self.progressBar.label.</span><wbr style="font-family:monospace,monospace;font-size:12.8px"><span style="font-family:monospace,monospace;font-size:12.8px">setText(text)</span> </div><div dir="ltr"><br></div><div>and then emit the text signal using -1 for val.</div><div dir="ltr"><br></div><div>Maurizio</div><div dir="ltr"><br></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-09-04 18:16 GMT+02:00 J Barchan <span dir="ltr"><<a href="mailto:jnbarchan@gmail.com" target="_blank">jnbarchan@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">PyQt5.7. I am having trouble `emit()`ing a signal and receiving its arguments correctly. I have read <a href="http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html" target="_blank">http://pyqt.sourceforge.net/<wbr>Docs/PyQt5/signals_slots.html</a> carefully.<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><b>Declaration</b>:</div><br><div style="font-family:tahoma,sans-serif" class="gmail_default"><span style="font-family:monospace,monospace"> # class variable for "notifyProgress" signal, for displaying a progressbar<br> notifyProgress = QtCore.pyqtSignal(int, str)</span><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><b>Initialisation</b>:</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div class="gmail_default"><span style="font-family:monospace,monospace"> self.notifyProgress.connect(<wbr>self.updateProgress)</span></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><b>Slot</b>:</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><span style="font-family:monospace,monospace"> def updateProgress(self, val: int, text: str):<br> # slot for self.notifyProgress<br> # eprpayrequestfunctions.runEpr(<wbr>) calls this to indicate progress<br> # if it passes an integer it's the desired value for the progressbar<br> # if it passes a string it's the desired value for the label<br> if val is not None:<br> self.progressBar.pb.setValue(<wbr>val)<br> if text is not None:<br> self.progressBar.label.<wbr>setText(text)</span><br><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><b>Signals</b>:</div><div style="font-family:tahoma,sans-serif" class="gmail_default"><br></div><div style="font-family:tahoma,sans-serif" class="gmail_default"><span style="font-family:monospace,monospace">1. notifyProgress.emit(None, "Some text")<br><br>2. notifyProgress.emit(i / 2, None)</span></div><br><div class="gmail_default" style="font-family:tahoma,sans-serif"><b>Behaviour in slot</b>:<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">The problem is the passing of <span style="font-family:monospace,monospace">None</span> from <span style="font-family:monospace,monospace">emit()</span>:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div>1. <span style="font-family:monospace,monospace">val</span> arrives in slot as <span style="font-family:monospace,monospace">1261196128</span>.<div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><div class="gmail_default">2. <span style="font-family:monospace,monospace">text</span> arrives in slot as <span style="font-family:monospace,monospace">''</span> (empty string).</div><div class="gmail_default"><br></div><div class="gmail_default"></div><b>Questions</b>:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><ul><li>Where is this behaviour for <span style="font-family:monospace,monospace">None</span> as an <span style="font-family:monospace,monospace">emit()</span> parameter documented?</li><li>What is the correct/best way for handling this correctly/easily?<span class="HOEnZb"><font color="#888888"><br></font></span></li></ul></div></div><span class="HOEnZb"><font color="#888888"><div dir="ltr"><br>-- <br><div class="m_6813107041399019673gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><span style="font-family:tahoma,sans-serif">Kindest,</span></div><div><span style="font-family:tahoma,sans-serif">Jonathan</span></div></div></div></div></div>
</div></font></span></div></div></div></div></div></div>
<br>______________________________<wbr>_________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.<wbr>riverbankcomputing.com/<wbr>mailman/listinfo/pyqt</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div>
</div>