In this video I’ll show you how to use an external Web Browser with your Tkinter app.

How many times would you have liked to open an external web browser from inside your Tkinter app?

In this video I’ll show you how to do that using the webbrowser module. It’s super easy!

Python Code: browse.py
(Github Code)

from tkinter import *
import webbrowser

root = Tk()
root.title('Codemy.com - Open Web Browser')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x500")

def open_browser(e):
	# Open default browser
	#webbrowser.open_new("https://codemy.com")
	
	# Open Specific Browser
	webbrowser.get("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s").open_new("https://codemy.com")


# Create Button
my_button = Button(root, text="Open Web Browser!", 
	font=("Helvetica", 24), command=lambda: open_browser(1))
my_button.pack(pady=50)

# Create Label
my_label = Label(root, text="Open Browser", font=("Helvetica", 24),
	fg="blue")
my_label.pack(pady=20)

# Bind Label
my_label.bind("", open_browser)




root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...