Created
March 18, 2018 22:26
-
-
Save frmdstryr/9541db3d6561ea78d2deb9ecb965f881 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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