<div dir="ltr"><div>Hi Rich,</div><div><br></div><div>It seems your object 'bio' is not being used after creation so it won't have an effect.</div><div><br></div><div>I've changed your code to subclass from QMainWindow, and added a statement self.setCentralWidget(container), and it now seem to be doing what you want. Please let me know if that's not true.</div><div><br></div><div>Rodrigo</div><div><pre style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(140,140,140);font-style:italic">#!/usr/bin/env python3<br></span><span style="color:rgb(140,140,140);font-style:italic"><br></span><span style="color:rgb(0,51,179)">import </span>sys<br><br><span style="color:rgb(0,51,179)">from </span>PyQt5 <span style="color:rgb(0,51,179)">import </span>QtWidgets <span style="color:rgb(0,51,179)">as </span>qtw<br><span style="color:rgb(0,51,179)">from </span>PyQt5 <span style="color:rgb(0,51,179)">import </span>QtGui <span style="color:rgb(0,51,179)">as </span>qtg<br><span style="color:rgb(0,51,179)">from </span>PyQt5 <span style="color:rgb(0,51,179)">import </span>QtCore <span style="color:rgb(0,51,179)">as </span>qtc<br><span style="color:rgb(0,51,179)">from </span>PyQt5.QtWidgets <span style="color:rgb(0,51,179)">import </span>QMainWindow<br><br><br><span style="color:rgb(0,51,179)">class </span><span style="color:rgb(0,0,0)">TestWindow</span>(QMainWindow):<br> <span style="color:rgb(0,51,179)">def </span><span style="color:rgb(178,0,178)">__init__</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(0,0,128)">super</span>().<span style="color:rgb(178,0,178)">__init__</span>()<br> <span style="color:rgb(128,128,128)">bio </span>= qtw.QWidget(<span style="color:rgb(102,0,153)">windowTitle</span>=<span style="color:rgb(0,128,128);font-weight:bold">'Test'</span>, <span style="color:rgb(102,0,153)">width </span>= <span style="color:rgb(23,80,235)">800</span>, <span style="color:rgb(102,0,153)">height </span>= <span style="color:rgb(23,80,235)">600</span>)<br><br> <span style="color:rgb(140,140,140);font-style:italic"># Layout<br></span><span style="color:rgb(140,140,140);font-style:italic"> </span>container = qtw.QWidget(<span style="color:rgb(148,85,141)">self</span>)<br> group1 = qtw.QGridLayout()<br> container.setLayout(group1)<br><br> savebutton = qtw.QPushButton(<span style="color:rgb(0,128,128);font-weight:bold">'Save'</span>)<br> savebutton.clicked.connect(<span style="color:rgb(148,85,141)">self</span>.save)<br> group1.addWidget(savebutton, <span style="color:rgb(23,80,235)">0</span>, <span style="color:rgb(23,80,235)">0</span>)<br><br> cancelbutton = qtw.QPushButton(<span style="color:rgb(0,128,128);font-weight:bold">'Cancel'</span>)<br> cancelbutton.clicked.connect(<span style="color:rgb(148,85,141)">self</span>.cancel)<br> group1.addWidget(cancelbutton, <span style="color:rgb(23,80,235)">0</span>, <span style="color:rgb(23,80,235)">1</span>)<br><br> <span style="color:rgb(148,85,141)">self</span>.setCentralWidget(container)<br><br> <span style="color:rgb(148,85,141)">self</span>.show()<br><br> <span style="color:rgb(140,140,140);font-style:italic"># Methods<br></span><span style="color:rgb(140,140,140);font-style:italic"> </span><span style="color:rgb(0,51,179)">def </span><span style="color:rgb(0,0,0)">save</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(0,51,179)">pass<br></span><span style="color:rgb(0,51,179)"><br></span><span style="color:rgb(0,51,179)"> def </span><span style="color:rgb(0,0,0)">cancel</span>(<span style="color:rgb(148,85,141)">self</span>):<br> <span style="color:rgb(0,51,179)">pass<br></span><span style="color:rgb(0,51,179)"><br></span><span style="color:rgb(0,51,179)"><br></span><span style="color:rgb(0,51,179)">if </span>__name__ == <span style="color:rgb(0,128,128);font-weight:bold">'__main__'</span>:<br> app = qtw.QApplication(sys.argv)<br> bio = TestWindow()<br> sys.exit(app.exec())<br><br><br></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 22, 2021 at 1:06 PM Rich Shepard <<a href="mailto:rshepard@appl-ecosys.com">rshepard@appl-ecosys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Looking in my two PyQt5 books and on the Web I'm not seeing how to<br>
successfully set a QWidget main window's size. Test code attached.<br>
<br>
The overall application will use a QMainWindow with a QTabWidget. Individual<br>
pages have a QWidget as the container (unless my understanding is flawed).<br>
I've tried to add width and height to the attached testgrid.py and it loads<br>
without error, but as a very small window. My readings and web searches<br>
haven't let me find the proper syntax to set a default initial window size<br>
for each tab's contant to 800x600 (unless they need to be smaller to fit on<br>
the QTabWidget in a QMainWindow.<br>
<br>
I've also tried qtc.QSize(800,600) without success.<br>
<br>
What's the proper syntax to open the test application at a size of 800x600?<br>
<br>
TIA,<br>
<br>
Rich<br>
</blockquote></div>