Forum Archive

It's like a bug.

tomomo

When I execute the code below, I cannot press the OK button.
Do you have the same symptoms?

iPhone X(iOS12.4.1)
Pythonista 3 v.3.2(320000)

import ui
main = ui.ScrollView(frame=(0, 0, 375, 812))
main.content_size = (375, 812)
wv = ui.WebView(frame=(0, 0,*main.content_size))
wv.load_url('https://www.google.co.jp/')
main.add_subview(wv)
main.present('fullscreen')

wv.evaluate_javascript('alert("123");')
cvp

@tomomo For me, it works
iPad mini 4 iOS 13.2.3
Pythonista beta V3.3 build 330018

mikael

@tomomo, works for me as well, on an iPhone with the same screen size and same Pythonista version as yours, but on iOS 13.

Just to be sure, have you tried restarting your phone?

tomomo

I tried rebooting, but I couldn't press the OK button.Is it because of iOS version 12.4.1?

tomomo

iPhone 6S(iOS13.2.3)
Pythonista 3 v.3.2(320000)

This worked.
So maybe the iOS version is a problem.

cvp

@tomomo thus, just to be sure, you see the button and when you tap it, nothing happens?

madivad

Doh! So how do you get out? I had to close down the app. Lol

iOS 12.4.1
Pythonista 3.3 beta

tomomo

Since you cannot press the OK button, you can only delete the app from the task.

How can I use Pythonista 3.3 beta?

cvp

@tomomo normally, from here but it seems full now😢

tomomo

Thank you.
It ’s full.

cvp

@tomomo this works on iPhone 5s iOS 12.4.3
Perhaps, you did not wait for the web page to be loaded before doing your alert

import ui
main = ui.ScrollView(frame=(0, 0, 375, 812))
main.content_size = (375, 812)
wv = ui.WebView(frame=(0, 0,*main.content_size))
wv.load_url('https://www.google.co.jp/')
main.add_subview(wv)
main.present('fullscreen')

def x():
    wv.evaluate_javascript('alert("123");')
ui.delay(x,1) 
tomomo

@cvp I will try it.

cvp

@tomomo and, normally, you should use delegate of WebView

import ui

class MyWebViewDelegate (object):
    def webview_did_finish_load(self, webview):
        wv.evaluate_javascript('alert("123");')

main = ui.ScrollView(frame=(0, 0, 375, 812))
main.content_size = (375, 812)
wv = ui.WebView(frame=(0, 0,*main.content_size))
wv.delegate = MyWebViewDelegate()
main.add_subview(wv)
main.present('fullscreen')

wv.load_url('https://www.google.co.jp/') 
tomomo

@cvp Thank you for the several amendments.
I will try my best to change the contents of the alert dynamically.