<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:12.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=FR link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>I ran in a strange behavior where widgets in the view aren’t properly refreshed on change.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>Here is the code, developed to show the problem:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='background:white'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>import </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>sys<br><br></span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>from </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>PyQt5 </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>import </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>QtWidgets<br></span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>from </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>PyQt5.QtCore </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>import </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>Qt<br><br><br></span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>class </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:FR'>MainWindow</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>(QtWidgets.QMainWindow):<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>def </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#B200B2;mso-fareast-language:FR'>__init__</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>):<br> QtWidgets.QMainWindow.</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#B200B2;mso-fareast-language:FR'>__init__</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.resize(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#1750EB;mso-fareast-language:FR'>250</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>, </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#1750EB;mso-fareast-language:FR'>100</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.setWindowTitle(</span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:teal;mso-fareast-language:FR'>"Demo"</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.centralWidget = QtWidgets.QWidget(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.formlayout = QtWidgets.QFormLayout(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.centralWidget)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.label1 = QtWidgets.QLabel(</span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:teal;mso-fareast-language:FR'>'Text 1'</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>, </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.centralWidget)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.ledit1 = QtWidgets.QLineEdit(</span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:teal;mso-fareast-language:FR'>'initial value'</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>, </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.centralWidget)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.bproceed = QtWidgets.QPushButton(</span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:teal;mso-fareast-language:FR'>'Proceed'</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>, </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.centralWidget)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.bproceed.setDefault(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>True</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.bproceed.setFocusPolicy(Qt.StrongFocus)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.formlayout.setWidget(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#1750EB;mso-fareast-language:FR'>1</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>, QtWidgets.QFormLayout.LabelRole, </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.label1)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.formlayout.setWidget(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#1750EB;mso-fareast-language:FR'>1</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>, QtWidgets.QFormLayout.FieldRole, </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.ledit1)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.formlayout.setWidget(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#1750EB;mso-fareast-language:FR'>2</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>, QtWidgets.QFormLayout.FieldRole, </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.bproceed)<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.setCentralWidget(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.centralWidget)<br><br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.bproceed.clicked.connect(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.on_clicked)<br><br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>def </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:FR'>on_clicked</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>):<br> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#94558D;mso-fareast-language:FR'>self</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>.ledit1.setText(</span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:teal;mso-fareast-language:FR'>''</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>)<br></span><i><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#8C8C8C;mso-fareast-language:FR'><br><br></span></i><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-fareast-language:FR'>if </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>__name__ == </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:teal;mso-fareast-language:FR'>"__main__"</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#080808;mso-fareast-language:FR'>:<br> app = QtWidgets.QApplication(sys.argv)<br> win = MainWindow()<br> win.show()<br> sys.exit(app.exec())<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>If the pushbutton is clicked with the mouse or with the space key (after getting the focus with Tab), the text in the lineedit is not refreshed. If a repaint is forced, it is.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>If the pushbutton is clicked with the enter key (after getting the focus with Tab), the text in the lineedit is correctly refreshed.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>Any idea?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>My env:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>OSX Catalina 10.15.5<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>Python 3.6<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>PyQt: 15.0<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt'>Thank you<o:p></o:p></span></p></div></body></html>