Skip to content

Commit ca1968c

Browse files
authored
Merge pull request #223 from robotools/toolbarPriority
add support for toolbar priority
2 parents 25ef265 + e3f5949 commit ca1968c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Lib/vanilla/vanillaWindows.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
NSToolbarSizeModeDefault,
3636
NSToolbarSizeModeRegular,
3737
NSToolbarSizeModeSmall,
38-
NSMenu
38+
NSMenu,
39+
NSToolbarItemVisibilityPriorityLow,
40+
NSToolbarItemVisibilityPriorityHigh
3941
)
4042
from objc import python_method
4143
from objc import super
@@ -771,6 +773,9 @@ def addToolbar(self, toolbarIdentifier, toolbarItems, addStandardItems=True, dis
771773
| | If the item should be added to the toolbar only through the customization |
772774
| | palette, use a value of _False_. Defaults to _True_. |
773775
+---------------------------------+---------------------------------------------------------------------------+
776+
| *priority* (optional) | A `string`, the display priority associated with the toolbar item. |
777+
| | Options are `"high"` or `"low"`. Defaults to *None*. |
778+
+---------------------------------+---------------------------------------------------------------------------+
774779
775780
.. _NSImage: https://developer.apple.com/documentation/appkit/nsimage?language=objc
776781
@@ -953,6 +958,8 @@ def _createToolbarItem(self, itemData):
953958
imageObject = itemData.get("imageObject")
954959
imageTemplate = itemData.get("imageTemplate")
955960
view = itemData.get("view")
961+
priority = itemData.get("priority")
962+
956963
menuRepresentation = itemData.get("menuRepresentation")
957964
callback = itemData.get("callback", None)
958965
# create the NSImage if needed
@@ -983,6 +990,10 @@ def _createToolbarItem(self, itemData):
983990
VanillaMenuBuilder(self, [menuRepresentation], dummyMenu)
984991
menuRepresentation = dummyMenu.itemAtIndex_(0)
985992
toolbarItem.setMenuFormRepresentation_(menuRepresentation)
993+
if priority == "low":
994+
toolbarItem.setVisibilityPriority_(NSToolbarItemVisibilityPriorityLow)
995+
elif priority == "high":
996+
toolbarItem.setVisibilityPriority_(NSToolbarItemVisibilityPriorityHigh)
986997
if callback is not None:
987998
target = VanillaCallbackWrapper(callback)
988999
toolbarItem.setTarget_(target)

0 commit comments

Comments
 (0)