Source:
from tkinter import Tk, Button, Canvas root = Tk() c = Canvas(root,width=100,height=100) c.pack() def opt(event): print(url1) url1 = "vk.com" url2 = "ok.ru" but1 = Button(text="Vk") but1.bind(sequence="<Button-3>",func=opt) but1.pack() but2 = Button(text="Ok") but2.bind(sequence="<Button-3>",func=opt) but2.pack() root.mainloop() How to make it so that when you click on the vk button, the url1 = "vk.com" function is transferred and it writes "vk.com" .
And if you click on ok then the url is transmitted url2 = "ok.ru" and writes "ok.ru"
It is necessary to press "<Button-3>"
commandparameter is used to hang the action to press the button