-
Notifications
You must be signed in to change notification settings - Fork 0
Geometry
http://www.tutorialspoint.com/pyqt/pyqt_layout_management.htm
Only the pyqt4 to pyqt5 thing, needing to import PyQt5.QtWidgets.
Again, a couple things going on here. Back to the QWidget instead of the QDialog. Return of QPushButton.
Demonstration of QPushButton(String), which constructs a default button with the label specified as the parameter. Saves a setText() call. They are not immediately added to the QWidget container, as in the previous two lessons.
This is a demonstration of the QHBoxLayout and QVBoxLayout classes. The former uniformly arranges its contents in a horizontal row, scaling and translating Widgets to fit the available window; the latter arranges its contents into a vertical column. Objects are added with Layout.addWidget(Widget), without specifying geometry information. The order must be a FIFO queue, but the documentation will state how the internal order is handled and manipulated. The Layout object may include a 'stretch' whitespace object with Layout.addStretch(). Layout objects may be added to a Layout object, to create rows within those columns, for example. Once laid out, the 'root' Layout object is added to the 'window Widget' with Widget.setLayout(Layout).
Then it's setWindowTitle, show, exit(app.exec_()), and Bob's your uncle.
Want an organized grid? QGridLayout(), then addWidget(Widget, row, col). Buttons, at least, are scaled horizontally and spaced vertically.
Another 'commonly used layout' object. Create a QFormLayout(), then addRow(Widget, Widget). 'Layout' may be substituted for 'Widget', the whole polymorpyhism thing.
This adds a new control and revisits an old one.
- QLabel(String) makes a comeback.
- QRadioButton(String) is new.
- QLineEdit() is a new one, and creates a text input field.