0

I have an optionmenu in tkinter but I want to display a text instead of the url, example google = www.google.com

import tkinter as tk

OptionList = [
"https://www.youtube.com/",
"https://stackoverflow.com/",
"https://github.com/",
] 

app = tk.Tk()

app.geometry('500x500')

variable = tk.StringVar(app)
variable.set(OptionList[0])

opt = tk.OptionMenu(app, variable, *OptionList)
opt.config(width=90, font=('Helvetica', 15))
opt.pack()

app.mainloop()
hephitao
  • 1
  • 1
  • 1
    Do you mean that you want your options to be hyperlinks? if so, you could find something valueable here: https://stackoverflow.com/questions/23482748/how-to-create-a-hyperlink-with-a-label-in-tkinter – hanmic-6 Sep 08 '21 at 16:00
  • Just bind to `""` and then open the webpage in the browser. – TheLizzard Sep 08 '21 at 16:12
  • 3
    Change `OptionList` to a *dictionary* like: `OptionList = {"Google": "https://www.google.com", ...}`, then `opt = tk.OptionMenu(app, variable, *OptionList.keys())`. – acw1668 Sep 08 '21 at 16:23

0 Answers0