Skip to content

Commit

Permalink
avoid overwriting self.layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerum committed Dec 3, 2024
1 parent e89a6f6 commit 1c38ea1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions saenopy/gui/common/QtShortCuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,13 +715,13 @@ def __init__(self, layout, name):
if layout is None and currentLayout() is not None:
layout = currentLayout()
layout.addWidget(self)
self.layout = QVBoxLayout(self)
self.layout_self = QVBoxLayout(self)

def __enter__(self):
return self, self.layout.__enter__()
return self, self.layout_self.__enter__()

def __exit__(self, exc_type, exc_val, exc_tb):
self.layout.__exit__(exc_type, exc_val, exc_tb)
self.layout_self.__exit__(exc_type, exc_val, exc_tb)

class QTabWidget(QtWidgets.QTabWidget):

Expand Down Expand Up @@ -776,8 +776,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):
class EnterableLayout:
def __enter__(self):
self.old_layout = currentLayout()
setCurrentLayout(self.layout)
return self.layout
setCurrentLayout(self.layout_self)
return self.layout_self

def __exit__(self, exc_type, exc_val, exc_tb):
setCurrentLayout(self.old_layout)
Expand All @@ -792,7 +792,7 @@ def __init__(self, parent=None, no_margins=False):
else:
super().__init__()
parent.addLayout(self)
self.layout = self
self.layout_self = self
if no_margins is True:
self.setContentsMargins(0, 0, 0, 0)

Expand All @@ -806,7 +806,7 @@ def __init__(self, parent=None, no_margins=False):
else:
super().__init__()
parent.addLayout(self)
self.layout = self
self.layout_self = self
if no_margins is True:
self.setContentsMargins(0, 0, 0, 0)

Expand Down Expand Up @@ -840,7 +840,7 @@ def __init__(self, *args):
super().__init__(*args)
if currentLayout() is not None:
currentLayout().addWidget(self)
self.layout = self
self.layout_self = self
self.widgets = []

def addLayout(self, layout):
Expand Down Expand Up @@ -1092,8 +1092,8 @@ def __init__(self, parent: QtWidgets.QWidget, map):
""" initialize the dialog with all the colormap of matplotlib """
QtWidgets.QDialog.__init__(self, parent)
main_layout = QtWidgets.QVBoxLayout(self)
self.layout = QtWidgets.QHBoxLayout()
main_layout.addLayout(self.layout)
self.layout_self = QtWidgets.QHBoxLayout()
main_layout.addLayout(self.layout_self)
button_layout = QtWidgets.QHBoxLayout()
main_layout.addLayout(button_layout)

Expand Down Expand Up @@ -1146,7 +1146,7 @@ def __init__(self, parent: QtWidgets.QWidget, map):
self.buttons.append(button)
layout.addWidget(button)
layout.addStretch()
self.layout.addLayout(layout)
self.layout_self.addLayout(layout)

def set_invert(self):
for button in self.buttons:
Expand Down
2 changes: 1 addition & 1 deletion saenopy/gui/common/gui_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def __init__(self, parent=None, title='', animationDuration=300, url=None):
self.label2.setStyleSheet("QPushButton { border: none; background: none; }")
self.label2.clicked.connect(lambda x: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url)))
self.child_widget = QtWidgets.QWidget().addToLayout()
self.layout = self
self.layout_self = self
self.value = self.toggleButton.value
#self.setValue = self.toggleButton.setValue
self.valueChanged = self.toggleButton.valueChanged
Expand Down

0 comments on commit 1c38ea1

Please sign in to comment.