コード例 #1
0
 def buttonToolBar(self, info):
     toolbarItems = info['toolbarItems']
     
     label = 'Show Reference Viewer'
     identifier = 'ReferenceViewer'
     filename = 'ReferenceIcon.pdf'
     callback = self.buttonStartCallback
     index = -2
     
     imagePath = os.path.join(self.base_path, 'resources', filename)
     image = NSImage.alloc().initByReferencingFile_(imagePath)
     
     view = ToolbarGlyphTools(
         (30, 25), 
         [dict(image=image, toolTip=label)], 
         trackingMode="one"
         )
     
     newItem = dict(
         itemIdentifier = identifier,
         label = label,
         callback = callback,
         view = view
         )
     toolbarItems.insert(index, newItem)
コード例 #2
0
    def addOverlapToolbarItem(self, info):

        toolbarItems = info['toolbarItems']

        label = 'Add Overlap w/ UI'
        identifier = 'addOverlapUI'
        filename = 'AddOverlapButtonUI.pdf'
        callback = self.addOverlap
        index = -2

        imagePath = os.path.join(self.base_path, 'resources', filename)
        image = NSImage.alloc().initByReferencingFile_(imagePath)

        view = ToolbarGlyphTools((30, 25), [dict(image=image, toolTip=label)],
                                 trackingMode="one")

        for item in list(toolbarItems):
            if item['itemIdentifier'] == identifier:
                toolbarItems.remove(item)

        newItem = dict(itemIdentifier=identifier,
                       label=label,
                       callback=callback,
                       view=view)

        toolbarItems.insert(index, newItem)
コード例 #3
0
ファイル: _startup.py プロジェクト: frankrolf/RoboToDo
    def addToolbarItem(self,
                       toolbarItems,
                       label,
                       identifier,
                       filename,
                       callback,
                       index=-1):
        imagePath = os.path.join(self.base_path, 'resources', filename)
        image = NSImage.alloc().initByReferencingFile_(imagePath)

        if identifier is 'roboToDoGlyph':
            view = ToolbarGlyphTools((30, 25),
                                     [dict(image=image, toolTip="To-Do")],
                                     trackingMode="one")

            newItem = dict(itemIdentifier=identifier,
                           label=label,
                           callback=callback,
                           view=view)
        else:
            newItem = dict(itemIdentifier=identifier,
                           label=label,
                           imageObject=image,
                           callback=callback)

        toolbarItems.insert(index, newItem)
コード例 #4
0
    def glyphEditorWantsToolbarItems(self, info):

        toolbarItems = info['itemDescriptions']

        label = 'Add Overlap'
        identifier = 'addOverlap'
        callback = self.addOverlap
        index = -2

        bundle = ExtensionBundle("AddOverlap")
        icon = bundle.getResourceImage("AddOverlapButton")

        view = ToolbarGlyphTools((30, 25), [dict(image=icon, toolTip=label)],
                                 trackingMode="one")

        newItem = dict(itemIdentifier=identifier,
                       label=label,
                       callback=callback,
                       view=view)

        toolbarItems.insert(index, newItem)