def __setupTab(self, name, layout): main_widget = QtWidgets.QWidget() w = QtWidgets.QWidget() w.setLayout(layout) scroll_area = QtWidgets.QScrollArea() scroll_area.setFocusPolicy(QtCore.Qt.NoFocus) scroll_area.setWidgetResizable(True) scroll_area.setWidget(w) layout = QtWidgets.QVBoxLayout() layout.addWidget(scroll_area) main_widget.setLayout(layout) self.tab.addTab(main_widget, name)
def _setupWindow(self): centralWidget = QtWidgets.QWidget(self) self.setCentralWidget(centralWidget) self._mainLayout = QtWidgets.QVBoxLayout(centralWidget) self._mainLayout.setContentsMargins(2, 2, 2, 2) centralWidget.setLayout(self._mainLayout) self.parentWidget = QtWidgets.QGroupBox() self.parentWidget.setObjectName("parentWidgetBox") centralWidget.setObjectName('centralWidget') self._mainLayout.setObjectName('baseMainLayout') self._mainLayout.addWidget(self.parentWidget) self.setMenuBar(self.menuBar) self.statusBar()
def addControl(self, name, control, attribute, default=None): buttonHeight = 18 widget = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(2) widget.setLayout(layout) label = QtWidgets.QLabel(name) incrementButton = QtWidgets.QPushButton('Increment') randomButton = QtWidgets.QPushButton('Random') setButton = QtWidgets.QPushButton('Set') incrementButton.setFixedSize(self.controlButtonWidth / 3, buttonHeight) randomButton.setFixedSize(self.controlButtonWidth / 3, buttonHeight) setButton.setFixedSize(self.controlButtonWidth / 3, buttonHeight) # Adding Widgets layout.addWidget(label) if control == 'intSlider': control = QtWidgets.QDoubleSpinBox() elif control == 'floatSlider': control = QtWidgets.QDoubleSpinBox() elif control == 'colorSlider': control = QtWidgets.QPushButton() if control and isinstance(control, dict): incrementButton.setVisible(False) randomButton.setVisible(False) setButton.setVisible(False) count = len(control) for key, value in control.iteritems(): button = QtWidgets.QPushButton(key) button.setFixedSize(self.controlButtonWidth / count, buttonHeight) button.setProperty('attribute', attribute) button.setProperty('value', value) self.Signal.addSignal(button, 'clicked', self.controlSignalEvent) layout.addWidget(button) elif control == 'custom': if attribute == 'aiSssSetname' or attribute == 'aiAov': incrementButton.setVisible(False) randomButton.setVisible(False) control = QtWidgets.QLineEdit() control.setFixedSize(self.controlButtonWidth / 2, buttonHeight) setButton.setFixedSize(self.controlButtonWidth / 2, buttonHeight) setButton.setProperty('control', control) setButton.setProperty('attribute', attribute) self.Signal.addSignal(setButton, 'clicked', self.controlSignalEvent) layout.addWidget(control) elif attribute == 'color' or attribute == 'lightColor': incrementButton.setVisible(False) randomButton.setVisible(False) control.setFixedWidth(70) layout.addItem( QtWidgets.QSpacerItem(73, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)) layout.addWidget(control) layout.addItem( QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)) control.setStyleSheet('QPushButton {background-color: white}') control.setProperty('red', 1) control.setProperty('green', 1) control.setProperty('blue', 1) self.Signal.addSignal(control, 'clicked', self.colorPickerEvent) self.Signal.addSignal(setButton, 'clicked', self.controlSignalEvent) setButton.setProperty('control', control) setButton.setProperty('attribute', attribute) elif control: if attribute == 'renderSmoothLevel': self._setupControlWidgetDefaults(control, default, precision=0, minV=0, maxV=7) elif attribute in [ 'aiSubdivIterations', 'aiSamples', 'aiColorTemperature', 'aiVolumeSamples', 'temperature', 'fixedSampleCount' ]: defaultValue = 1 if attribute == 'aiColorTemperature' or attribute == 'temperature': defaultValue = 6500 self._setupControlWidgetDefaults(control, defaultValue, precision=0, minV=0) elif attribute in [ 'aiDispHeight', 'intensity', 'aiDiffuse', 'aiSpecular', 'aiSss', 'aiIndirect', 'aiVolume', 'aiSpread', 'diffuse', 'specular' ]: self._setupControlWidgetDefaults(control, 1) else: self._setupControlWidgetDefaults(control, default) self.Signal.addSignal(incrementButton, 'clicked', self.controlSignalEvent) self.Signal.addSignal(randomButton, 'clicked', self.controlSignalEvent) self.Signal.addSignal(setButton, 'clicked', self.controlSignalEvent) incrementButton.setProperty('attribute', attribute) randomButton.setProperty('attribute', attribute) setButton.setProperty('attribute', attribute) incrementButton.setProperty('control', control) setButton.setProperty('control', control) layout.addWidget(control) layout.addWidget(incrementButton) layout.addWidget(randomButton) layout.addWidget(setButton) return widget