pythontkinterpython-webbrowser

Need Help using webbrowser in python


I made an app that opens urls in a web browser, when you enter them into a gui.

from tkinter import *
import webbrowser

def WebOpen():
    url = (WebEntry.get())
    webbrowser.open(url)

gui = Tk()

gui.after(1, lambda: gui.focus_force)

gui.geometry("1920x1040")

gui.resizable(False, False)

gui.attributes('-fullscreen',True)

gui.configure(bg="black")

ExitWindow = Label(gui, text="To Quit This Computer Application, On Your Keyboard, Press and Hold the ALT and the F4 keys at the bottom and top of your keyboard respectively.", fg="white", bg="black", font="arial, 21")
ExitWindow.place(x=30,y=5)

WebEntry = Entry(gui, font="arial, 21")
WebEntry.place(x=100,y=400)

WebButton = Button(gui, text="Take Me There!",font="arial, 21",command=WebOpen())
WebButton.place(x=200, y=500)

gui.mainloop()

I tried to use webbrowser and tkinter to make an app that opens a webpage, but as soon as my program started, it opened file explorer (I think because of an empty path or something.)


Solution

  • Remove the parenthesis in the line 26. It works alright after removal

    WebButton = Button(gui, text="Take Me There!",font="arial, 21",command=WebOpen)