我想要一个带有网络代码的常规GTK盒子。该代码将有一个带apt的安装按钮(Firefox将这些URL打开到软件中心)。
Unable to load page
Problem occurred while loading the URL apt:package
URL cannot be shown
但是当我尝试它时,我收到一个URL错误:
if (id is in candidate)
You are in "candidate"
else if (id is in exam)
You are in "exam"
我可以在Linux中捕获apt链接吗?提前谢谢!
答案 0 :(得分:1)
您必须连接到navigation-requested
信号。这是一个例子:
from gi.repository import Gtk, WebKit
class window(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.connect('delete-event', Gtk.main_quit)
webview = WebKit.WebView()
self.add(webview)
webview.connect('navigation-requested', self.on_navigation_requested)
webview.open('http://google.de')
#webview.open('apt://test') uncomment to test apt URIs
def on_navigation_requested(self, view, frame, req):
uri = req.get_uri()
if uri and uri.startswith('apt'):
print('apt uri')
return WebKit.NavigationResponse.IGNORE
return WebKit.NavigationResponse.ACCEPT
if __name__ == '__main__':
win = window()
win.show_all()
Gtk.main()