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()
3
  • 1
    Do you mean that you want your options to be hyperlinks? if so, you could find something valueable here: stackoverflow.com/questions/23482748/… Commented Sep 8, 2021 at 16:00
  • Just bind to "<ButtonRelease-1>" and then open the webpage in the browser. Commented Sep 8, 2021 at 16:12
  • 3
    Change OptionList to a dictionary like: OptionList = {"Google": "https://www.google.com", ...}, then opt = tk.OptionMenu(app, variable, *OptionList.keys()). Commented Sep 8, 2021 at 16:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.