def __init__(self, parent, fmto, artist=None, base=None):
        """
        Parameters
        ----------
        %(FontWeightWidget.parameters)s
        """
        QWidget.__init__(self, parent)
        hbox = QHBoxLayout()
        if artist is not None:
            self.current_font = self.artist_to_qfont(artist)
            self.current_color = QtGui.QColor.fromRgbF(
                *mcol.to_rgba(artist.get_color()))
        else:
            self.current_color = QtGui.QColor(Qt.black)
        self.fmto_name = fmto.name or fmto.key

        # choose font button
        button = QPushButton('Choose font')
        button.clicked.connect(partial(self.choose_font, None))
        hbox.addWidget(button)

        # font size spin box
        self.spin_box = spin_box = QSpinBox(self)
        spin_box.setRange(1, 1e9)
        if artist is not None:
            spin_box.setValue(int(artist.get_size()))
        spin_box.valueChanged.connect(self.modify_size)
        hbox.addWidget(spin_box)

        # font color button
        self.btn_font_color = button = QToolButton(self)
        button.setIcon(QIcon(get_icon('font_color.png')))
        button.clicked.connect(partial(self.choose_color, None))
        hbox.addWidget(button)

        # bold button
        self.btn_bold = button = QToolButton(self)
        button.setIcon(QIcon(get_icon('bold.png')))
        button.clicked.connect(self.toggle_bold)
        button.setCheckable(True)
        if artist is not None:
            button.setChecked(self.current_font.weight() > 50)
        hbox.addWidget(button)

        # italic button
        self.btn_italic = button = QToolButton(self)
        button.setIcon(QIcon(get_icon('italic.png')))
        button.clicked.connect(self.toggle_italic)
        button.setCheckable(True)
        if artist is not None:
            button.setChecked(self.current_font.italic())
        hbox.addWidget(button)

        if base is not None:
            # add a button to change to the base formatoption
            fmtos = [
                base,
                getattr(fmto.plotter, base.key + 'size', None),
                getattr(fmto.plotter, base.key + 'weight', None),
                ]
            fmtos = list(filter(None, fmtos))
            hbox.addWidget(Switch2FmtButton(parent, *fmtos))

        self.setLayout(hbox)
def __init__ ( self , parent , fmto , artist = None , base = None ) : QWidget . __init__ ( self , parent ) hbox = QHBoxLayout ( ) if artist is not None : self . current_font = self . artist_to_qfont ( artist ) self . current_color = QtGui . QColor . fromRgbF ( * mcol . to_rgba ( artist . get_color ( ) ) ) else : self . current_color = QtGui . QColor ( Qt . black ) self . fmto_name = fmto . name or fmto . key button = QPushButton ( 'Choose font' ) button . clicked . connect ( partial ( self . choose_font , None ) ) hbox . addWidget ( button ) self . spin_box = spin_box = QSpinBox ( self ) spin_box . setRange ( 1 , 1e9 ) if artist is not None : spin_box . setValue ( int ( artist . get_size ( ) ) ) spin_box . valueChanged . connect ( self . modify_size ) hbox . addWidget ( spin_box ) self . btn_font_color = button = QToolButton ( self ) button . setIcon ( QIcon ( get_icon ( 'font_color.png' ) ) ) button . clicked . connect ( partial ( self . choose_color , None ) ) hbox . addWidget ( button ) self . btn_bold = button = QToolButton ( self ) button . setIcon ( QIcon ( get_icon ( 'bold.png' ) ) ) button . clicked . connect ( self . toggle_bold ) button . setCheckable ( True ) if artist is not None : button . setChecked ( self . current_font . weight ( ) > 50 ) hbox . addWidget ( button ) self . btn_italic = button = QToolButton ( self ) button . setIcon ( QIcon ( get_icon ( 'italic.png' ) ) ) button . clicked . connect ( self . toggle_italic ) button . setCheckable ( True ) if artist is not None : button . setChecked ( self . current_font . italic ( ) ) hbox . addWidget ( button ) if base is not None : fmtos = [ base , getattr ( fmto . plotter , base . key + 'size' , None ) , getattr ( fmto . plotter , base . key + 'weight' , None ) , ] fmtos = list ( filter ( None , fmtos ) ) hbox . addWidget ( Switch2FmtButton ( parent , * fmtos ) ) self . setLayout ( hbox )
Parameters
        ----------
        %(FontWeightWidget.parameters)s