def bgColorChange(self): """Handles change events to the background color.""" color = QColorDialog.getColor(QColor(*self.bgcolor), self) self.bgcolor = [ color.red(), color.green(), color.blue(), self.bgcolor[3] ] self.bgColorBox.setStyleSheet("QFrame {\n background-color: "\ + ColorMaps.rgbStylesheetString(self.bgcolor) + ";\n" + "border: 1px solid black;\n border-radius: 2px;\n }") self.mframe.agent.module_scene.background_color = np.array( [x / 255.0 for x in self.bgcolor]) self.mframe.agent.module_scene.announceChange() # Normally we shouldn't have to do this but when I try opening the # TabDialog with show() which gives back control, unfortunate things # can happen, so I use .exec_() which halts processing events # outside the dialog, so I force this color change here # Sadly this appears to only solve the problem for modules created # after this one. Will need to fix some other time... self.mframe.updateBGColor( self.mframe.agent.module_scene.background_color) QApplication.processEvents()
def buildBGColorWidget(self): """Creates the controls for altering the GL background colors.""" widget = QWidget() layout = QHBoxLayout() label = QLabel("Background Color") self.bgColorBox = ClickFrame(self, QFrame.Panel | QFrame.Sunken) self.bgColorBox.setLineWidth(0) self.bgColorBox.setMinimumHeight(12) self.bgColorBox.setMinimumWidth(36) self.bgColorBox.clicked.connect(self.bgColorChange) self.bgcolor = ColorMaps.gl_to_rgb( self.mframe.agent.module_scene.background_color) self.bgColorBox.setStyleSheet("QFrame {\n background-color: "\ + ColorMaps.rgbStylesheetString(self.bgcolor) + ";\n" + "border: 1px solid black;\n border-radius: 2px;\n }") layout.addWidget(label) layout.addItem(QSpacerItem(5, 5)) layout.addWidget(self.bgColorBox) widget.setLayout(layout) return widget
def buildBGColorWidget(self): """Creates the controls for altering the GL background colors.""" widget = QWidget() layout = QHBoxLayout() label = QLabel("Background Color") self.bgColorBox = ClickFrame(self, QFrame.Panel | QFrame.Sunken) self.bgColorBox.setLineWidth(0) self.bgColorBox.setMinimumHeight(12) self.bgColorBox.setMinimumWidth(36) self.bgColorBox.clicked.connect(self.bgColorChange) self.bgcolor = ColorMaps.gl_to_rgb( self.mframe.agent.module_scene.background_color) self.bgColorBox.setStyleSheet("QFrame {\n background-color: "\ + ColorMaps.rgbStylesheetString(self.bgcolor) + ";\n" + "border: 1px solid black;\n border-radius: 2px;\n }") layout.addWidget(label) layout.addItem(QSpacerItem(5,5)) layout.addWidget(self.bgColorBox) widget.setLayout(layout) return widget
def bgColorChange(self): """Handles change events to the background color.""" color = QColorDialog.getColor(QColor(*self.bgcolor), self) self.bgcolor = [color.red(), color.green(), color.blue(), self.bgcolor[3]] self.bgColorBox.setStyleSheet("QFrame {\n background-color: "\ + ColorMaps.rgbStylesheetString(self.bgcolor) + ";\n" + "border: 1px solid black;\n border-radius: 2px;\n }") self.mframe.agent.module_scene.background_color = np.array( [x / 255.0 for x in self.bgcolor]) self.mframe.agent.module_scene.announceChange() # Normally we shouldn't have to do this but when I try opening the # TabDialog with show() which gives back control, unfortunate things # can happen, so I use .exec_() which halts processing events # outside the dialog, so I force this color change here # Sadly this appears to only solve the problem for modules created # after this one. Will need to fix some other time... self.mframe.updateBGColor(self.mframe.agent.module_scene.background_color) QApplication.processEvents()