Closed typemytype closed 1 year ago
import vanilla
class Test:
def __init__(self):
self.w = vanilla.Window((200, 200), minSize=(100, 100))
self.w.addToolbar(
"com.identifier",
[
dict(
itemIdentifier="foo",
label="Foo",
callback=self.fooCallback
),
dict(
itemIdentifier="bar",
label="bar",
callback=self.barCallback,
menuRepresentation=dict(
title="menu bar",
items=[
dict(title="hello", callback=self.menuBarCallback)
]
)
)
]
)
self.w.open()
def fooCallback(self, sender):
print("foo", sender)
def barCallback(self, sender):
print("bar", sender)
def menuBarCallback(self, sender):
print("menuBarCallback", sender)
Test()
add new key
menuFormRepresentation
to build a NSMenuItem from either a NSMenuItem or a single menu item dict as described in VanillaMenuBuilderhttps://github.com/robotools/vanilla/blob/master/Lib/vanilla/vanillaWindows.py#L705-L732
see https://developer.apple.com/documentation/appkit/nstoolbaritem/1532562-menuformrepresentation?language=objc