Archived discussion

Displaying a tooltip when a 3D object is clicked in pythonOCC 3D viewer

pythonOCCMon, 03/20/2023 - 04:042 replies

Browse this forum
QuestionAuthor

In PythonOCC, I am trying to make a tooltip or popup of sorts to display some text when I click a sphere that I created in 3D space. The code that I used and the resulting window is attached below. I would greatly appreciate it if anyone could explain how I can add a tooltip using PythonOCC to directly show info about a highlighted object. Some potential tooltip results are also attached below. Thank you!

Discussion

2 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hi Author,
The following example does not create a tooltip, but it prints the information about a klicked object into the terminal:
https://github.com/tpaviot/pythonocc-demos/blob/master/examples/core_dis...

Hope it helps a bit.

02Commenter-2

I cannot find any reliable callback in PythonOCC for tracking mouse movements, only for mouse clicks (.register_select_callback()) as in the sample referred by Daiva. So I guess you'll need asking the project to add such callbacks or hack in somehow using Qt/Wx-specific implementation.

The label itself could be displayed via AIS_TextLabel directly in 3D viewer or via some GUI widget. Dynamically highlighted object could be retrieved from AIS_InteractiveContext::DetectedOwner() as in case of C++ API.