2

我目前正在尝试使用 Tix.Balloon 为图形用户界面中的选项创建工具提示和帮助状态栏。它几乎可以按预期工作。但是,我希望状态栏在鼠标不在绑定的小部件上时显示一条消息。

具体来说,当其中一个框未突出显示时,我希望状态栏显示“所有角度都以度为单位”之类的内容。

目前代码看起来有点像:

from Tkinter import *
from Tix import *
root = Tk()
status = Label(root, height = 3, width=30, bd=1,bg='yellow',wraplength = 210, text = "All angles are in degrees")
status.grid(row = 0,column = 0,pady = 10)
bal = Balloon(root,statusbar = status)
frame_1 = Frame(root,relief=RIDGE,bd = 2)
frame_1.grid(row=1,column = 0)
Angles = [StringVar(),StringVar()]

#Incomming
label_in = Label(frame_1,text = "TH_in")
label_in.grid(row = 0,column = 0)

entry_in = Entry(frame_1, width = 20, textvariable = Angles[0])
entry_in.grid(row = 0,column = 1)

#Outgoing
label_out = Label(frame_1,text = "TH_out")
label_out.grid(row = 1,column = 0)

entry_out = Entry(frame_1, width = 20, textvariable = Angles[1])
entry_out.grid(row=1,column=1)

#tool tip / status bar
bal.bind_widget(label_in,balloonmsg='Incidence Angle',statusmsg = 'Incidence angle of the incoming light with respect to the surface normal.')
bal.bind_widget(label_out,balloonmsg='Detector Angle',statusmsg = 'Angle between the surface normal and the detector')
root.mainloop()

这在开始时状态栏中有“所有角度都以度数”消息,但在标签中的状态消息之一替换它之后,它不会回来。

有什么建议么?

4

0 回答 0