0

I wish to open a url in a tkinter gui. This works fine, however, when I click on the login icon it opens in an external browser. Am I able to log into the site and stay in the same tkinter gui? Thanks

# Import tkinter and webview libraries
from tkinter import *
import webview
  
# define an instance of tkinter
tk = Tk()
  
#  size of the window where we show our website
tk.geometry("800x800")
  
# Open website
webview.create_window('mapgenie', 'https://mapgenie.io/diablo-4/maps/sanctuary')
webview.start()
quietplace
  • 471
  • 1
  • 4
  • 14

1 Answers1

1

I tested your code by running another website and attempting to login; everything worked well, and the webpage also opened in the tkinter window.

Try the following website if you have an account on it or else try instagram -

from tkinter import *
import webview
  
# define an instance of tkinter
tk = Tk()
  
#  size of the window where we show our website
tk.geometry("800x800")
  
# Open website
webview.create_window('HackerRank', 'https://www.hackerrank.com/')
webview.start()

I believe the problem with the login page opening in the browser at https://mapgenie.io/diablo-4/maps/sanctuary is due to the website's framework. You may try inspecting and seeing the HTML framework.

Reason - As seen in the figure below, there is a 'href' (hypertext reference) included in the anchor tag, which opens the web browser.

Mapgenie's Login Button Inspection

But this is not the case with Hackerrank (Image for reference) -

HackerRank's Login Button Inspection

Hope it's clear now.

  • Yes, I can confirm that seems to be the case. [Here](https://pywebview.flowrl.com/examples/links.html) it says that it is a blank target that does this. I wonder if there is a way to listen for these events and keep them in the gui? Thankyou – quietplace Jul 25 '23 at 06:49
  • Here are some of the alternatives you can try - Web Scraping: Use Python's libraries like requests and BeautifulSoup to perform web scraping and simulate the login process programmatically. This way, you can fetch data from the website and display it within your Tkinter application. AND, Custom Login Form: Instead of relying on the website's login page, you can create a custom login form within your Tkinter application. When users log in using your custom form, you can use the credentials they provide to make requests to the website's API and fetch data to display within the Tkinter GUI. – Yes_ItsMEOW Jul 26 '23 at 10:21