如何在tkinter中创建MacOS的帮助按钮?

2024-04-29 13:40:32 发布

您现在位置:Python中文网/ 问答频道 /正文

Human Interface Guidelines描述了一个与众不同的帮助按钮,它的设计与普通的tkinter按钮不同。我的问题很简单,我能在tkinter中创建这个按钮吗?我查看了effbot上的tkinter文档,但什么也没找到


Tags: 文档tkinter按钮interfacehumanguidelineseffbot
1条回答
网友
1楼 · 发布于 2024-04-29 13:40:32

您可以制作一个按钮,在其上放置一个问号图像,并将边框设置为0

举个例子:

from tkinter import *

root = Tk()
root.config(bg="light grey")
helpim = PhotoImage(file="help.gif")

help = Button(root, bd=0, bg="light grey")
help["activebackground"] = "light grey"
help.config(image=helpim)
help.pack()

root.mainloop()

这是我使用的问号图像:

enter image description here

您可以为按钮分配一个命令,以将帮助显示为dialog message box
输出:

enter image description here

相关问题 更多 >