【问题标题】:How to display text beside cursor in tkinter Listbox如何在 tkinter 列表框中的光标旁边显示文本
【发布时间】:2018-09-22 21:51:33
【问题描述】:

我有这几行代码在double clicked 时打印Listbox 中的选定内容,但我想在cursor 旁边显示文本,例如double click the selected content to print,以提示用户在它可以之前采取此类操作打印出来。

我搜索了listbox documentation,发现它是一个属性光标,当小部件具有focus 时,您将其设置为cursor 类型以显示,但没有找到类似cursor-text 的内容来执行此操作。是我可以解决这个问题的方法,欢迎您提出建议。

from tkinter import *


def test(event=None):
    print("woow test works")
    print(l.get(ACTIVE))


root = Tk()

l = Listbox(root, cursor="tcross")
l.pack()
l.insert(END, ("today"),("tomorrow"))
l.bind("<Double-Button-1>", test)

root.mainloop()

【问题讨论】:

  • 你也许可以实现所谓的“工具提示”来做你想做的事情。例如,请参阅this。我认为用Listbox 本身来做到这一点,充其量是非常困难的,如果不是不可能的话。

标签: python tkinter


【解决方案1】:

我不太懂你的英语,但你可以看到 this page 的一个使用工具提示的示例,它使文本出现在鼠标悬停时。

【讨论】:

    猜你喜欢
    • 2022-11-18
    • 1970-01-01
    • 2022-07-08
    • 2014-09-14
    • 2023-02-22
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多