Closed wangyuanhong2 closed 1 month ago
Hi, "pythonista-wkwebview" is specific to Pythonista, it doesn't transfer to other Python engines.
That being said, Carnets, because it is based on Jupyter, is already running in a web page. Depending on your goals, you can have HTML code in a Markdown cell, or opened as a link. I would suggest looking for "HTML embedding in a Jupyter notebook".
If your needs are more specific, there's also a-Shell, which is also running Python but has more control over the WkWebView (but again, not through pythonista-wkwebview).
Thank you! Can you elaborate a little more? I tried a_shell today and did not find a way for python code to use wkwebview. It seems pylibc doesn’t support iOS, so import objc on a_shell will report error:
import objc
Traceback (most recent call last):
File "
Again, it depends on what you want to do. But internalbrowser <url>
will open a web page or a file inside a-Shell.
Let me a little more specific. I used a library to scrape some websites to fetch some data back and the library uses pyminiracer which happens to be not supported in IOS. I am wondering whether I can replace pyminiracer with some code implementation to work around it on IOS.
As far as I can tell, pyminiracer is for running JavaScript commands.
From inside a-Shell, you can run JavaScript commands with jsc
, as in: jsc file.js
. It uses Apple's own JavaScript engine (different from V8 and node).
Thanks for the help. I’ve tried it.
Hi there, I would like to use webview on carnets and tried using following steps but failed. Can you help take a look and direct me how to move forward(maybe use another library to make me use webview function)? Thanks!
pip install pythonista-wkwebview v = WKWebView() v.present() v.load_html('
Hello world') v.load_url('http://omz-software.com/pythonista/')got the following error: ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from wkwebview import * 2 v = WKWebView() 3 v.present()
File /var/mobile/Containers/Data/Application/9F32A456-4131-45A4-8487-7CAEB77E3A45/Library/lib/python3.11/site-packages/wkwebview.py:8 2 ''' 3 WKWebView - modern webview for Pythonista 4 ''' 6 version = '1.0' ----> 8 from objc_util import * 9 import ui, console, webbrowser 10 import queue, weakref, ctypes, functools, time, os, json, re
ModuleNotFoundError: No module named 'objc_util'