Simple Application to run a link from a list

Hello everybody, I think it’s time to get back to work with Python after a break. Are you ready? Let’s get it started with a little app made with tkinter to make a GUI. Something very basic and easy to do, but you will create something really useful that can give you some ideas about making an app and from where to start with tkinter. I think this will help you create wonderful tools you can use to make your life easier and to get ideas about using python for real applications. Let’s go!

In this first version we will see how to create a list of link that you can click on to open the browser with that link. In the next tutorial we will see how to add links from the app, instead of adding them inside the code, for a true user friendly app.

This is the code. Just double click to go to the link. If you want to add links you need to hard code the links putting them inside the link variable you see down the code below.

import tkinter as tk
import os

root = tk.Tk()
root.geometry("800x400")
lb = tk.Listbox()
lb.pack(fill="both", expand=1)
lb.bind("<Double-Button>", lambda event: open_site(lb.get(lb.curselection())))

def open_site(site):
	os.startfile(site)

def create_voice(site):
	lb.insert(tk.END, site)

# Put in this multilines strings all your links
links ="""https://pythonprogramming.altervista.org/wp-admin/
www.google.it
www.repubblica.it
"""
for voices in links.splitlines():
	create_voice(voices)

root.mainloop()

The App will look like this

The Window created with tkinter with the links you can double click to go to the link itself. The browser will open with the link you clicked.

Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.