如何在webkit2gtk中进行标题更改呼叫? [英] How to make title-change call work in webkit2gtk?

查看:57
本文介绍了如何在webkit2gtk中进行标题更改呼叫?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将用python2编写的旧GTK webkit代码移植到webkit2和python3(Ubuntu已删除了旧的webkit v1). js代码更改了html的标题,而python检测到将其关闭.但是,它在webkit2中不起作用. 在旧代码中,有一行

I am trying to port an old GTK webkit code written in python2 to webkit2 and python3 (Ubuntu has removed old webkit v1). The js code changes the title of the html, and python detected it to close it. However, it is not working in webkit2. In the old code, there is the line

self.webview.connect('title-changed', title_changed) #title_changed is a python function, which will do something

显示TypeError: <WebKit2.WebView object at 0x7f14b687ecd0 (WebKitWebView at 0x557297cdb7c0)>: unknown signal name: title-changed

.

如何将此代码移植到webkit2? 根据 https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html 有webkit_web_view_get_title(),但是有什么方法可以检测标题的更改?

How to port this code to webkit2? According to https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html there is webkit_web_view_get_title (), but is there any way to detect change of title?

推荐答案

由于title是属性,因此它自动带有您可以连接的notify信号.使用notify::title.

Since title is a property, it automatically comes with a notify signal you can connect to. Use notify::title.

例如,使用以下代码

self.webview.connect('notify::title', title_changed)

这篇关于如何在webkit2gtk中进行标题更改呼叫?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆