import sys sys.argv=["Main"] from tkinter import Tk, Frame, Menu root = Tk() # Команды def command1(): root.destroy() def command2(): root.destroy() # Определяем положение курсора class POINT(Structure): _fields_ = [("x", c_ulong), ("y", c_ulong)] def queryMousePosition(): pt = POINT() windll.user32.GetCursorPos(byref(pt)) return { "x": pt.x, "y": pt.y} root.overrideredirect (1) # Создаем меню menu = Menu(root, tearoff=0) menu.add_command(label="LABEL1", command=command1) menu.add_command(label="LABEL2", command=command2) # Создаем canvas frame = Frame(root, width=0, height=0) frame.pack() # Открываем меню menu.post(%(x)s,%(y)s % (queryMousePosition())) root.mainloop()
Ошибка в cтроке:
menu.post(%(x)s,%(y)s % (queryMousePosition()))