def update_format(self):
        """
        Update the font format toolbar/actions when a new text selection is made. This is necessary to keep
        toolbars/etc. in sync with the current edit state.
        :return:
        """
        # Disable signals for all format widgets, so changing values here does not trigger further formatting.
        self.block_signals(self._format_actions, True)

        self.fonts.setCurrentFont(self.editor.currentFont())
        # Nasty, but we get the font-size as a float but want it was an int
        self.fontsize.setCurrentText(str(int(self.editor.fontPointSize())))

        self.italic_action.setChecked(self.editor.fontItalic())
        self.underline_action.setChecked(self.editor.fontUnderline())
        self.bold_action.setChecked(self.editor.fontWeight() == QFont.Weight.Bold)

        self.alignl_action.setChecked(self.editor.alignment() == Qt.AlignmentFlag.AlignLeft)
        self.alignc_action.setChecked(self.editor.alignment() == Qt.AlignmentFlag.AlignCenter)
        self.alignr_action.setChecked(self.editor.alignment() == Qt.AlignmentFlag.AlignRight)
        self.alignj_action.setChecked(self.editor.alignment() == Qt.AlignmentFlag.AlignJustify)

        self.block_signals(self._format_actions, False)

        Update the font format toolbar/actions when a new text selection is made. This is necessary to keep
        toolbars/etc. in sync with the current edit state.
        :return:
        
pyside2/demos/wordprocessor/main.py