格式 Python 字符串 - messagebox:tkinter
Format Python String - messagebox:tkinter
我希望以下字符串中的This is a help message:
显示为粗体。
help_message = """This is a help message:
Demo!"""
tk.messagebox.showinfo('Help', help_message)
这可以用 """{}content""".format('some_style_string')
完成吗?
我看到其他示例使用如下代码:
class color:
PURPLE = '3[95m'
CYAN = '3[96m'
DARKCYAN = '3[36m'
BLUE = '3[94m'
GREEN = '3[92m'
YELLOW = '3[93m'
RED = '3[91m'
BOLD = '3[1m'
UNDERLINE = '3[4m'
END = '3[0m'
但是所有的例子似乎都涉及到print的使用。
Can this be done with """{}content""".format('some_style_string')
不,不能。 tk.messagebox
无法显示样式文本。
I have seen other examples use code like the following...
不,那也不行。这些是转义码,旨在由 ansi 终端(或 curses
包)解释。
如果您想要带样式的文本,则必须使用 Toplevel
和一些文本、标签或 canvas 小部件创建自己的对话框。
我希望以下字符串中的This is a help message:
显示为粗体。
help_message = """This is a help message:
Demo!"""
tk.messagebox.showinfo('Help', help_message)
这可以用 """{}content""".format('some_style_string')
完成吗?
我看到其他示例使用如下代码:
class color:
PURPLE = '3[95m'
CYAN = '3[96m'
DARKCYAN = '3[36m'
BLUE = '3[94m'
GREEN = '3[92m'
YELLOW = '3[93m'
RED = '3[91m'
BOLD = '3[1m'
UNDERLINE = '3[4m'
END = '3[0m'
但是所有的例子似乎都涉及到print的使用。
Can this be done with """{}content""".format('some_style_string')
不,不能。 tk.messagebox
无法显示样式文本。
I have seen other examples use code like the following...
不,那也不行。这些是转义码,旨在由 ansi 终端(或 curses
包)解释。
如果您想要带样式的文本,则必须使用 Toplevel
和一些文本、标签或 canvas 小部件创建自己的对话框。