Create a button with url

Hi,

I am new to the python programming and try something out and see what’s happening.

I want to have a textbox where i can enter a series name.

With that i want to combine a url to a website with this entry.

I already have this:

comp1 = ‘Search - TheTVDB.com
comp2 = [“true%20detective”]

urlTVDB = comp1 + “”.join(comp2)

comp2 must come out of the textbox.

so the url must look like this:\

This must be linked to a button, when i hit it it opens the website.

@rich23 your strings just parsed as URL’s. Recommend using single ticks and triple ticks to format code.

Either way, I think I get what you’re looking to do. You may want to look at f-strings which should fit the bill for that. Python String Formatting

E.g., something like url = f”{comp1}query={comp2}”

ok, this works.

But now i need a textbox or something like that, that asks me a name of the serie wich i can use in the search string.

import time
import webbrowser
import tkinter as tk

input(“Naam”)

comp1 = ‘Search - TheTVDB.com

Naam = input()

url = f"{comp1}{Naam}"

urls = [url,]

for url in urls:
webbrowser.open_new_tab(url)
time.sleep(0.5)

I dont get a textbox but when i entered a text, it is not used in the “Naam”

I’ve written a couple of packages that might help. The first is pymsgbox, which adds an alert() and prompt() function (like in JavaScript) for pop up dialog boxes. This is nice if you need a basic GUI for a program. PyMsgBox · PyPI

Second, I just finished a presentable version of ButtonPad, a GUI framework (built on top of tkinter) for making simple desktop apps. Basically, if you need a Python app that has buttons and text boxes and not much more: ButtonPad · PyPI

I used it to write what I think you want (you need to use pip to install buttonpad first):

import buttonpad, webbrowser

URL_PREFIX = "https://www.google.com/search?q="

layout = """
[Search term goes here]
Open URLs"""

bp = buttonpad.ButtonPad(
    layout,
    cell_width=400,
    cell_height=60,
)

def open_url(widget, x, y):
    webbrowser.open(URL_PREFIX + bp[0, 0].text)

bp[0,1].on_click = open_urls

bp.run()

Dear Richard,

Tkinter has a thing called ‘widgets’ - which includes text boxes, buttons, and a lot more.

This sample code has a button and input boxes . . .

from tkinter import *
 
TJwin = Tk()
TJwin.title("Welcome to the Dog House !")     # create and title window
TJwin.geometry('500x350')
 
dalbl = Label(TJwin, text="Hello")            # make a text label
dalbl.grid(column=0, row=0)                   # place it top left.
 
datxt = Entry(TJwin,width=10)                 # Make a text entry box
datxt.grid(column=1, row=1)
 
def clicked():                                # What to do if button clicked
    res = "Welcome to " + datxt.get()
    dalbl.configure(text= res)
 
dabtn = Button(TJwin, text="Click Me", command=clicked)     # Button
dabtn.grid(column=2, row=3)
 
TJwin.mainloop()

This simple little program shows how Tkinter can make a label, an entry box, and a button. Note that the function for what the button does must come before the creation of the button. And, datxt.get() is the function that fetches the contents of the text box.