I'm new to QGIS and Python and I want to know how to bold some text in a QTextBrowser. I'm using Ubuntu. I just tried these in the QGIS Python console but it doesn't give me the result.
>>> class color:
... PURPLE = '\033[95m'
... CYAN = '\033[96m'
... DARKCYAN = '\033[36m'
... BLUE = '\033[94m'
... GREEN = '\033[92m'
... YELLOW = '\033[93m'
... RED = '\033[91m'
... BOLD = '\033[1m'
... UNDERLINE = '\033[4m'
... END = '\033[0m'
>>> print color.BOLD + 'Hello World !' + color.END
ESC[1mHello World !ESC[0m
>>> import sys
>>> from termcolor import colored, cprint
>>> print colored('hello', 'red'), colored('world', 'green')
ESC[31mhelloESC[0m ESC[32mworldESC[0m
Please help me to find a solution to this problem.
QTextBrowser
is not a console. What you tried are console escapes. If you want to make the text bold in QTextBrowser
use the insertHtml
method inherited from QTextEdit
and use the appropriate HTML tags.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.