pyRevit
pyRevit copied to clipboard
[Bug]: Tooltip images not displaying
✈ Pre-Flight checks
- [X] I don't have SentinelOne antivirus installed (see above for the solution)
- [X] I have searched in the issues (open and closed) but couldn't find a similar issue
- [X] I have searched in the pyRevit Forum for similar issues
- [X] I already followed the installation troubleshooting guide thoroughly
- [X] I am using the latest pyRevit Version
🐞 Describe the bug
"tooltip.png" in bundle folders is not displaying on hover, this appears to be the same problem as in #1265, but for images rather than video. Below is my solution, which was to copy the code from set_tooltip_video()
to set_tooltip()
, and revise to use Windows Image Control and the load_bitmapimage()
function.
⌨ Error/Debug Message
Fails silently, just no image displayed.
♻️ To Reproduce
- Go to pyRevit tab, Templates, hover over Generate FilledRegion Swatches
- after a brief pause the tooltip should expand and show the image
⏲️ Expected behavior
Expected:
Only get this, (it never expands):
🖥️ Hardware and Software Setup (please complete the following information)
Windows 11 Pro
Tried in Revit 2020 and 2022
Output from pyrevit env:
Microsoft Windows 10 [Version 10.0.22621]
Admin Access: No
%APPDATA%: "C:\Users\<username>\AppData\Roaming"
Latest Installed .Net Framework: 4.8
No .Net Target Packs are installed.
Installed .Net-Core Target Packs: v7.0.402
pyRevit CLI v4.8.13.23182+2215
Additional context
This solved the problem for me... coreutils > ribbon.py
def set_tooltip_image(self, tooltip_image):
try:
adwindows_obj = self.get_adwindows_object()
if isinstance(self.get_rvtapi_object().ToolTip, str):
exToolTip = self.get_rvtapi_object().ToolTip
else:
exToolTip = None
if adwindows_obj:
adwindows_obj.ToolTip = AdWindows.RibbonToolTip()
adwindows_obj.ToolTip.Title = self.ui_title
adwindows_obj.ToolTip.Content = exToolTip
_StackPanel = System.Windows.Controls.StackPanel()
_image = System.Windows.Controls.Image()
_image.Source = load_bitmapimage(tooltip_image)
_StackPanel.Children.Add(_image)
adwindows_obj.ToolTip.ExpandedContent = _StackPanel
adwindows_obj.ResolveToolTip()
else:
self.tooltip_image = tooltip_image
except Exception as ttimage_err:
raise PyRevitUIError('Error setting tooltip image {} | {} '
.format(tooltip_image, ttimage_err))
I am still figuring out how to do PRs for git repositories which have branches.