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


Python AppKit.NSBundle类代码示例

本文整理汇总了Python中AppKit.NSBundle的典型用法代码示例。如果您正苦于以下问题:Python NSBundle类的具体用法?Python NSBundle怎么用?Python NSBundle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: resource_path

def resource_path(resource, resource_type):
        path = NSBundle.mainBundle().pathForResource_ofType_(
            resource, resource_type)
        if NSFileManager.defaultManager().fileExistsAtPath_(path):
            return path
        else:
            return None
开发者ID:JulianEberius,项目名称:qsx,代码行数:7,代码来源:utils.py

示例2: _init_popover

    def _init_popover(self):
        print 'init popover'
        #import pdb; pdb.set_trace()
        rect = NSMakeRect(0, 0, 40, 40)
        self.button = NSButton.alloc().initWithFrame_(rect)
        self.button.setImage_(self._app['_icon_nsimage'])
        self.button.setAction_('mycallback:')
        #self.button.setTransparent_(True)
        self.button.setBordered_(False)
        self.button.setTitle_('W')
        self.button.setButtonType_(AppKit.NSMomentaryChangeButton)

        print 'BUTTON ', self.nsstatusitem.action
        #rect2 = NSMakeRect(0, 0, 100, 100)
        self.popover = NSPopover.alloc().init()
        #myBundle = NSBundle bundleWithPath:@"/Library/MyBundle.bundle"]
        myBundle = NSBundle.alloc().initWithPath_("/Users/pfitzsimmons/repos/webchiver/app/webchiver.bundle")
        #view_controller = NSViewController.alloc().initWithNibName_bundle_('SnippetPopoverViewController.nib', myBundle)
        view_controller = PopViewController.alloc().init()
        #self.popover.setContentViewController_(view_controller)
        #self.nsstatusitem.setAction_('mycallback:')
        self.nsstatusitem.setView_(self.button)
        #import pdb; pdb.set_trace()

        rect3 = NSMakeRect(500, 500, 600, 600)
        self.window = MyWindow.alloc().initWithContentRect_styleMask_backing_defer_(
            rect3,
            AppKit.NSBorderlessWindowMask,
            #AppKit.NSTexturedBackgroundWindowMask,
            NSBackingStoreBuffered,
            True
            )
        self.window.setOpaque_(False)
开发者ID:pfitzsimmons,项目名称:rumps,代码行数:33,代码来源:rumps.py

示例3: initialize

    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,代码行数:33,代码来源:MailWrap.py

示例4: keyboard_tap_callback

def keyboard_tap_callback(proxy, type_, event, refcon):
        from AppKit import NSKeyUp, NSEvent, NSBundle
        NSBundle.mainBundle().infoDictionary()['NSAppTransportSecurity'] =\
            dict(NSAllowsArbitraryLoads=True)
        if type_ < 0 or type_ > 0x7fffffff:
            LOG.error('Unkown mac event')
            run_event_loop()
            LOG.error('restart mac key board event loop')
            return event
        try:
            key_event = NSEvent.eventWithCGEvent_(event)
        except:
            LOG.info("mac event cast error")
            return event
        if key_event.subtype() == 8:
            key_code = (key_event.data1() & 0xFFFF0000) >> 16
            key_state = (key_event.data1() & 0xFF00) >> 8
            if key_code in (16, 19, 20):
                # 16 for play-pause, 19 for next, 20 for previous
                if key_state == NSKeyUp:
                    if key_code is 19:
                        ControllerApi.player.play_next()
                    elif key_code is 20:
                        ControllerApi.player.play_last()
                    elif key_code is 16:
                        ControllerApi.player.play_or_pause()
                return None
        return event
开发者ID:JamesMackerel,项目名称:FeelUOwn,代码行数:28,代码来源:mac.py

示例5: keyboard_tap_callback

def keyboard_tap_callback(proxy, type_, event, refcon):
    from AppKit import NSKeyUp, NSEvent, NSBundle
    NSBundle.mainBundle().infoDictionary()['NSAppTransportSecurity'] =\
        dict(NSAllowsArbitraryLoads=True)
    if type_ < 0 or type_ > 0x7fffffff:
        logger.error('Unkown mac event')
        run_event_loop()
        logger.error('restart mac key board event loop')
        return event
    try:
        key_event = NSEvent.eventWithCGEvent_(event)
    except:
        logger.info("mac event cast error")
        return event
    if key_event.subtype() == 8:
        key_code = (key_event.data1() & 0xFFFF0000) >> 16
        key_state = (key_event.data1() & 0xFF00) >> 8
        if key_code in (16, 19, 20):
            # 16 for play-pause, 19 for next, 20 for previous
            if key_state == NSKeyUp:
                if key_code is 19:
                    logger.info('mac hotkey: play next')
                    send_cmd('next')
                elif key_code is 20:
                    logger.info('mac hotkey: play last')
                    send_cmd('previous')
                elif key_code is 16:
                    os.system('echo "play_pause" | nc -4u -w0 localhost 8000')
                    send_cmd('toggle')
            return None
    return event
开发者ID:cosven,项目名称:feeluown-mac-hotkey-plugin,代码行数:31,代码来源:mac.py

示例6: migrateSupport

def migrateSupport(oldAppName, newAppName):
    print('Checking Miro preferences and support migration...')

    global migrated
    migrated = False

    from AppKit import NSBundle

    prefsPath = os.path.expanduser('~/Library/Preferences').decode('utf-8')
    newDomain = NSBundle.mainBundle().bundleIdentifier()
    newPrefs = '%s.plist' % os.path.join(prefsPath, newDomain)
    oldDomain = newDomain.replace(newAppName, oldAppName)
    oldPrefs = '%s.plist' % os.path.join(prefsPath, oldDomain)
    
    if os.path.exists(oldPrefs):
        if os.path.exists(newPrefs):
            print("Both %s and %s preference files exist." % (oldAppName, newAppName))
        else:
            os.rename(oldPrefs, newPrefs)
            print("Migrated preferences to %s" % newPrefs)

    supportFolderRoot = os.path.expanduser('~/Library/Application Support')
    oldSupportFolder = os.path.join(supportFolderRoot, oldAppName)
    newSupportFolder = os.path.join(supportFolderRoot, newAppName)
    if os.path.exists(oldSupportFolder):
        if os.path.exists(newSupportFolder):
            print("Both %s and %s support folders exist." % (oldAppName, newAppName))
        else:
            os.rename(oldSupportFolder, newSupportFolder)
            print("Migrated support folder to %s" % newSupportFolder)
            migrated = True
开发者ID:cool-RR,项目名称:Miro,代码行数:31,代码来源:migrateappname.py

示例7: extract_tb

def extract_tb(tb, script=None, src=None):
    """Return a list of pre-processed entries from traceback."""
    list = []
    n = 0
    while tb is not None:
        f = tb.tb_frame
        lineno = tb.tb_lineno
        co = f.f_code
        filename = co.co_filename
        name = co.co_name
        if filename==script:
            line = src.split('\n')[lineno-1]
        else:
            linecache.checkcache(filename)
            line = linecache.getline(filename, lineno, f.f_globals)
        if line: line = line.strip()
        else: line = None
        list.append((filename, lineno, name, line))
        tb = tb.tb_next

    # omit the internal plotdevice stack frames in `dist` builds
    from AppKit import NSBundle
    debug = 'flux' in NSBundle.mainBundle().infoDictionary().get('CFBundleVersion','')
    if not debug:
        moduledir = abspath(dirname(dirname(__file__)))
        return [frame for frame in list if moduledir not in frame[0]]
    return list
开发者ID:VinayPrakashSingh,项目名称:plotdevice,代码行数:27,代码来源:common.py

示例8: initWithApp_

 def initWithApp_(self, app):
     self = super(Menu, self).init()
     if self is None:
         return None
     self.app        = app
     self.mainwindow = NSApplication.sharedApplication().mainWindow()
     self.bundle     = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix')
     return self
开发者ID:GLOP1978,项目名称:quotefixformac,代码行数:8,代码来源:menu.py

示例9: init

 def init(self):
     bundle = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix')
     nib = bundle.loadNibNamed_owner_topLevelObjects_('QuoteFixPreferencesModule', self, None)
     if not nib or nib[0] < 1:
         raise AssertionError('unable to load nib')
     nib[1].retain()
     self.view = filter(lambda _: isinstance(_, NSBox), nib[1])[0]
     self.setMinSize_(self.view.boundsSize())
     self.setPreferencesView_(self.view)
     return self
开发者ID:robertklep,项目名称:quotefixformac,代码行数:10,代码来源:preferences.py

示例10: _helpBookCallback

 def _helpBookCallback(self, sender):
     from Carbon import AH
     bundle = NSBundle.mainBundle()
     if bundle is None:
         return
     info = bundle.infoDictionary()
     helpBookName = info.get("CFBundleHelpBookName")
     if self._page is not None:
         AH.AHGoToPage(helpBookName, self._page, self._anchor)
     elif self._anchor is not None:
         AH.AHLookupAnchor(helpBookName, self._anchor)
开发者ID:LettError,项目名称:vanilla,代码行数:11,代码来源:vanillaButton.py

示例11: finishLaunching

    def finishLaunching(self):
        # Make statusbar item
        statusbar = NSStatusBar.systemStatusBar()
        self.statusitem = statusbar.statusItemWithLength_(
            NSVariableStatusItemLength)
        # Thanks Matthias Kretschmann
        # at http://kremalicious.com/coffee-cup-icon/
        icon_path = NSBundle.mainBundle()\
                            .pathForResource_ofType_(
                                ICON_BASE, ICON_EXT)
        if not icon_path:
            icon_path = ICON_FILE
        self.icon = NSImage.alloc()\
                           .initByReferencingFile_(icon_path)
        self.icon.setScalesWhenResized_(True)
        self.icon.setSize_((20, 20))
        self.statusitem.setImage_(self.icon)

        # Make the menu
        self.menubarMenu = NSMenu.alloc().init()

        self.menuItem = NSMenuItem.alloc()\
                                  .initWithTitle_action_keyEquivalent_(
                                      'Connect', 'connectAndCloseCNA:', '')
        self.menubarMenu.addItem_(self.menuItem)

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

        # Add menu to statusitem
        self.statusitem.setMenu_(self.menubarMenu)
        self.statusitem.setToolTip_('Cartel')
        self.statusitem.setHighlightMode_(True)

        # Get the default notification center.
        self.workspace = NSWorkspace.sharedWorkspace()
        self.default_center = NSNotificationCenter.defaultCenter()

        # Create the handler
        self.rhandler = ReachabilityHandler.new()
        self.rhandler.app = self

        self.default_center.addObserver_selector_name_object_(
            self.rhandler,
            "handleChange:",
            kReachabilityChangedNotification,
            None)

        # Create the reachability object and start notifactions.
        self.reachability = Reachability()
        self.reachability.startNotifier()
开发者ID:jmatt,项目名称:cartel,代码行数:53,代码来源:cartel.py

示例12: applicationDidFinishLaunching_

 def applicationDidFinishLaunching_(self, notification):
     u"""
     Setting up globals.
     """
     print '* Meta Application finished launching, initializing...'
     self.model = Model()
     self.path = os.path.join(os.path.dirname(__file__))
     self.resourcePath = NSBundle.mainBundle().resourcePath()
     self.documentFilesPath = self.resourcePath + '/en.lproj/'
     path = '/Users/michiel/Projects/Meta/imftc/imftc.meta'
     document = self.model.openDocument(path)
     self.openStartWindow()
开发者ID:michielkauwatjoe,项目名称:Meta,代码行数:12,代码来源:delegate.py

示例13: executeVanillaTest

def executeVanillaTest(cls, nibPath=None, calls=None, **kwargs):
    """
    Execute a Vanilla UI class in a mini application.
    """
    app = NSApplication.sharedApplication()
    delegate = _VanillaMiniAppDelegate.alloc().init()
    app.setDelegate_(delegate)

    if nibPath:
        NSBundle.loadNibFile_externalNameTable_withZone_(nibPath, {}, None)
    else:
        mainMenu = NSMenu.alloc().initWithTitle_("Vanilla Test")

        fileMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("File", None, "")
        fileMenu = NSMenu.alloc().initWithTitle_("File")
        fileMenuItem.setSubmenu_(fileMenu)
        mainMenu.addItem_(fileMenuItem)

        editMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Edit", None, "")
        editMenu = NSMenu.alloc().initWithTitle_("Edit")
        editMenuItem.setSubmenu_(editMenu)
        mainMenu.addItem_(editMenuItem)

        helpMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Help", None, "")
        helpMenu = NSMenu.alloc().initWithTitle_("Help")
        helpMenuItem.setSubmenu_(helpMenu)
        mainMenu.addItem_(helpMenuItem)

        app.setMainMenu_(mainMenu)

    if cls is not None:
        cls(**kwargs)

    if calls is not None:
        for call, kwargs in calls:
            call(**kwargs)

    app.activateIgnoringOtherApps_(True)
    AppHelper.runEventLoop()
开发者ID:LettError,项目名称:vanilla,代码行数:39,代码来源:testTools.py

示例14: check_version

    def check_version(self):
        infodict    = NSBundle.mainBundle().infoDictionary()
        mailversion = infodict['CFBundleVersion']
        lastknown   = self.prefs.string["QuoteFixLastKnownBundleVersion"]
        if lastknown and lastknown != mailversion:
            NSRunAlertPanel(
                'QuoteFix plug-in',
                '''
The QuoteFix plug-in detected a different Mail.app version (perhaps you updated?).

If you run into any problems with regards to replying or forwarding mail, consider removing this plug-in (from ~/Library/Mail/Bundles/).

(This alert is only displayed once for each new version of Mail.app)''',
                    None,
                    None,
                    None
            )
            self.prefs.string["QuoteFixLastKnownBundleVersion"] = mailversion
开发者ID:GLOP1978,项目名称:quotefixformac,代码行数:18,代码来源:app.py

示例15: awakeFromNib

    def awakeFromNib(self):
        self.currentVersionUpdater.setStringValue_(self.app.version)
        self.updateInterval.setSelectedSegment_(self.app.check_update_interval)
        self.setLastUpdateCheck()

        # set donate image
        bundle  = NSBundle.bundleWithIdentifier_('name.klep.mail.QuoteFix')
        path    = bundle.pathForResource_ofType_("donate", "gif")
        image   = NSImage.alloc().initByReferencingFile_(path)
        self.donateButton.setImage_(image)

        # check custom signature matcher
        self.check_signature_matcher(self.customSignatureMatcher)
        self.customSignatureMatcherDefault.setStringValue_(self.app.default_signature_matcher)

        # set attribution previews
        self.set_preview(self.customReplyAttribution)
        self.set_preview(self.customForwardingAttribution)
        self.set_preview(self.customSendAgainAttribution)
开发者ID:robertklep,项目名称:quotefixformac,代码行数:19,代码来源:preferences.py


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