WebView navigation buttons
I'm struggling a bit with the WebView. See this code:
import ui wv = ui.WebView() wv.load_url('https://forum.omz-software.com') wv.present()
Works fine so far, it opens the page ;-). However, I don't see any navigation buttons to navigate forward or back. Do I have to create them by myself by making a view which contains WebView and the buttons (assigned to
wv.go_back()) or is there an option which I could set for WebView? I haven't found one in the documentation, but maybe I was looking for the wrong keywords...
I think that there is no option and that you have to create buttons which, when pressed, call the webview methods go_back or go_forward.
OK, done. :-)
quick&dirty (hopefully not very dirty ;-), but if you find some things to optimize please tell me):
import ui class MyWebView(ui.View): def __init__(self, url): self.width, self.height = ui.get_window_size() self.wv = ui.WebView(frame=self.bounds) self.wv.load_url(url) self.add_subview(self.wv) bi_back = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_back_32')) bi_forward = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_forward_32')) bi_back.action = self.go_back bi_forward.action = self.go_forward self.right_button_items = [bi_forward, bi_back] self.present() def go_back(self, bi): self.wv.go_back() def go_forward(self, bi): self.wv.go_forward() wv = MyWebView('https://forum.omz-software.com')