Created
March 13, 2023 23:30
-
-
Save ChristianOConnor/24626d28b4a12c45012279718eab3626 to your computer and use it in GitHub Desktop.
Example Fix for, How do I add widgets to the top left of Pyside Qt layout instead of having the items centered and evenly spaced?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wid = QtWidgets.QWidget() | |
grid = QtWidgets.QVBoxLayout(wid) | |
# setting the inner widget and layout | |
grid_inner = QtWidgets.QVBoxLayout(wid) | |
wid_inner = QtWidgets.QWidget(wid) | |
wid_inner.setLayout(grid_inner) | |
# add the inner widget to the outer layout | |
grid.addWidget(wid_inner) | |
# add tab frame to widget | |
wid_inner.tab = QtWidgets.QTabWidget(wid_inner) | |
grid_inner.addWidget(wid_inner.tab) | |
# create tab | |
new_tab_area = QtWidgets.QWidget(wid_inner.tab) | |
new_tab = QtWidgets.QScrollArea(new_tab_area) | |
grid_tab_1 = QtWidgets.QVBoxLayout(new_tab_area) | |
new_tab.tab_name_private = "test1" | |
wid_inner.tab.addTab(new_tab, "test1") | |
for idx, tx in enumerate(self.log): | |
fname_array = (tx.file_name).split('/') | |
btn = QtWidgets.QPushButton(str(idx) + ' ' + fname_array[(len(fname_array)) - 1]) | |
btn.clicked.connect(lambda checked=False, x=idx: self.display_transaction(x)) | |
grid_tab_1.addWidget(btn) | |
# create tab 2 | |
new_tab_area2 = QtWidgets.QWidget(wid_inner.tab) | |
new_tab2 = QtWidgets.QScrollArea(new_tab_area2) | |
grid_tab_2 = QtWidgets.QVBoxLayout(new_tab_area2) | |
wid_inner.tab.addTab(new_tab2, "test2") | |
for idx, tx in enumerate(self.log): | |
fname_array = (tx.file_name).split('/') | |
btn = QtWidgets.QPushButton(str(idx) + ' ' + fname_array[(len(fname_array)) - 1]) | |
btn.clicked.connect(lambda checked=False, x=idx: self.display_transaction(x)) | |
grid_tab_2.addWidget(btn) | |
continue_btn = QtWidgets.QPushButton("Ok") | |
self.layout = QtWidgets.QVBoxLayout() | |
self.layout.addWidget(wid) | |
self.layout.addWidget(continue_btn) | |
self.setLayout(self.layout) | |
continue_btn.clicked.connect(self.continue_to_main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment