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


Python ScriptingBridge.SBApplication类代码示例

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


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

示例1: _get_opened_files_adobe_cc

def _get_opened_files_adobe_cc(identifier: str) -> Iterator[Item]:
    """
    Retrieve documents path of opened files of the given bundle *identifier* (application).
    Where application is one of the Adobe Creative Suite:

        >>> get_opened_files_via_com("com.adobe.Photoshop")
        >>> get_opened_files_via_com("com.adobe.Illustrator")

    Complete specs of supported applications:
        - Illustrator: https://www.adobe.com/devnet/illustrator/scripting.html
        - Photoshop: https://www.adobe.com/devnet/photoshop/scripting.html
    """
    if not _is_running(identifier):
        return

    app = SBApplication.applicationWithBundleIdentifier_(identifier)

    if not app or not app.isRunning():
        return

    documents = app.documents()
    if not documents:
        return

    for doc in documents:
        file_path = doc.filePath()
        if not file_path:
            # The document is not yet saved and so has no path
            continue

        path = file_path.path()
        pid = compute_fake_pid_from_path(path)
        yield pid, Path(path)
开发者ID:nuxeo,项目名称:nuxeo-drive,代码行数:33,代码来源:files.py

示例2: GET

 def GET(self):
     
     iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
     track = iTunes.currentTrack()
     
     web.header('Content-Type','text/html; charset=utf-8') 
     return render.nowplaying(track=track, iTunes=iTunes, len=len)
开发者ID:vinc3m1,项目名称:nowplaying,代码行数:7,代码来源:code.py

示例3: start_server

def start_server():
    """Spawn server. Does not check if the server is already running.
    """
    if run_cmd == '':
        # Complex run command not given, build it from the information available
        if mswindows or darwin:
            cmd = []
        else:
            cmd = ['urxvt', '-fn', 'xft:Consolas-8', '-T', 'Slimv', '-e']
        cmd = cmd + [python_path, slimv_path, '-p', str(PORT), '-l', lisp_path, '-s']
    else:
        cmd = shlex.split(run_cmd)

    # Start server
    #TODO: put in try-block
    if mswindows:
        CREATE_NEW_CONSOLE = 16
        server = Popen( cmd, creationflags=CREATE_NEW_CONSOLE )
    elif darwin:
        from ScriptingBridge import SBApplication

        term = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
        term.doScript_in_(" ".join(cmd) + " ; exit", 0) 
    else:
        server = Popen( cmd )

    # Allow subprocess (server) to start
    time.sleep( 2.0 )
开发者ID:de-bug,项目名称:dotfiles,代码行数:28,代码来源:slimv.py

示例4: application_openFile_

 def application_openFile_(self, ns_app, path):
     terminal = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
     tab = terminal.doScript_in_("clear; %s; exit 0;" % (YAYBUC,), None)
     tab.setCustomTitle_(CUSTOM_WINDOW_TITLE )
     tab.setTitleDisplaysCustomTitle_(True)
     tab.setTitleDisplaysDeviceName_(False)
     tab.setTitleDisplaysFileName_(False)
     tab.setTitleDisplaysShellPath_(False)
     tab.setTitleDisplaysWindowSize_(False)
开发者ID:yaybu,项目名称:Yaybu.app,代码行数:9,代码来源:Application.py

示例5: _activate_window

def _activate_window():
    if sublime.platform() == 'osx':
        if SBApplication:
            subl_window = SBApplication.applicationWithBundleIdentifier_("com.sublimetext.2")
            subl_window.activate()
        else:
            os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Sublime Text" to true' ''')
    elif sublime.platform() == 'linux':
        subprocess.call("wmctrl -xa 'sublime_text.sublime-text-2'", shell=True)
开发者ID:trukanduk,项目名称:smate,代码行数:9,代码来源:smate.py

示例6: applicationOpenUntitledFile_

 def applicationOpenUntitledFile_(self, _):
     window, tab = find_best_yaybu_terminal()
     if window and tab:
         tab.setSelected_(True)
         window.setFrontmost_(True)
         term = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
         term.activate()
         return
     self.openYaybufile_(None)
开发者ID:yaybu,项目名称:Yaybu.app,代码行数:9,代码来源:Application.py

示例7: reload_safari

def reload_safari(keyword):
    safari = SBApplication.applicationWithBundleIdentifier_("com.apple.Safari")
    if not safari:
        print("Safari doesn't appear to be running!")
        return
    for window in safari.windows():
        for tab in window.tabs():
            if keyword in tab.URL():
                print("Reloading Safari: {}".format(tab.URL()))
                tab.setURL_(tab.URL())
开发者ID:davea,项目名称:watch,代码行数:10,代码来源:watch.py

示例8: reload_chrome

def reload_chrome(keyword):
    chrome = SBApplication.applicationWithBundleIdentifier_("com.google.Chrome")
    if not chrome:
        print("Chrome doesn't appear to be running!")
        return
    for window in chrome.windows():
        for tab in window.tabs():
            if keyword in tab.URL():
                print("Reloading Chrome: {}".format(tab.URL()))
                tab.reload()
开发者ID:davea,项目名称:watch,代码行数:10,代码来源:watch.py

示例9: on_done

    def on_done(self):
        # Create a secure temporary directory, both for privacy and to allow
        # multiple files with the same basename to be edited at once without
        # overwriting each other.
        try:
            self.temp_dir = tempfile.mkdtemp(prefix='rsub-')
        except OSError as e:
            sublime.error_message('Failed to create rsub temporary directory! Error: %s' % e)
            return
        self.temp_path = os.path.join(self.temp_dir,
                                      os.path.basename(self.env['display-name'].split(':')[-1]))
        try:
            temp_file = open(self.temp_path, "wb+")
            temp_file.write(self.file[:self.file_size])
            temp_file.flush()
            temp_file.close()
        except IOError as e:
            # Remove the file if it exists.
            if os.path.exists(self.temp_path):
                os.remove(self.temp_path)
            try:
                os.rmdir(self.temp_dir)
            except OSError:
                pass

            sublime.error_message('Failed to write to temp file! Error: %s' % str(e))

        # create new window if needed
        if len(sublime.windows()) == 0 or "new" in self.env:
            sublime.run_command("new_window")

        # Open it within sublime
        view = sublime.active_window().open_file(
            "{0}:{1}:0".format(
                self.temp_path, self.env['selection'] if 'selection' in self.env else 0),
            sublime.ENCODED_POSITION)

        # Add the file metadata to the view's settings
        # This is mostly useful to obtain the path of this file on the server
        view.settings().set('rsub', self.env)

        # Add the session to the global list
        SESSIONS[view.id()] = self

        # Bring sublime to front
        if(sublime.platform() == 'osx'):
            if(SBApplication):
                subl_window = SBApplication.applicationWithBundleIdentifier_("com.sublimetext.2")
                subl_window.activate()
            else:
                os.system("/usr/bin/osascript -e '%s'" %
                          'tell app "Finder" to set frontmost of process "Sublime Text" to true')
        elif(sublime.platform() == 'linux'):
            import subprocess
            subprocess.call("wmctrl -xa 'sublime_text.sublime-text-2'", shell=True)
开发者ID:aurora,项目名称:rsub,代码行数:55,代码来源:rsub.py

示例10: openTerminal_

 def openTerminal_(self, sender):
     """ Open a Terminal.app window running bpython,
         with the PlotDevice.app environment pre-loaded """
     TerminalApp = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
     scriptPythonPath = ":".join(sys.path)
     scriptBPythonExecutable = bundle_path(shared='bplotdevice')
     scriptBPythonSetup = bundle_path(rsrc='plotdevice-term.py')
     scriptCommand = '''cd %s && PYTHONPATH="%s" %s -i %s && exit''' % (
         bundle_path(), scriptPythonPath, scriptBPythonExecutable, scriptBPythonSetup)
     TerminalApp.activate()
     TerminalApp.doScript_in_(scriptCommand, None)
开发者ID:fish2000,项目名称:plotdevice,代码行数:11,代码来源:app.py

示例11: bring_to_front

def bring_to_front():
    global WINDOW_HANDLE
    if(sublime.platform() == 'osx'):
        if(SBApplication):
            subl_window = SBApplication.applicationWithBundleIdentifier_("com.sublimetext.2")
            subl_window.activate()
        else:
            os.system("/usr/bin/osascript -e '%s'" %
                      'tell app "Finder" to set frontmost of process "Sublime Text" to true')
    elif(sublime.platform() == 'linux'):
        import subprocess
        subprocess.call("wmctrl -xa '%s'" % WINDOW_HANDLE, shell=True)
开发者ID:KES777,项目名称:rsub,代码行数:12,代码来源:rsub.py

示例12: get_display_profile_path

def get_display_profile_path():
    if not hasattr(get_display_profile_path, 'profile_path'):
        import objc
        from ScriptingBridge import SBApplication
        ImageEvents = SBApplication.applicationWithBundleIdentifier_('com.apple.ImageEvents')
        #ImageEvents.activate()
        displays = ImageEvents.displays()
        if len(displays) < 1:
            get_display_profile_path.profile_path = None
        get_display_profile_path.profile_path = displays[0].displayProfile().location().properties()['POSIXPath']
        ImageEvents.quitSaving_(objc.NO)
    return get_display_profile_path.profile_path
开发者ID:fish2000,项目名称:plotdevice,代码行数:12,代码来源:__init__.py

示例13: __init__

 def __init__(self):
     if sys.platform == "win32":
         # import win32com.client
         # c = win32com.client.gencache.EnsureDispatch("iTunes.Application")
         raise NotImplementedError("Sorry, there's no Windows support yet.")
     elif sys.platform == "darwin": # OS X
         # Get a reference to the client without launching it.
         # Spotify will launch automatically when called.
         self.client = SBApplication.alloc().initWithBundleIdentifier_("com.spotify.client")
     else:
         raise NotImplementedError("Sorry, your platform is not supported yet.")
     self.status_updater = None
开发者ID:KoreanFoodComics,项目名称:sublime-spotify,代码行数:12,代码来源:spotify_player.py

示例14: enableshortcuts

 def enableshortcuts(self):
     self.apply()
     # popup System Preferences dialog
     try:
         # http://stackoverflow.com/questions/6652598/cocoa-button-opens-a-system-preference-page/6658201
         from ScriptingBridge import SBApplication
         sysprefs = 'com.apple.systempreferences'
         prefs = SBApplication.applicationWithBundleIdentifier_(sysprefs)
         pane = [x for x in prefs.panes() if x.id() == 'com.apple.preference.security'][0]
         prefs.setCurrentPane_(pane)
         anchor = [x for x in pane.anchors() if x.name() == 'Privacy_Accessibility'][0]
         anchor.reveal()
         prefs.activate()
     except:
         AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})
     self.parent.event_generate('<<Quit>>', when="tail")
开发者ID:Marginal,项目名称:EDMarketConnector,代码行数:16,代码来源:prefs.py

示例15: POST

 def POST(self):
     
     iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
     track = iTunes.currentTrack()
     
     i = web.input(submit = None)
     
     if i.submit == "play":
         iTunes.playpause()
     elif i.submit == "next":
         iTunes.nextTrack()
     elif i.submit == "prev":
         iTunes.previousTrack()
     
     web.header('Content-Type','text/html; charset=utf-8') 
     return render.nowplaying(track=track, iTunes=iTunes, len=len)
开发者ID:vinc3m1,项目名称:nowplaying,代码行数:16,代码来源:code.py


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