PyQt配置文本超链接样式
发布时间
阅读量:
阅读量
希望将PyQt控件中的文字内容配置为可点击的超链接形式,然而在查阅相关资料时发现,多数教程仅涉及如何在Label控件中实现该功能。为此,本人进行了自主尝试与研究。
以下是具体实现代码
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QHBoxLayout, QTextBrowser
def get_hyper_link(url):
# 这里的字体、颜色和大小都可以自定义
return f'<a href="{url}" style="color:#ffb61e;font-size:20px;font-family:Microsoft YaHei"><b>{url}</b></a>'
class UiDialog(QWidget):
def __init__(self):
super(UiDialog, self).__init__()
self.resize(500, 500)
self.output = QTextBrowser(self)
self.output.setTex
全部评论 (0)
还没有任何评论哟~
