首页 > 解决方案 > Ignition 7.8 – 通过脚本从容器内的文本区域获取组件文本

问题描述

带有脚本的按钮正在将组件值保存到 SQL 更新的参数中。调用按钮位于包含文本区域的容器上方一层。但是,使用推荐的用户手册方法设置文本区域值会引发错误“<em>AttributeError: 'NoneType' object has no attribute 'text'”</p>

标准表格不起作用:

Comments = event.source.parent.getComponent('textArea1).text

在通话结束时还尝试了不同的属性:

… .string , … .value , … .stringvalue
event.source.parent.parent.getComponent('textArea1).text

查看组件上的属性绑定路径时,我能够返回“根容器。ContainerName.textArea1.text”。当我修改为如下所示的 GetProperty pull 时,我收到了一个类似的错误,其中包含未找到 Selected Property 的附加信息。我尝试了与上面列出的类似的替代方案。

Comments = event.source.parent.ContainerName.getComponent('textArea1).text

有什么建议么?

标签: ignitionscada-ignition

解决方案


解决方案是使用 '.getComponent' 方法按名称调用容器组件,然后使用标准方法调用文本区域。下面的组合代码用于设置参数注释。

Comments = event.source.parent.parent.getComponent('ContainerName').getComponent('TextArea1').text

从 Container 中检索 Component 值似乎没有包含在 Ignition Manual 中。


推荐阅读