当前位置: 首页>>代码示例>>Python>>正文


Python NSMenuItem.separatorItem方法代码示例

本文整理汇总了Python中AppKit.NSMenuItem.separatorItem方法的典型用法代码示例。如果您正苦于以下问题:Python NSMenuItem.separatorItem方法的具体用法?Python NSMenuItem.separatorItem怎么用?Python NSMenuItem.separatorItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppKit.NSMenuItem的用法示例。


在下文中一共展示了NSMenuItem.separatorItem方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setupUI

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
    def setupUI(self):
        self.statusbar = NSStatusBar.systemStatusBar()
        self.statusitem = self.statusbar.statusItemWithLength_(NSVariableStatusItemLength) #NSSquareStatusItemLength #NSVariableStatusItemLength

        # Set initial image icon
        icon_path = os.path.join(current_path, "../trayicon.ico")
        image = NSImage.alloc().initByReferencingFile_(icon_path)
        image.setScalesWhenResized_(True)
        image.setSize_((20, 20))
        self.statusitem.setImage_(image)

        # Let it highlight upon clicking
        self.statusitem.setHighlightMode_(1)
        self.statusitem.setToolTip_("ZeroNet")

        # Build a very simple menu
        self.menu = NSMenu.alloc().init()
        self.menu.setAutoenablesItems_(False)

        #self.create_menu_item( 'ip_external', 'IP: %s' % INFO['ip_external'],  'info:')
        self.menu.addItem_( NSMenuItem.separatorItem() )

        # Links
        self.create_menu_item( 'open_zeronet', 'Open ZeroNet',  'open:')
        self.create_menu_item( 'open_reddit', 'Zeronet Reddit Community', 'openreddit:')
        self.create_menu_item( 'open_gh', 'Report issues/feature requests', 'opengithub:')

        self.menu.addItem_( NSMenuItem.separatorItem() )

        self.create_menu_item( 'quit_zeronet', 'Quit ZeroNet', 'windowWillClose:' )

        # Bind it to the status item and hide dock icon
        self.statusitem.setMenu_(self.menu)
        NSApp.setActivationPolicy_(NSApplicationActivationPolicyProhibited)
开发者ID:barrabinfc,项目名称:ZeroNet,代码行数:36,代码来源:tray_osx.py

示例2: inject

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
    def inject(self):
        try:
            # necessary because of the menu callbacks
            self.retain()

            # get application menu instance
            appmenu = NSApplication.sharedApplication().mainMenu().itemAtIndex_(0).submenu()

            # make a new menu item
            self.item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
                "QuoteFix",
                "toggleState:",
                "")
            self.item.setToolTip_(self.get_string("QUOTEFIX_TOOLTIP", ""))
            self.set_state_and_title(self.item)
            self.item.setTarget_(self)

            # add separator and new item
            appmenu.insertItem_atIndex_(NSMenuItem.separatorItem(), 1)
            appmenu.insertItem_atIndex_(self.item, 2)

            # observe changes for active state
            NSUserDefaultsController.sharedUserDefaultsController().addObserver_forKeyPath_options_context_(
                self,
                "values.QuoteFixDisabled",
                NSKeyValueObservingOptionNew,
                None
            )

        except Exception, e:
            raise e
开发者ID:GLOP1978,项目名称:quotefixformac,代码行数:33,代码来源:menu.py

示例3: initialize

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
    def initialize(cls):
        # Register ourselves as a Mail.app plugin and add an entry for our
        # 'Fill Text' and Wrap Text' actions to the Edit menu.

        application = NSApplication.sharedApplication()
        bundle = NSBundle.bundleWithIdentifier_('uk.me.cdw.MailWrap')
        cls.registerBundle()

        editmenu = application.mainMenu().itemAtIndex_(2).submenu()
        editmenu.addItem_(NSMenuItem.separatorItem())

        mask = NSCommandKeyMask | NSAlternateKeyMask
        editmenu.addItemWithTitle_action_keyEquivalent_('Fill Text',
            'fillText', '\\').setKeyEquivalentModifierMask_(mask)

        mask = NSCommandKeyMask
        editmenu.addItemWithTitle_action_keyEquivalent_('Wrap Text',
            'wrapText', "\\").setKeyEquivalentModifierMask_(mask)

        # Read our configuration settings if present. Otherwise, set the
        # correct default values.

        defaults = NSUserDefaults.standardUserDefaults()
        defaults = defaults.dictionaryForKey_('MailWrap') or {}
        ComposeViewController._fixAttribution = defaults.get('FixAttribution', False)
        EditingMessageWebView._bulletLists = defaults.get('BulletLists', True)
        EditingMessageWebView._indentWidth = int(defaults.get('IndentWidth', 2))
        EditingMessageWebView._wrapWidth = int(defaults.get('WrapWidth', 72))

        # Report the plugin name and version to the com.apple.mail log.

        version = bundle.objectForInfoDictionaryKey_('CFBundleVersion')
        NSLog('Loaded MailWrap %s' % version)
开发者ID:javigon,项目名称:mailwrap,代码行数:35,代码来源:MailWrap.py

示例4: applicationDidFinishLaunching_

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
  def applicationDidFinishLaunching_(self, notification):
    self.noDevice = None

    #Create menu
    self.menu = NSMenu.alloc().init()

    self.barItem = dict()

    # Load images
    self.noDeviceImage = NSImage.alloc().initByReferencingFile_('icons/no_device.png')
    self.barImage = dict(kb = NSImage.alloc().initByReferencingFile_('icons/kb.png'),
			 magicMouse = NSImage.alloc().initByReferencingFile_('icons/magic_mouse.png'),
			 mightyMouse = NSImage.alloc().initByReferencingFile_('icons/mighty_mouse.png'),
			 magicTrackpad = NSImage.alloc().initByReferencingFile_('icons/TrackpadIcon.png'))

    #Define menu items
    self.statusbar = NSStatusBar.systemStatusBar()
    self.menuAbout = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('About BtBatStat', 'about:', '')
    self.separator_menu_item = NSMenuItem.separatorItem()
    self.menuQuit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')

    # Get the timer going
    self.timer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(start_time, 10.0, self, 'tick:', None, True)
    NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode)
    self.timer.fire()

    #Add menu items
    self.menu.addItem_(self.menuAbout)
    self.menu.addItem_(self.separator_menu_item)
    self.menu.addItem_(self.menuQuit)

    #Check for updates
    checkForUpdates()
开发者ID:Ku2f,项目名称:btbatstat,代码行数:35,代码来源:BtBatStat.py

示例5: constructMenu

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
    def constructMenu(self):
        self.menu.removeAllItems()

        separator_required = False
        if self.is_ip_assigned:
            # For each of the proxyTypes we are concerned with, check to see if any
            # are configured. If so (even if not enabled), create a menuitem for
            # that proxy type.
            for proxy in self.proxyTypes.values():
                enabled = CFDictionaryGetValue(self.prefDict, proxy['prefEnable'])
                if enabled is not None:
                    proxy['menuitem'] = self.menu.addItemWithTitle_action_keyEquivalent_(
                        proxy['title'],
                        proxy['action'],
                        proxy['keyEquivalent']
                    )
                    separator_required = True
                else:
                    proxy['menuitem'] = None
        else:
            self.menu.addItemWithTitle_action_keyEquivalent_("No connection - Please connect to any network before using this tool", None, "")

        if separator_required:
            self.menu.addItem_(NSMenuItem.separatorItem())

         # Need a way to quit
        self.menu.addItemWithTitle_action_keyEquivalent_("Quit", "quitApp:", "q")
开发者ID:arnaudruffin,项目名称:OsxProxyToggler,代码行数:29,代码来源:ToggleProxy.py

示例6: setupStatusBar

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
    def setupStatusBar(self):
        statusbar = NSStatusBar.systemStatusBar()
        statusitem = statusbar.statusItemWithLength_(20).retain()
        
        icon = NSImage.imageNamed_('status')
        icon.setSize_((20, 20))
        statusitem.setImage_(icon)
        
        iconHighlight = NSImage.imageNamed_('status-hi')
        iconHighlight.setSize_((20, 20))
        statusitem.setAlternateImage_(iconHighlight)
        
        statusitem.setHighlightMode_(1)
        
        # TODO: Put this whole menu creation stuff into interface builder!
        menu = NSMenu.alloc().init()
        
        linkMenu = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Post a Link', 'doLink:', '')
        linkMenu.setTarget_(self);
        # Make it possible to invoke the link menu via a keyboard shortcut.
        linkMenu.setKeyEquivalentModifierMask_(NSShiftKeyMask | NSCommandKeyMask)
        linkMenu.setKeyEquivalent_('l')
        menu.addItem_(linkMenu)
        
        
        menu.addItem_(NSMenuItem.separatorItem())
        
        previewMenu = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Update Preview', 'doPreview:', '')
        previewMenu.setTarget_(self);
        menu.addItem_(previewMenu)
        
        publishMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Publish', None, '')
        publishMenu = NSMenu.alloc().init();
        s3MenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('S3', 'doPublish:', '')
        s3MenuItem.setTarget_(self);
        publishMenu.addItem_(s3MenuItem)
        publishMenuItem.setSubmenu_(publishMenu)
        menu.addItem_(publishMenuItem)
        
        menu.addItem_(NSMenuItem.separatorItem())

        quitMenu = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')
        menu.addItem_(quitMenu)
        
        statusitem.setMenu_(menu)
        menu.release();
开发者ID:Mondego,项目名称:pyreco,代码行数:48,代码来源:allPythonContent.py

示例7: _initialize_menu

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
    def _initialize_menu(self):
        self.menubarMenu = NSMenu.alloc().init()
        for schedule in self._schedules:
            menu_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(schedule.name, 'execute:', '')
            self._menu_items.append(menu_item)
            self.menubarMenu.addItem_(menu_item)

        menu_item = NSMenuItem.separatorItem()
        self.menubarMenu.addItem_(menu_item)

        self.quit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')
        self.menubarMenu.addItem_(self.quit)

        self.statusitem.setMenu_(self.menubarMenu)
        self.statusitem.setToolTip_('Crow')
开发者ID:smartstudy,项目名称:project_cron,代码行数:17,代码来源:main.py

示例8: addMenuItemsForEvent_toMenu_

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
	def addMenuItemsForEvent_toMenu_(self, theEvent, theMenu):
		"""
		Adds menu items to default context menu.
		Remove this method if you do not want any extra context menu items.
		"""
		try:

			if hasattr(self, 'conditionalContextMenus'):
				contextMenus = self.conditionalContextMenus()

				if contextMenus:
					# Todo: Make sure that the index is 0 for all items,
					# i.e., add at top rather than at bottom of menu:
					newSeparator = NSMenuItem.separatorItem()
					theMenu.addItem_(newSeparator)
					setUpMenuHelper(theMenu, contextMenus, self)

		except:
			self.logError(traceback.format_exc())
开发者ID:schriftgestalt,项目名称:GlyphsSDK,代码行数:21,代码来源:plugins.py

示例9: defaultContextMenu

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
	def defaultContextMenu(self):
		"""
		Sets the default content of the context menu and returns the menu.
		Add menu items that do not depend on the context,
		e.g., actions that affect the whole layer, no matter what is selected.
		Remove this method if you do not want any extra context menu items.
		"""
		try:
			# Get the current default context menu:
			theMenu = objc.super(SelectTool, self).defaultContextMenu()

			# Add separator at the bottom:
			newSeparator = NSMenuItem.separatorItem()
			theMenu.addItem_(newSeparator)

			# Add menu items at the bottom:
			setUpMenuHelper(theMenu, self.generalContextMenus, self)

			return theMenu
		except:
			self.logError(traceback.format_exc())
开发者ID:schriftgestalt,项目名称:GlyphsSDK,代码行数:23,代码来源:plugins.py

示例10: _buildMenu

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
 def _buildMenu(self, items, menu):
     for item in items:
         if isinstance(item, NSMenuItem):
             menu.addItem_(item)
         elif item == "----":
             item = NSMenuItem.separatorItem()
             menu.addItem_(item)
         else:
             title = item["title"]
             callback = item.get("callback")
             subItems = item.get("items")
             
             menuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(title, "", "")
             if callback:
                 wrapper = VanillaCallbackWrapper(callback)
                 self._callbackWrappers.append(wrapper)
                 menuItem.setTarget_(wrapper)
                 menuItem.setAction_("action:")
             if subItems:
                 subMenu = NSMenu.alloc().init()
                 self._buildMenu(subItems, subMenu)
                 menuItem.setSubmenu_(subMenu)
             menu.addItem_(menuItem)
开发者ID:schriftgestalt,项目名称:vanilla,代码行数:25,代码来源:vanillaPopUpButton.py

示例11: __init__

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
 def __init__(self):
     self._menuitem = NSMenuItem.separatorItem()
开发者ID:philippeowagner,项目名称:rumps,代码行数:4,代码来源:rumps.py

示例12: _add_separator_to_platform_menu

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
 def _add_separator_to_platform_menu(self):
     ns_item = NSMenuItem.separatorItem()
     self._ns_menu.addItem_(ns_item)
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:5,代码来源:Menu.py

示例13: _populatePlacard

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
 def _populatePlacard(self):
     if not hasattr(self, "placard"):
         return
     options = self._placardOptions = [
         (None, None, None),  # Display...
         ("Fill", "showGlyphFill", None),
         ("Stroke", "showGlyphStroke", None),
         ("Image", "showGlyphImage", None),
         ("Metrics", "showGlyphMargins", None),
         ("On Curve Points", "showGlyphOnCurvePoints", None),
         ("Off Curve Points", "showGlyphOffCurvePoints", None),
         ("Point Coordinates", "showGlyphPointCoordinates", None),
         ("Anchors", "showGlyphAnchors", None),
         ("Blues", "showFontPostscriptBlues", None),
         ("Family Blues", "showFontPostscriptFamilyBlues", None),
         (None, None, None),  # layer divider
     ]
     if not hasattr(self, "_placardLayerOptions"):
         self._placardLayerOptions = {}
     # title
     item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Display...", None, "")
     item.setHidden_(True)
     items = [item]
     # main layer
     for title, drawingAttribute, layerName in options:
         if title is None:
             continue
         state = self.getDrawingAttribute(drawingAttribute)
         item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(title, None, "")
         item.setState_(state)
         items.append(item)
     # sub layers
     glyph = self._glyphView.getGlyph()
     if glyph is not None:
         layerSet = glyph.layerSet
         if layerSet is not None:
             if len(layerSet.layerOrder) > 1:
                 items.append(NSMenuItem.separatorItem())
                 # prep the state dictionary
                 for layerName in list(self._placardLayerOptions.keys()):
                     if layerName not in layerSet:
                         del self._placardLayerOptions[layerName]
                 for layerName in layerSet.layerOrder:
                     if layerName not in self._placardLayerOptions:
                         self._placardLayerOptions[layerName] = False
                 for layerName in layerSet.layerOrder:
                     state = self._placardLayerOptions[layerName]
                     enabled = True
                     if layerName == glyph.layer.name:
                         state = True
                         enabled = False
                     self._placardOptions.append((None, None, layerName))
                     title = "Layer: %s" % layerName
                     item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(title, None, "")
                     item.setState_(state)
                     item.setEnabled_(enabled)
                     items.append(item)
     # set the items
     self.placard.optionsButton.setItems(items)
     button = self.placard.optionsButton.getNSPopUpButton()
     button.setTitle_("Display...")
     # update the layer options
     self._updateLayerDrawingAttributes()
开发者ID:typesupply,项目名称:defconAppKit,代码行数:65,代码来源:glyphView.py

示例14: setFont

# 需要导入模块: from AppKit import NSMenuItem [as 别名]
# 或者: from AppKit.NSMenuItem import separatorItem [as 别名]
 def setFont(self, font):
     # script list
     if font is None:
         scriptList = []
     else:
         scriptList = ["DFLT"] + font.getScriptList()
     unsupportedScripts = [i for i in scriptTags if i not in scriptList]
     if unsupportedScripts:
         scriptList.append(NSMenuItem.separatorItem())
         scriptList += unsupportedScripts
     self._controlGroup.scriptPopUpButton.setItems(scriptList)
     # language list
     if font is None:
         languageList = []
     else:
         languageList = ["Default"] + font.getLanguageList()
     unsupportedLanguages = [i for i in languageTags if i not in languageList]
     if unsupportedLanguages:
         languageList.append(NSMenuItem.separatorItem())
         languageList += unsupportedLanguages
     self._controlGroup.languagePopUpButton.setItems(languageList)
     # teardown existing controls
     for attr in self._gsubAttributes:
         delattr(self._controlGroup, attr)
     for attr in self._gposAttributes:
         delattr(self._controlGroup, attr)
     for attr in self._featureNames:
         delattr(self._controlGroup, attr)
     if hasattr(self._controlGroup, "gposTitle"):
         del self._controlGroup.gposTitle
     if hasattr(self._controlGroup, "gsubTitle"):
         del self._controlGroup.gsubTitle
     # stylistic set names
     if hasattr(font, "stylisticSetNames"):
         stylisticSetNames = font.stylisticSetNames
     else:
         stylisticSetNames = {}
     # GSUB
     top = self._dynamicTop
     if font is None:
         gsub = None
     else:
         gsub = font.gsub
     if gsub is None:
         gsubFeatureList = []
     else:
         gsubFeatureList = gsub.getFeatureList()
     self._gsubAttributes = {}
     self._featureNames = {}
     if gsubFeatureList:
         self._controlGroup.gsubTitle = vanilla.TextBox((10, top, -10, 14),
             NSAttributedString.alloc().initWithString_attributes_("GSUB", titleControlAttributes), sizeStyle="small")
         top += 20
         for tag in gsubFeatureList:
             state = font.gsub.getFeatureState(tag)
             attr = "gsubCheckBox_%s" % tag
             obj = vanilla.CheckBox((10, top, -10, 22), tag, value=state, callback=self._controlEditCallback)
             setattr(self._controlGroup, attr, obj)
             self._gsubAttributes[attr] = tag
             top += 20
             # stylistic set name
             if tag in stylisticSetNames:
                 attr = "ssName_%s" % tag
                 setName = stylisticSetNames[tag]
                 if hasattr(self._controlGroup, attr):
                     obj = getattr(self._controlGroup, attr)
                     obj.set(setName)
                 else:
                     obj = vanilla.TextBox((26, top, -10, 13), setName, sizeStyle="mini")
                     setattr(self._controlGroup, attr, obj)
                 self._featureNames[attr] = setName
                 top += 13
         top += 10
     # GPOS
     if font is None:
         gpos = None
     else:
         gpos = font.gpos
     if gpos is None:
         gposFeatureList = []
     else:
         gposFeatureList = gpos.getFeatureList()
     self._gposAttributes = {}
     if gposFeatureList:
         self._controlGroup.gposTitle = vanilla.TextBox((10, top, -10, 14),
             NSAttributedString.alloc().initWithString_attributes_("GPOS", titleControlAttributes), sizeStyle="small")
         top += 20
         for tag in gposFeatureList:
             state = font.gpos.getFeatureState(tag)
             attr = "gposCheckBox_%s" % tag
             obj = vanilla.CheckBox((10, top, -10, 22), tag, value=state, callback=self._controlEditCallback)
             setattr(self._controlGroup, attr, obj)
             self._gposAttributes[attr] = tag
             top += 20
         top += 10
     # set the view size
     (x, y), (w, h) = self._nsObject.documentView().frame()
     self._nsObject.documentView().setFrame_(((x, y), (w, top)))
     x, y, w, h = self._controlGroup.getPosSize()
     self._controlGroup.setPosSize((x, y, w, top))
开发者ID:andyclymer,项目名称:defconAppKit,代码行数:102,代码来源:openTypeControlsView.py


注:本文中的AppKit.NSMenuItem.separatorItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。