How can I track the window URL in a thread? #1335
-
Hi import threading
import webview
from time import sleep
def main():
window = webview.create_window('App behind OAuth', 'https://domain.com/login/sso')
x = threading.Thread(target=monitor_thread, args=[window], daemon=True)
x.start()
webview.start(private_mode=False, debug=True)
def monitor_thread(window):
# while window.get_current_url() != 'https://domain.com/loggedIn':
while True:
print(f"Thread loop: {window.get_current_url()}")
sleep(1000)
# this is where I would inspect the page once it's loaded
if __name__ == "__main__":
main() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I don't know what's wrong with your example, but a better approach would be to subscribe to def main():
global window
window = webview.create_window('App behind OAuth', 'https://domain.com/login/sso')
window.events.loaded += monitor_thread
webview.start(private_mode=False, debug=True)
def monitor_thread():
print(window.get_current_url())
if __name__ == "__main__":
main() |
Beta Was this translation helpful? Give feedback.
-
That's perfect - much simpler and works! |
Beta Was this translation helpful? Give feedback.
I don't know what's wrong with your example, but a better approach would be to subscribe to
window.events.loaded
event to track url changes. For example