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

List:       pykde
Subject:    [PyQt] Testing widget visibility
From:       Grzegorz Bokota <g.bokota () mimuw ! edu ! pl>
Date:       2020-01-20 12:52:38
Message-ID: CADUBGeRET9CH7i-v+daK_6u1jC-COy92EeRAosKFvzh58MJeCQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


in my program I have widget which visibility which visibility is controlled
by some variable in internal settings object. In this case I meet verid bug
that it works on Linux (my main system) but does not work on Windows and
Macos. Due to this I would like to cover it with my test.

Control of this variable state is such that I cannot connect setVisible to
stateChanged of control Widget. But this change is done when widow with
widget is inactive.
My current code is

def event(self, event: QEvent):
    if event.type() == QEvent.WindowActivate:
        self.widget.setVisible(self.settings.control_variable)
    return super().event(event)

And this works for all system (problem with multiple system were connected
with setting this variable), but when I try to test it using pytest and
pytest-qt the test fail because widget visibility does not change. I try to
use qtbot.waitActive and similar.

Anyone of you meet with such problem and can suggest how to write test
which allow to test changing widget visibility, when it changes on windows
activation?

Regards,
Grzegorz Bokota

[Attachment #5 (text/html)]

<div dir="ltr"><div>in my program I have widget which visibility which visibility is \
controlled by some variable in internal settings object. In this case I meet verid \
bug that it works on Linux (my main system) but does not work on Windows and Macos. \
Due to this I would like to cover it with my test. \
<br></div><div><br></div><div>Control of this variable state is such that I cannot \
connect <font face="monospace">setVisible</font> to <font \
face="monospace">stateChanged</font> of control Widget. But this change is done when \
widow with widget is inactive. <br></div><div>My current code \
is</div><div><div><br></div><div> <pre \
style="background-color:rgb(39,40,34);color:rgb(248,248,242);font-family:&quot;JetBrains \
Mono Medium&quot;"><span style="color:rgb(102,217,239);font-style:italic">def \
</span><span style="color:rgb(166,226,46)">event</span>(<span \
style="color:rgb(148,85,141)">self</span>, <span \
style="color:rgb(253,151,31);font-style:italic">event</span><span \
style="color:rgb(249,38,114)">: </span>QEvent)<span \
style="color:rgb(249,38,114)">:<br></span><span style="color:rgb(249,38,114)">    \
</span><span style="color:rgb(102,217,239);font-style:italic">if </span><span \
style="color:rgb(253,151,31);font-style:italic">event</span>.<span \
style="color:rgb(102,217,239)">type</span>() <span style="color:rgb(249,38,114)">== \
</span>QEvent.WindowActivate<span style="color:rgb(249,38,114)">:<br></span><span \
style="color:rgb(249,38,114)">        </span><span \
style="color:rgb(148,85,141)">self</span>.widget.<span \
style="color:rgb(102,217,239)">setVisible</span>(<span \
style="color:rgb(148,85,141)">self</span>.settings.control_variable)<br>    <span \
style="color:rgb(102,217,239);font-style:italic">return </span><span \
style="color:rgb(102,217,239)">super</span>().<span \
style="color:rgb(102,217,239)">event</span>(<span \
style="color:rgb(253,151,31);font-style:italic">event</span>)</pre></div></div><div>And \
this works for all system (problem with multiple system were connected with setting \
this variable), but when I try to test it using <font face="monospace">pytest</font> \
and <font face="monospace">pytest-qt</font> the test fail because widget visibility \
does not change. I try to use <span \
style="font-family:monospace">qtbot.waitActive</span> and similar. \
<br></div><div><br></div><div>Anyone of you meet with such problem and can suggest \
how to write test which allow to test changing widget visibility, when it changes on \
windows activation? <br></div><div><br></div><div>Regards,</div><div>Grzegorz \
Bokota<br></div><div></div></div>


[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