Friday, December 12, 2025
HomeUncategorisedHow to open a website in a Tkinter window?

How to open a website in a Tkinter window?

In this article, we are going to see how we can open a website in the Tkinter window. We can open a website in Tkinter using webview. This library allows us to view the HTML content in its GUI window.  

Syntax to install Tkinter and webview using the below commands.

pip install tk
pip install pywebview

Method 1: Using  webview.create_window() and webview.start() function

In this method, we are use webview.create_window() and webview.start() function to open website in Tkinter. create_window() function is create window for website and start() function display this website on screen. Follow the below steps to open a website in Tkinter using this method.

  • Import Tkinter and webview libraries.
  • define an instance of Tkinter.
  • Set the size of your window.
  • Call webview.create_window() function.

Example:

Python3




# 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("800x450")
  
# Open website
webview.create_window('Geeks for Geeks', 'https://geeksforgeeks.org')
webview.start()


Output:

Method 2: Using webbrowser.open() function

In this method. we use webbrowser.open() function. This function opens the requested page using the default browser. Follow the below steps to open a website in Tkinter using this method.

  • Import Tkinter and webview libraries.
  • define an instance of Tkinter.
  • Set the size of your window.
  • Call webbrowser.open() function.

Example:

Python3




# import required library
import webbrowser
from tkinter import *
  
# creating root
root = Tk()
  
# setting GUI title
root.title("WebBrowsers")
  
# setting GUI geometry
root.geometry("660x660")
  
# call webbrowser.open() function.
webbrowser.open("www.instagram.com")


Output:

RELATED ARTICLES

Most Popular

Dominic
32445 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6814 POSTS0 COMMENTS
Nicole Veronica
11952 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12029 POSTS0 COMMENTS
Shaida Kate Naidoo
6949 POSTS0 COMMENTS
Ted Musemwa
7199 POSTS0 COMMENTS
Thapelo Manthata
6895 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS