首页 > 解决方案 > 在 raiseevent() 方法中存储 HTML 对象(div 元素) - Pepper robo

问题描述

在胡椒机器人平板电脑中,我必须在单击按钮时在 webview 中显示网页。

如何在方法中存储对象(htmldiv元素)raiseevent()

例如:session.raiseevent("eventname", "htmldivelement")

下面的python函数加载url和webview

def web_view(self):

    url = "https://www.google.com"
    try:
        self.ts.loadUrl(url)
        self.ts.showWebview()
        #self.showWebview("https://www.google.com")
    except Exception, e:
        self.logger.info("Error while loading tablet: {}".format(e))

标签: javascriptpythonhtmlpepper

解决方案


您不能请求在 Pepper 的平板电脑上显示任意 html。

有两种方法可以从 Python 更新 Pepper 的平板电脑:

  • 加载一个新网页ALTabletService.showWebview(url)
  • 有一个使用javascript SDK订阅 ALMemory 事件的网页,并使用有关新平板电脑状态的信息引发 almemory 事件(这些通常传递 json,但也可以发送 html 任何其他格式 - 无论如何,你必须用javascript处理它)。在robots-jumpstarter中有一些例子。

推荐阅读