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


Python AppKit.NSApplication类代码示例

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


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

示例1: run

  def run(self):
    NSApplication.sharedApplication()
    self.delegate = AppDelegate.alloc().init()
    self.delegate.event_sniffer = self

    NSApp().setDelegate_(self.delegate)

    self.workspace = NSWorkspace.sharedWorkspace()
    nc = self.workspace.notificationCenter()

    # This notification needs OS X v10.6 or later
    nc.addObserver_selector_name_object_(
        self.delegate,
        'applicationActivated:',
        'NSWorkspaceDidActivateApplicationNotification',
        None)

    nc.addObserver_selector_name_object_(
        self.delegate,
        'screenSleep:',
        'NSWorkspaceScreensDidSleepNotification',
        None)

    # I don't think we need to track when the screen comes awake, but in case
    # we do we can listen for NSWorkspaceScreensDidWakeNotification

    NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
        self.options.active_window_time, self.delegate, 'writeActiveApp:',
        None, True)

    # Start the application. This doesn't return.
    AppHelper.runEventLoop()
开发者ID:liuzl,项目名称:ulogme,代码行数:32,代码来源:ulogme_osx.py

示例2: run

 def run(self):
     NSApplication.sharedApplication()
     delegate = self.createAppDelegate().alloc().init()
     NSApp().setDelegate_(delegate)
     NSApp().setActivationPolicy_(NSApplicationActivationPolicyProhibited)
     self.workspace = NSWorkspace.sharedWorkspace()
     AppHelper.runEventLoop()
开发者ID:johniv,项目名称:selfspy,代码行数:7,代码来源:sniff_cocoa.py

示例3: startupOKAction_

    def startupOKAction_(self, btn):
        """
        User clicked OK in the server setup sheet.
        """

        # Create the actual session.
        server = self.serverText.stringValue()
        path = self.pathText.stringValue()
        user = self.userText.stringValue()
        pswd = self.passwordText.stringValue()
        self.session = Session(server, path, user, pswd, logging=False)
        self.window.setTitle_(self.serverText.stringValue())
        self.pathLabel.setStringValue_(self.session.path)
        NSUserDefaults.standardUserDefaults().setObject_forKey_(server, "LastServer")
        NSUserDefaults.standardUserDefaults().setObject_forKey_(path, "LastPath")
        NSUserDefaults.standardUserDefaults().setObject_forKey_(user, "LastUser")

        # List the root resource.
        self.progress.startAnimation_(self)
        resources = self.session.getRoot().listChildren()
        self.progress.stopAnimation_(self)
        self.columns = [resources]

        # Done with the sheet.
        self.startupSheet.close()
        NSApplication.sharedApplication().endSheet_(self.startupSheet)

        # Force reload of browser pane views.
        self.browser.loadColumnZero()
        self.list.reloadItem_(None)
开发者ID:muelli,项目名称:CalDAVClientLibrary,代码行数:30,代码来源:WebDAVBrowser.py

示例4: interruptwait

def interruptwait():
    """
    If waituntil() has been called, this will interrupt the waiting process so
    it can check whether it should stop waiting.
    """
    evt = NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(NSApplicationDefined, NSPoint(), NSApplicationDefined, 0, 1, None, LIGHTBLUE_NOTIFY_ID, 0, 0)
    NSApplication.sharedApplication().postEvent_atStart_(evt, True)
开发者ID:640Labs,项目名称:lightblue-0.4,代码行数:7,代码来源:_macutil.py

示例5: __init__

 def __init__(self):
     # Force NSApp initialisation.
     NSApplication.sharedApplication().activateIgnoringOtherApps_(0)
     self.namespace = {}
     self.canvas = graphics.Canvas()
     self.context = graphics.Context(self.canvas, self.namespace)
     self.__doc__ = {}
     self._pageNumber = 1
     self.frame = 1
开发者ID:ajinkyakulkarni,项目名称:nodebox-pyobjc,代码行数:9,代码来源:console.py

示例6: resetServer_

 def resetServer_(self, sender):
     """
     Display the sheet asking for server details.
     """
     NSApplication.sharedApplication().beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(
         self.startupSheet,
         self.window,
         None, None, 0
     )
开发者ID:muelli,项目名称:CalDAVClientLibrary,代码行数:9,代码来源:WebDAVBrowser.py

示例7: run

    def run(self):
        NSApplication.sharedApplication()
        delegate = self.createAppDelegate().alloc().init()
        NSApp().setDelegate_(delegate)
        NSApp().setActivationPolicy_(NSApplicationActivationPolicyProhibited)
        self.workspace = NSWorkspace.sharedWorkspace()

        def handler(signal, frame):
            AppHelper.stopEventLoop()
        signal.signal(signal.SIGINT, handler)
        AppHelper.runEventLoop()
开发者ID:clstrfcuk,项目名称:selfspy,代码行数:11,代码来源:sniff_cocoa.py

示例8: log_std

def log_std(msg):
	from AppKit import NSAlert, NSInformationalAlertStyle, NSRunningApplication, NSApplicationActivateIgnoringOtherApps

	# initialize
	# tip from: http://graphicsnotes.blogspot.fr/2010/01/programmatically-creating-window-in-mac.html
	NSApplication.sharedApplication()
	NSRunningApplication.currentApplication().activateWithOptions_(NSApplicationActivateIgnoringOtherApps);

	alert = NSAlert.alloc().init()
	alert.autorelease()
	alert.setAlertStyle_(NSInformationalAlertStyle)
	alert.setMessageText_(msg)
	alert.runModal()
开发者ID:ChennyBaBy,项目名称:bin-scripts,代码行数:13,代码来源:export-current-omnigraffle-canvas.py

示例9: ns_process_key_event

 def ns_process_key_event(self, ns_event):
     #  Perform menu setup before command-key events.
     #  Send non-command key events to associated window if any,
     #  otherwise pass them to the pygui application. This is necessary
     #  because otherwise there is no way of receiving key events when
     #  there are no windows.
     if ns_event.modifierFlags() & NSCommandKeyMask:
         NSApplication.sendEvent_(self._ns_app, ns_event)
     else:
         ns_window = ns_event.window()
         if ns_window:
             ns_window.sendEvent_(ns_event)
         else:
             event = Event(ns_event)
             self.handle(event.kind, event)
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:15,代码来源:Application.py

示例10: generateStylesheets

def generateStylesheets(url):
    delegate = AppDelegate.alloc().init()
    delegate.url = url

    app = NSApplication.sharedApplication()
    app.setDelegate_(delegate)
    app.run()    
开发者ID:rf,项目名称:hacknyf2011,代码行数:7,代码来源:WebClient.py

示例11: awakeFromNib

	def awakeFromNib(self):
		print "Awakened from NIB"
		NSApplication.sharedApplication().setDelegate_(self)
		self.window().setFrameAutosaveName_("mainWindow")
		self.pids={}
		nc=NSNotificationCenter.defaultCenter()
		nc.addObserver_selector_name_object_(self,
			'deadProcess:',
			"NSTaskDidTerminateNotification",
			None)
		nc.addObserver_selector_name_object_(self,
			'runChecked:',
			"RUN_CHECKED",
			None)

		self.initDefaults()
开发者ID:dustin,项目名称:loginit,代码行数:16,代码来源:LogInit.py

示例12: start

    def start(self):
        # Load today's count data back from data file
        super(KeyCounter, self).start()

        NSApplication.sharedApplication()
        self.delegate = self._create_app_delegate().alloc().init()
        NSApp().setDelegate_(self.delegate)
        NSApp().setActivationPolicy_(NSApplicationActivationPolicyProhibited)

        signal.signal(signal.SIGINT, self.stop)
        signal.signal(signal.SIGTERM, self.stop)

        self._check_for_access()
        self.delegate.initializeStatusBar()

        AppHelper.runEventLoop()
开发者ID:mynicolas,项目名称:KeyCounter,代码行数:16,代码来源:macos_counter.py

示例13: selectGlyphsWithErrors

	def selectGlyphsWithErrors(self):
		"""
		Selects all glyphs with errors in the active layer
		"""
		font = NSApplication.sharedApplication().font
		if font is None:
			return None

		options, run_tests = self.selectGlyphsOptions()
		if run_tests is None:
			return
		if options is None:
			return
		
		font.disableUpdateInterface()
		mid = font.selectedFontMaster.id
		self.options["grid_length"] = font.gridLength
		glyphlist = font.glyphs.keys()
		outline_test_pen = OutlineTestPen(font, options, run_tests)
		for glyph_name in glyphlist:
			glyph = font.glyphs[glyph_name]
			layer = glyph.layers[mid]
			outline_test_pen.errors = []
			if layer is not None:
				try:
					layer.drawPoints(outline_test_pen)
					if len(outline_test_pen.errors) > 0:
						glyph.selected = True
					else:
						glyph.selected = False
				except Exception as e:
					self.logToConsole( "selectGlyphsWithErrors: Layer '%s': %s" % (glyph_name, str(e)) )
		font.enableUpdateInterface()
开发者ID:jenskutilek,项目名称:RedArrow-Glyphs,代码行数:33,代码来源:plugin.py

示例14: init

def init():
    print "init ui cocoa"
    global browserwindow
    app = NSApplication.sharedApplication()
    app.setActivationPolicy_(1)
    start_taskbar()
    app.finishLaunching()
    _browserwindow = NSWindow.alloc()
    icon = NSImage.alloc().initByReferencingFile_(settings.mainicon)
    app.setApplicationIconImage_(icon)
    
    deleg = Delegate.alloc()
    deleg.init()
    app.setDelegate_(deleg)
    
    signal.signal(signal.SIGINT, mac_sigint)
    
    from .input import BrowserDelegate
    bd = BrowserDelegate.alloc()
    bd.init()
    browserwindow = draw_browser(_browserwindow, bd)
    from .... import ui
    ui.log.debug('using cocoa')
    atexit.register(exit)
    gevent_timer(deleg)
    ui.module_initialized.set()
    sys.exit = exit
    AppHelper.runEventLoop()
开发者ID:Werniman,项目名称:client,代码行数:28,代码来源:app.py

示例15: run

    def run(self, **options):
        """Performs various setup tasks including creating the underlying Objective-C application, starting the timers,
        and registering callback functions for click events. Then starts the application run loop.

        .. versionchanged:: 0.2.1
            Accepts `debug` keyword argument.

        :param debug: determines if application should log information useful for debugging. Same effect as calling
                      :func:`rumps.debug_mode`.

        """
        dont_change = object()
        debug = options.get('debug', dont_change)
        if debug is not dont_change:
            debug_mode(debug)

        nsapplication = NSApplication.sharedApplication()
        nsapplication.activateIgnoringOtherApps_(True)  # NSAlerts in front
        self._nsapp = NSApp.alloc().init()
        self._nsapp._app = self.__dict__  # allow for dynamic modification based on this App instance
        nsapplication.setDelegate_(self._nsapp)
        if _NOTIFICATIONS:
            NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self._nsapp)

        setattr(App, '*app_instance', self)  # class level ref to running instance (for passing self to App subclasses)
        t = b = None
        for t in getattr(timer, '*timers', []):
            t.start()
        for b in getattr(clicked, '*buttons', []):
            b(self)  # we waited on registering clicks so we could pass self to access _menu attribute
        del t, b

        self._nsapp.initializeStatusBar()

        AppHelper.runEventLoop()
开发者ID:4m1g0,项目名称:duplicati,代码行数:35,代码来源:rumps.py


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