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

Method create_toolbar

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

Source from the content-addressed store, hash-verified

554 pass
555
556 def create_toolbar(self):
557 # Purge any existing toolbar items
558 self.purge_toolbar()
559
560 # Create the new toolbar items.
561 if self.interface.toolbar:
562 for cmd in self.interface.toolbar:
563 if isinstance(cmd, Command):
564 self._toolbar_items[toolbar_identifier(cmd)] = cmd
565
566 self.native_toolbar = NSToolbar.alloc().initWithIdentifier(
567 f"Toolbar-{id(self)}"
568 )
569 self.native_toolbar.setDelegate(self.native)
570 else:
571 self.native_toolbar = None
572
573 self.native.setToolbar(self.native_toolbar)
574
575 # Adding/removing a toolbar changes the size of the content window.
576 if self.interface.content:
577 self.interface.content.refresh()
578
579 def purge_toolbar(self):
580 while self._toolbar_items:

Callers 2

_startupMethod · 0.45
__init__Method · 0.45

Calls 3

purge_toolbarMethod · 0.95
toolbar_identifierFunction · 0.85
refreshMethod · 0.45

Tested by

no test coverage detected