Example #1
0
    def set_selected(self, selected):
        """Adjust the style sheet to indicate selection or not"""
        if selected:
            p = QtGui.QPalette()
            highlight_col = p.color(QtGui.QPalette.Active,
                                    QtGui.QPalette.Highlight)

            border = "rgb(%s, %s, %s)" % (
                highlight_col.red(),
                highlight_col.green(),
                highlight_col.blue(),
            )
            background = "rgba(%s, %s, %s, 25%%)" % (
                highlight_col.red(),
                highlight_col.green(),
                highlight_col.blue(),
            )
            self.ui.widget_frame.setStyleSheet("""
                #widget_frame {
                    border: 1px solid %s;
                    background-color: %s;
                }
            """ % (border, background))
        else:
            self.ui.widget_frame.setStyleSheet("""
                #widget_frame {
                    border: 1px solid transparent;
                }
            """)

        # force a refresh of the stylesheet
        self.ui.widget_frame.style().unpolish(self.ui.widget_frame)
        self.ui.widget_frame.style().polish(self.ui.widget_frame)
        self.ui.widget_frame.update()
Example #2
0
    def set_selected(self, selected):
        """ Update the styling to reflect if the widget is selected or not """
        if selected:
            p = QtGui.QPalette()
            highlight_col = p.color(QtGui.QPalette.Active,
                                    QtGui.QPalette.Highlight)

            transp_highlight_str = "rgba(%s, %s, %s, 25%%)" % \
                (highlight_col.red(), highlight_col.green(), highlight_col.blue())
            highlight_str = "rgb(%s, %s, %s)" % \
                (highlight_col.red(), highlight_col.green(), highlight_col.blue())

            # make a border around the cell
            self.setStyleSheet("""#frame {
                    border-width: 2px;
                    border-color: %s;
                    border-style: solid;
                    background-color: %s;
                   }
                """ % (highlight_str, transp_highlight_str))
        else:
            self.setStyleSheet("""#frame {
                      border-width: 2px;
                      border-color: transparent;
                      border-style: solid;
                }""")
    def set_selected(self, selected):
        """
        Adjust the style sheet to indicate selection or not
        """
        p = QtGui.QPalette()
        highlight_col = p.color(QtGui.QPalette.Active,
                                QtGui.QPalette.Highlight)

        transp_highlight_str = "rgba(%s, %s, %s, 25%%)" % (
            highlight_col.red(), highlight_col.green(), highlight_col.blue())
        highlight_str = "rgb(%s, %s, %s)" % (
            highlight_col.red(), highlight_col.green(), highlight_col.blue())

        if selected:
            # make a border around the cell
            self.ui.box.setStyleSheet("""#box {border-width: 2px; 
                                                 border-color: %s; 
                                                 border-style: solid; 
                                                 background-color: %s}
                                      """ %
                                      (highlight_str, transp_highlight_str))
        else:
            self.ui.box.setStyleSheet("")