如何在 Tkinter 中顯示工具提示?
在需要在懸停在一個按鈕上時顯示一些資訊時,工具提示很有用。
為了建立和顯示一個工具提示,可以使用 Tkinter 的 Balloon 屬性。
示例
#Import the tkinter library
from tkinter import *
from tkinter.tix import *
#Create an instance of tkinter frame
win = Tk()
#Set the geometry
win.geometry("600x450")
#Create a tooltip
tip = Balloon(win)
#Create a Button widget
my_button=Button(win, text= "Hover Me")
my_button.pack(pady=20)
#Bind the tooltip with button
tip.bind_widget(my_button,balloonmsg="www.tutorialspoint.com")
win.mainloop()輸出
上面的程式碼將顯示一個帶有“將滑鼠懸停”按鈕的視窗。當用戶懸停在按鈕上時,將顯示一個工具提示文字。

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP