Mundo em Python

Rádio em Braga

from tkinter import *

stations = {
"Antena 1": {"frequency": "89.5 MHz", "link": "http://www.rtp.pt/play/direto/antena1"},
"Antena 2": {"frequency": "88.2 MHz", "link": "http://www.rtp.pt/play/direto/antena2"},
"Antena 3": {"frequency": "92.0 MHz", "link": "http://www.rtp.pt/play/direto/antena3"},
"Rádio Renascença": {"frequency": "103.4 MHz", "link": "https://rr.sapo.pt/player"},
"RFM": {"frequency": "93.2 MHz", "link": "https://rfm.sapo.pt/"},
"Mega Hits": {"frequency": "92.9 MHz", "link": "https://megahits.sapo.pt/"},
"Cidade FM": {"frequency": "107.2 MHz", "link": "https://cidade.iol.pt/"},
"M80 Rádio": {"frequency": "94.8 MHz", "link": "https://m80.iol.pt/"},
"TSF": {"frequency": "89.5 MHz", "link": "https://www.tsf.pt/"},
"Rádio Comercial": {"frequency": "97.4 MHz", "link": "https://radiocomercial.iol.pt/"},
"Rádio Observador": {"frequency": "98.4 MHz", "link": "https://observador.pt/radio/player/"}
} def show_frequency():
selected_station = station_var.get()
if selected_station:
frequency_label.config(text=f"A frequência de "
f"{selected_station} "
f"é\n{stations[selected_station]['frequency']}.")
link_button.config(command=lambda: open_link(stations[selected_station]['link']))
else:
frequency_label.config(text="Por favor, selecione uma estação de rádio.")
link_button.config(command=lambda: None) def open_link(url):
import webbrowser
webbrowser.open(url) root = Tk()
root.title("Rádio em Braga")
root.geometry("400x400")
root.config(bg="#103030") # Título
titulo = Label(root, text="Rádio em Braga", font=("Arial", 28, "bold"), bg="#103030", fg="#49e3e3")
titulo.pack(pady=20) station_var = StringVar()
station_var.set("Selecione a estação") station_menu = OptionMenu(root, station_var, *stations.keys())
station_menu.config(font=("Arial", 14), bg="white", fg="#103030")
station_menu.pack(pady=10)
show_frequency_button = Button(root, text="Mostrar Frequência", command=show_frequency,
bg="#49e3e3", fg="#103030", font=("Arial", 14))
show_frequency_button.pack(pady=10)
frequency_label = Label(root, text="", font=("Arial", 14), bg="#103030", fg="#49e3e3")
frequency_label.pack(pady=10)
link_button = Button(root, text="Abrir Site", bg="#49e3e3", fg="#103030", font=("Arial", 14))
link_button.pack(pady=10)
root.mainloop()
0