|
35 | 35 | NSToolbarSizeModeDefault, |
36 | 36 | NSToolbarSizeModeRegular, |
37 | 37 | NSToolbarSizeModeSmall, |
38 | | - NSMenu |
| 38 | + NSMenu, |
| 39 | + NSToolbarItemVisibilityPriorityLow, |
| 40 | + NSToolbarItemVisibilityPriorityHigh |
39 | 41 | ) |
40 | 42 | from objc import python_method |
41 | 43 | from objc import super |
@@ -771,6 +773,9 @@ def addToolbar(self, toolbarIdentifier, toolbarItems, addStandardItems=True, dis |
771 | 773 | | | If the item should be added to the toolbar only through the customization | |
772 | 774 | | | palette, use a value of _False_. Defaults to _True_. | |
773 | 775 | +---------------------------------+---------------------------------------------------------------------------+ |
| 776 | + | *priority* (optional) | A `string`, the display priority associated with the toolbar item. | |
| 777 | + | | Options are `"high"` or `"low"`. Defaults to *None*. | |
| 778 | + +---------------------------------+---------------------------------------------------------------------------+ |
774 | 779 |
|
775 | 780 | .. _NSImage: https://developer.apple.com/documentation/appkit/nsimage?language=objc |
776 | 781 |
|
@@ -953,6 +958,8 @@ def _createToolbarItem(self, itemData): |
953 | 958 | imageObject = itemData.get("imageObject") |
954 | 959 | imageTemplate = itemData.get("imageTemplate") |
955 | 960 | view = itemData.get("view") |
| 961 | + priority = itemData.get("priority") |
| 962 | + |
956 | 963 | menuRepresentation = itemData.get("menuRepresentation") |
957 | 964 | callback = itemData.get("callback", None) |
958 | 965 | # create the NSImage if needed |
@@ -983,6 +990,10 @@ def _createToolbarItem(self, itemData): |
983 | 990 | VanillaMenuBuilder(self, [menuRepresentation], dummyMenu) |
984 | 991 | menuRepresentation = dummyMenu.itemAtIndex_(0) |
985 | 992 | toolbarItem.setMenuFormRepresentation_(menuRepresentation) |
| 993 | + if priority == "low": |
| 994 | + toolbarItem.setVisibilityPriority_(NSToolbarItemVisibilityPriorityLow) |
| 995 | + elif priority == "high": |
| 996 | + toolbarItem.setVisibilityPriority_(NSToolbarItemVisibilityPriorityHigh) |
986 | 997 | if callback is not None: |
987 | 998 | target = VanillaCallbackWrapper(callback) |
988 | 999 | toolbarItem.setTarget_(target) |
|
0 commit comments