简体   繁体   English

是否可以在 Windows 10 通知(python win10toast 模块)中加下划线/粗体文本?

[英]Is it possible to underline/bold text in a Windows 10 Notification (python win10toast module)?

I am developing a program that generates a notification upon completion.我正在开发一个在完成时生成通知的程序。 It is clickable and I would like to exaggerate this by underlining or bolding "Click here" in the notification.它是可点击的,我想通过在通知中加下划线或加粗“点击此处”来夸大这一点。 Is this possible?这可能吗? If it's not a feature in win10toast, is there another module I could use?如果它不是 win10toast 中的一个功能,我可以使用另一个模块吗?

try:尝试:

from win10toast import ToastNotifier

def return_with_underline(x):
    lst1 = []
    for letter in x:
        if letter != ' ':
            lst1.append(letter)
            lst1.append('\u0332')
        else:
            lst1.append(letter)
    return '{:s}'.format(''.join(lst1))

toaster = ToastNotifier()

toaster.show_toast(return_with_underline('Click Here!'), "Hi", icon_path=None, duration=5)

This is not perfect (does not work with spaces), but you can use other Unicode characters too, instead of \̣2这并不完美(不适用于空格),但您也可以使用其他 Unicode 字符,而不是\̣2

Got this from here (they are talking about plain strings but it works here too):从这里得到这个(他们谈论的是普通字符串,但它也适用于这里):

Python: String formatter to get underlined headline Python:字符串格式化程序以获得带下划线的标题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM