MCPcopy
hub / github.com/beeware/toga / purge_toolbar

Method purge_toolbar

cocoa/src/toga_cocoa/window.py:579–596  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

577 self.interface.content.refresh()
578
579 def purge_toolbar(self):
580 while self._toolbar_items:
581 dead_items = []
582 _, cmd = self._toolbar_items.popitem()
583 # The command might have toolbar representations on multiple window
584 # toolbars, and may have other representations (at the very least, a menu
585 # item). Only clean up the representation pointing at *this* window. Do this
586 # in 2 passes so that we're not modifying the set of native objects while
587 # iterating over it.
588 for item_native in cmd._impl.native:
589 if (
590 isinstance(item_native, NSToolbarItem)
591 and item_native.target == self.native
592 ):
593 dead_items.append(item_native)
594
595 for item_native in dead_items:
596 cmd._impl.native.remove(item_native)

Callers 2

__del__Method · 0.95
create_toolbarMethod · 0.95

Calls 2

appendMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected