PauBot
December 7, 2023, 3:09pm
1
Hi there!
I am using Python to create some Add-ons, and I would like the user to see information about some of the properties (input fields, buttons, dropdowns, etc.) when he hovers the mouse on them. For example, in the HOME/Origin/Snap menu, when the user hovers on ‘1 Point’, he can see the text ‘Snap component with a single click’.
Does anyone know if and how this can be achieved with Python? I checked the documentation and couldn’t find anything on this.
Thanks!
TSy
December 7, 2023, 7:48pm
2
Those are called tooltips. I think there is a way to assign tooltips for properties of Python commands through the localization system.
https://help.visualcomponents.com/4.8/Premium/en/Python_API/Template_for_Python_Add-on.htm?rhhlterm=Tooltip
idkfa
December 7, 2023, 8:59pm
3
__init__.py
from vcApplication import *
cmdName = "cmdTipExample"
netCommand = findCommand("netCommand")
netCommand.execute("SetLocalizationCommand", "English", "Python", cmdName, "Tooltip", "Tooltip Example")
def OnStart():
cmduri = getApplicationPath() + "TipExample.py"
cmd = loadCommand(cmdName, cmduri)
addMenuItem("VcTabHome/VcRibbonTools", "TipExample", -1, cmdName, "Help/rHelp")
TipExample.py
from vcCommand import *
from vcHelpers.Application import *
cmdName = "cmdTipExample"
app = getApplication()
cmd = getCommand()
netCommand = app.findCommand("netCommand")
def getPanelProperty(propertyValue, propertyName, tooltip):
property = cmd.getProperty(propertyName)
if not property:
property = cmd.createProperty(propertyValue, propertyName)
netCommand.execute("SetLocalizationCommand", "English", "Python", "%s.%s" % (cmdName, propertyName), "Description", tooltip)
return property
def OnPrintMe(arg):
print "Hello %s" % me.Value
def OnStart():
global me, printMe
me = getPanelProperty(VC_STRING, "Me", "This is me")
printMe = getPanelProperty(VC_BUTTON, "PrintMe", "Click to print me")
printMe.OnChanged = OnPrintMe
executeInActionPanel()
1 Like