Skip to content

Instantly share code, notes, and snippets.

@frmdstryr
Created March 18, 2018 22:26
Show Gist options
  • Save frmdstryr/9541db3d6561ea78d2deb9ecb965f881 to your computer and use it in GitHub Desktop.
Save frmdstryr/9541db3d6561ea78d2deb9ecb965f881 to your computer and use it in GitHub Desktop.
from enaml.qt.QtGui import QCursor
enamldef PopupMenu(Menu): menu:
attr selected = set()
attr choices = []
attr pos = None
activated ::
# Save where it was opened
self.pos = QCursor.pos()
Looper:
iterable << choices
Action:
text = loop_item
# When selected re-open at the position it was originally opened
triggered :: menu.proxy.widget.exec_(menu.pos)
checkable = True
checked << self.text in selected
checked :: selected.add(self.text) if self.checked else selected.remove(self.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment