def new_style(name, color=None, bold=None, italic=None, underline=None): style = self.doc.addStyle(name, self.parent_style) if color is not None: if isinstance(color, str): color = awtColor( int(color[0:2], 16), int(color[2:4], 16), int(color[4:6], 16) ) StyleConstants.setForeground(style, color) if bold is not None: StyleConstants.setBold(style, bold) if italic is not None: StyleConstants.setItalic(style, italic) if underline is not None: StyleConstants.setUnderline(style, underline) return style