Create Popup: Get Value of the Menu Item Clicked On

I oddly couldn’t find anywhere that shows how to get the value of the popup menu item that is ultimately clicked on. All of my menu items will call the exact same function and will set a window property to the value that was clicked on.

I’m assuming, but is this Vision?

If so, when constructing your methods, you can take advantage of first-class functions via functools.partial:

from functools import partial

def saySomething(event, message):

messages = [

menu = system.gui.createPopupMenu(
   ["Say %s" % message for message in messages],
   [partial(saySomething, message=message) for message in messages]