Единственная проблема заключается в том, что когда URL-адрес меняется на toga://hunt, появляется экран, на котором веб-страница недоступна. Можно ли как-нибудь предотвратить это или ускорить переход с HunterButton.html --> toga://hunt --> HunterButton.html?
async def hunterMessageHandler (self, webview, **kwargs):
global hunterID
lastUrl = None
defaultUrl = f"http://127.0.0.1:{self.app.local_port} hunterButton.html"
while True:
await asyncio.sleep(0.01)
if not hasattr(self, "hunterView"):
continue
url = self.hunterView.url
if url != lastUrl:
lastUrl = url
if url == "toga://hunt":
self.hunterView.evaluate_javascript(f'window.location = "http://127.0.0.1:{self.app.local_port}/hunterButton.html"')
print("button clicked")
jsApp.become_hunter
print(f"url: {url}")
hunterID = "hunter" + self.idInput.value
print(f"id: {hunterID}")
url = defaultUrl
print(f"url: {url}")
lastUrl = defaultUrl
Соответствующий HTML
Hunter Button

const msg = "uu";
function huntFunction (Toga) {
console.log("clicked");
window.location = "toga://hunt"
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... s-reupload
Мобильная версия