Forum Archive

Load webview url

donnieh

Newbie here. Why won't this load? I have a webview placed in the UI.

import ui

w1 = ui.WebView('webview1')
w1.load_url('http://www.yahoo.com')

userista

You have to add the WebView to a View as a subview and present it.

w1 = ui.WebView('webview1')

w1.load_url('http://www.yahoo.com')

my_view = ui.View()

my_view.add_subview(w1)

my_view.present()

ccc

You can also directly present the WebView:

import ui
w1 = ui.WebView('webview1')
w1.load_url('http://www.yahoo.com')
w1.present()
donnieh

Thank you all very much. The web view works good, especially with CCC's suggestion. However the results are not as expected. These above examples creates a pop up web view which is not intended. I have a web view library object placed in the .pyui editor. It is named webview1. How do I open a url in this little web view and not the pop up full screen web view?

ccc

w1.present('sheet')

donnieh

Hmmm

w1.present('sheet')

and

w1.present( )

both identically open the sheet web view. Neither open the webview I placed in the .pyui editor from the library (webview1).

ccc
import ui
view = ui.load_view()
w1 = view['webview1']
w1.load_url('http://www.yahoo.com')
view.present()
donnieh

Works like a charm! Thank you!!!!!