I have a tkinter script. I was wondering is there anyway to have is so when you hit a button it takes you to a Web Site
from tkinter import *
app = Tk()
app.geometry("250x400")
app.title("Links")
def Link():
?
button1 = Button(app, text = "To a web site.", command = Link)
button1.pack()
app.mainloop()
There's a module for that.
import webbrowser
webbrowser.open("http://xkcd.com/353/")
Use webbrowser module to open the URL
. The documentation: https://docs.python.org/3/library/webbrowser.html
# You can use open
from webbrowser import open
def link():
open('https://www.youtube.com/')
# You can use open_new_tab
from webbrowser import open_new_tab
def link():
open_new_tab('https://www.youtube.com/')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With