简体   繁体   English

wxpython treectrl在悬停时显示位图图片

[英]wxpython treectrl show bitmap picture on hover

So i'm programming python program that uses wxPython for UI, with wx.TreeCtrl widget for selecting pictures(.png) on selected directory. 所以我正在编写使用wxPython for UI的python程序,并带有wx.TreeCtrl小部件,用于在所选目录上选择picture(.png)。 I would like to add hover on treectrl item that works like tooltip, but instead of text it shows bitmap picture. 我想在像工具提示一样工作的treectrl项目上添加悬停,但不是文本而是显示位图图片。

Is there something that already allows this, or would i have to create something with wxWidgets? 是否有已经允许这样做的东西,还是我必须使用wxWidgets创建东西?

I am not too familiar with wxWidgets, so if i have to create something like that how hard would it be, lot of code is already using the treectrl, so it needs to be able to work same way. 我对wxWidgets不太熟悉,因此如果我必须创建类似的代码,那么很多代码已经在使用treectrl,因此它必须能够以相同的方式工作。

So how would i have to go about doing this? 那么我该怎么做呢? And if there might be something i might be missing id be happy to know. 如果有什么我可能想念的身份证,我很高兴知道。

Take a look at the wx.lib.agw.supertooltip module. 看一下wx.lib.agw.supertooltip模块。 It should help you to create a tooltip-like window that displays custom rich content. 它应该可以帮助您创建一个类似于工具提示的窗口,以显示自定义的丰富内容。

As for triggering the display of the tooltip, you can catch mouse events for the tree widget (be sure to call Skip so the tree widget can see the events too) and reset a timer each time the mouse moves. 至于触发工具提示的显示,您可以捕获树小部件的鼠标事件(请确保调用“ Skip以便树小部件也可以看到事件)并在每次鼠标移动时重置计时器。 If the timer expires because the mouse hasn't been moved in that long then you can use tree.HitTest to find the item that the cursor is on and then show the appropriate image for that item. 如果计时器由于没有移动鼠标tree.HitTest长时间而过期,则可以使用tree.HitTest查找光标所在的项目,然后显示该项目的适当图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM