def finish_group(): # Finish the existing group debug_print('Finishing', current_group) # The widget that holds this group's controls controls_widget = QWidget() controls_widget.setLayout(group_layout) controls_widget.setVisible(False) # The group box, which contains the label to toggle the controls# # and the controls themselves group_box_layout = QVBoxLayout() group_box_layout.addWidget( ToggleWidgetLabel(current_group, controls_widget)) group_box_layout.addWidget(controls_widget) group_box = QGroupBox() group_box.setLayout(group_box_layout) # Add the group box to the main layout self._main_layout.addRow(group_box) #self._main_layout.addWidget(group_box) groups[current_group] = group_box
class TransformationParameterWidget(QWidget): """ TransformationParameterWidget """ def __init__(self): super(TransformationParameterWidget, self).__init__() self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(self.cancelButtonClicked) self.applyButton = QPushButton("Apply") self.applyButton.clicked.connect(self.applyButtonClicked) self.mainLayout = QGridLayout() self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.widget = QWidget() self.widget.setLayout(self.mainLayout) self.showControls(False) self.transformationWidget = None layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(self.widget, 0, 0, 1, 2) layout.addWidget(self.cancelButton, 1, 0) layout.addWidget(self.applyButton, 1, 1) self.setLayout(layout) def setTransformationTool(self, transformationTool): self.transformationTool = transformationTool self.cleanUpTransformWidget() self.transformationWidget = self.transformationTool.getParameterWidget() self.mainLayout.addWidget(self.transformationWidget) self.showControls(True) @Slot() def cancelButtonClicked(self): """ Cancels the transform and hides the apply / cancel buttons """ self.showControls(False) self.cleanUpTransformWidget() self.transformationTool.cancelTransform() self.transformationTool.cleanUp() self.transformationTool = None @Slot() def applyButtonClicked(self): """ Applies the transform and hides the apply / cancel buttons """ self.showControls(False) self.cleanUpTransformWidget() self.transformationTool.applyTransform() self.transformationTool.cleanUp() self.transformationTool = None def showControls(self, show): self.widget.setVisible(show) self.applyButton.setVisible(show) self.cancelButton.setVisible(show) def cleanUpTransformWidget(self): item = self.mainLayout.takeAt(0) if item: item.widget().deleteLater()
def testBasic(self): # Also related to bug #244, on existence of setVisible''' widget = QWidget() self.assert_(not widget.isVisible()) widget.setVisible(True) self.assert_(widget.isVisible())