🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Create a Python extension

User: "Pierre_20718"
Altair Community Member
Updated by Pierre_20718

Hi,

I'm trying to create a Python extension for Hyperview (2024), with a button in the ribbon for an existing script.

I got this error:

Traceback (most recent call last):
File "S:/GitLab-Runner/builds/TqqBBs8CP/0/altairengineering/modvis/common/common/framework/win64/hwx/bin/win64/hwsigslot.py", line 1620, in _Emit
File "/users/altairbuilds6/gitlab-runner-dir/builds/qUzuQUGTh/1/altairengineering/modvis/hwx/hwdesktop/unity/scripts/python/hwx/xmlui/factory/ribbonfactory.py", line 1115, in _onCommand
File "/users/altairbuilds6/gitlab-runner-dir/builds/qUzuQUGTh/1/altairengineering/modvis/hwx/hwdesktop/unity/scripts/python/hwx/xmlui/utils.py", line 225, in execcallback
File "<string>", line 1
rescale(<generator object execcallback.<locals>.<genexpr> at 0x000001EE3EC14740>)
^
SyntaxError: invalid syntax

And my source files are :

extension.xml :

<section name="Extension">
	<! … some stuff with name, version, etc. —>
	<entry name="tclscript"			value="global-init.tcl" />
	<entry name="script"			value="global-init.py" />
	<section name="profile" value="HyperView">
		<entry name="ribbonxml" value="hv/hv-ribbon.xml" />
		<entry name="script" value="hv/hv-init.py" />
	</section>

</section>

Global-init.py and global-init.tcl are pretty empty (I start with a first button before to do more) :

import hw
from hw import hv
package require postquery
namespace eval ::MyExtension {
global env
variable workDir [file normalize [[::hwp::GetSession] GetSystemVariable CURRENTWORKINGDIR]]
}

hv/hv-ribbon.xml

<root>
<actionlist>
<action
tag="Ext_Ribbon_HV_Action_rescale"
text="Rescale legend"
tooltip="Rescale the legend with an exponential scale"
image="scale.png"
command="py: rescale"
/> </actionlist> <page tag="Ext_Ribbon_HV_Ribbon_testone" text="TEST ONE"> <group tag="Ext_Ribbon_HV_Ribbon_testonegroupone" text="GROUP ONE"> <action actiontag="Ext_Ribbon_HV_Action_rescale"/> </group> </page> </root>

hv/hv-init.py :

import sys
import hw
from hw import hv
def rescale(*a, **kwargs):

print("hello world!")
#return _rescale() # not working, so I try to only run a print…
return 0

What's wrong ?

Thanks,

Pierre

Find more posts tagged with