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


Python webbrowser.open方法代码示例

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


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

示例1: run

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def run(port=None):
    import webbrowser, threading

    if port is None:
        port = getRandomPort()

    # load()
    url = "http://127.0.0.1:{}/".format(port)
    logging.info("Starting browser at {}".format(url))
    # webbrowser.open_new(url)

    threading.Timer(1.25, lambda: webbrowser.open(url) ).start()

    app.run(
        port=port#,
        # debug=True
    ) 
开发者ID:svviz,项目名称:svviz,代码行数:19,代码来源:web.py

示例2: __init__

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def __init__(self, master=None):
        tk.Frame.__init__(self, master)
        self.master = master
        self.init_window()
        
        self.about_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/LPHK-banner.png"))
        self.info_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/info.png"))
        self.warning_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/warning.png"))
        self.error_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/error.png"))
        self.alert_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/alert.png"))
        self.scare_image = ImageTk.PhotoImage(Image.open(PATH + "/resources/scare.png"))
        self.grid_drawn = False
        self.grid_rects = [[None for y in range(9)] for x in range(9)]
        self.button_mode = "edit"
        self.last_clicked = None
        self.outline_box = None 
开发者ID:nimaid,项目名称:LPHK,代码行数:18,代码来源:window.py

示例3: show_module

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def show_module(self, modId):
        """Show a given module inside a web browser

        :param str modId: a valid module Id. See :meth:`moduleIds`

        Validity of modId is not checked but if wrong the URL will not open a
        proper web page.
        """
        if modId.startswith("md:"):
            modId = modId.split(":")[1]
        url = "http://www.kegg.jp/module/" + modId
        self.logging.info(url)
        res = webbrowser.open(url)
        return res

    # wrapper of all databases to ease access to them (buffered) 
开发者ID:cokelaer,项目名称:bioservices,代码行数:18,代码来源:kegg.py

示例4: headless_authorize

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def headless_authorize(self):
        """
        Authorize without a display using only TTY.
        """
        url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
        # Ask the user to open this url on a system with browser
        print('\n-------------------------------------------------------------------------')
        print('\t\tOpen the below URL in your browser\n')
        print(url)
        print('\n-------------------------------------------------------------------------\n')
        print('NOTE: After authenticating on Fitbit website, you will redirected to a URL which ')
        print('throws an ERROR. This is expected! Just copy the full redirected here.\n')
        redirected_url = input('Full redirected URL: ')
        params = urlparse.parse_qs(urlparse.urlparse(redirected_url).query)
        print(params['code'][0])
        self.authenticate_code(code=params['code'][0]) 
开发者ID:praveendath92,项目名称:fitbit-googlefit,代码行数:18,代码来源:auth_fitbit.py

示例5: main

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def main():
    # Arguments parsing
    parser = argparse.ArgumentParser("Client ID and Secret are mandatory arguments")
    parser.add_argument("-i", "--id", required=True, help="Client id", metavar='<client-id>')
    parser.add_argument("-s", "--secret", required=True, help="Client secret", 
        metavar='<client-secret>')
    parser.add_argument("-c", "--console", default=False, 
        help="Authenticate only using console (for headless systems)", action="store_true")
    args = parser.parse_args()

    server = OAuth2Server(args.id, args.secret)
    if args.console:
        server.headless_authorize()
    else:   
        server.browser_authorize()

    credentials = dict(
        client_id=args.id,
        client_secret=args.secret,
        access_token=server.oauth.token['access_token'],
        refresh_token=server.oauth.token['refresh_token'])
    json.dump(credentials, open('fitbit.json', 'w')) 
开发者ID:praveendath92,项目名称:fitbit-googlefit,代码行数:24,代码来源:auth_fitbit.py

示例6: collision_series

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def collision_series(paperback=True, kindle=True):
    import webbrowser
    import imp
    if paperback:    
        webbrowser.open("https://www.createspace.com/6043857")
        imp.reload(webbrowser)
        webbrowser.open("https://www.createspace.com/7164863")
        return
    if kindle:
        webbrowser.open("https://www.amazon.com/Resolve-Immortal-Flesh-Collision-Book-ebook/dp/B01CO3MBVQ")
        imp.reload(webbrowser)
        webbrowser.open("https://www.amazon.com/Formulacrum-Collision-Book-Rich-Colburn-ebook/dp/B0711P744G")
        return
    webbrowser.open("https://www.paypal.com/donate/?token=G1UymFn4CP8lSFn1r63jf_XOHAuSBfQJWFj9xjW9kWCScqkfYUCdTzP-ywiHIxHxYe7uJW&country.x=US&locale.x=US")

# ============================================================================================ 
开发者ID:the3dadvantage,项目名称:Modeling-Cloth,代码行数:18,代码来源:ModelingCloth.py

示例7: main

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def main():
    print('====== Menu ======')
    print('1. Play')
    print('2. See Source Code')
    print('3. Rules')
    print('4. Rules dictation by Sheldon Lee Cooper')
    print('5. Exit')
    inp = int(input('Enter Choice :'))
    if inp is 1:
        rpsls()
    elif inp is 3:
        rules()
    elif inp is 4:
        webbrowser.open('https://goo.gl/kR2653')
    elif inp is 5:
        exit()
    elif inp is 2:
        webbrowser.open('https://goo.gl/4TStoZ')
    if inp is not 5:
        main() 
开发者ID:aashutoshrathi,项目名称:Python-Scripts-and-Games,代码行数:22,代码来源:RPSLS.py

示例8: importfile

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def importfile(path):
    """Import a Python source file or compiled file given its path."""
    magic = imp.get_magic()
    with open(path, 'rb') as file:
        if file.read(len(magic)) == magic:
            kind = imp.PY_COMPILED
        else:
            kind = imp.PY_SOURCE
        file.seek(0)
        filename = os.path.basename(path)
        name, ext = os.path.splitext(filename)
        try:
            module = imp.load_module(name, file, path, (ext, 'r', kind))
        except:
            raise ErrorDuringImport(path, sys.exc_info())
    return module 
开发者ID:war-and-code,项目名称:jawfish,代码行数:18,代码来源:pydoc.py

示例9: open_in_browser

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def open_in_browser(url_or_message):
        if isinstance(url_or_message, str):
            url = url_or_message
        elif hasattr(url_or_message, 'linkInfo'):
            url = url_or_message.linkInfo['linkUrl']
        elif 'linkInfo' in url_or_message:
            url = url_or_message['linkInfo']['linkUrl']
        elif hasattr(url_or_message, 'content'):
            urls = extract_url(url_or_message.content)
            if urls:
                for url in urls:
                    webbrowser.open(url)
                return
        else:
            raise ValueError('No url found')

        if not URL_VALIDATION_PATTERN.match(url):
            raise ValueError('Url invalid')
        else:
            webbrowser.open(url) 
开发者ID:Sorosliu1029,项目名称:Jike-Metro,代码行数:22,代码来源:client.py

示例10: launch

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def launch(self, outputFilename, templateFilename=DefaultTemplate, port='auto'):
        '''
        Save and then launch this notebook

        Parameters
        ----------
        outputFilename : str
            filename to save this notebook to
        templateFilename : str, optional
            filename to build this notebook from (see save_to)
        '''
        self.save_to(outputFilename, templateFilename)
        outputFilename = _os.path.abspath(outputFilename)  # for path manips below

        from notebook import notebookapp
        servers = list(notebookapp.list_running_servers())
        for serverinfo in servers:
            rel = _os.path.relpath(outputFilename, serverinfo['notebook_dir'])
            if ".." not in rel:  # notebook servers don't allow moving up directories
                if port == 'auto' or int(serverinfo['port']) == port:
                    url = _os.path.join(serverinfo['url'], 'notebooks', rel)
                    _browser.open(url); break
        else:
            print("No running notebook server found that is rooted above %s" %
                  outputFilename) 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:27,代码来源:notebook.py

示例11: run_mpi_coverage_tests

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def run_mpi_coverage_tests(coverage_cmd, nproc=4):
    shutil.copy('mpi/setup.cfg.mpi', 'setup.cfg')

    #OLD: worked with python2.7, but not with 3 (where .coverage files turned to JSON)
    #mpicommands = ('time mpiexec -np %s python%s mpi/runtests.py -v ' % (str(nproc), '' if version is None else version)+
    #               '--with-coverage --cover-package=pygsti --cover-erase mpi/testmpi*.py  ' +
    #               '> ../output/coverage_tests_mpi.out 2>&1')

    mpicommands = ('time mpiexec -np %s %s run -p ' % (str(nproc), coverage_cmd) +
                   '--source=pygsti mpi/runtests.py -v mpi/testmpi*.py ' +
                   '> ../output/coverage_tests_mpi.out 2>&1')

    with open('../output/mpi_output.txt', 'w') as output:
        returned = subprocess.call(mpicommands, shell=True, stdout=output, stderr=output)
    with open('../output/mpi_output.txt', 'r') as output:
        print(output.read())
    os.remove('setup.cfg')
    return returned 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:20,代码来源:runTests.py

示例12: install

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def install(self, url, target_folder):

        tmp_zipfile = self.download(url)
        base_dir = os.path.splitext(os.path.basename(tmp_zipfile))[0] + '/'
        with open(tmp_zipfile, 'rb') as ins:
            zipfp = zipfile.ZipFile(ins)
            for name in zipfp.namelist():
                data = zipfp.read(name)
                name = name.split(base_dir, 1)[-1]  # strip the top-level target_folder
                if name == '':  # skip top-level target_folder
                    continue

                fname = os.path.join(target_folder, name)
                if fname.endswith('/'):  # A target_folder
                    if not os.path.exists(fname):
                        os.makedirs(fname)
                else:
                    with open(fname, 'wb') as fp:
                        fp.write(data) 
开发者ID:ywangd,项目名称:pythonista-tools-installer,代码行数:21,代码来源:ptinstaller.py

示例13: call_after

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def call_after(self, *args):
        if config.make_font_cache_on_start:
            font_cache_update()
        if self.docs:
            return
        docs = self._get_docs()
        if config.new_doc_on_start and not docs:
            self.load_plugins()
            self.new()
        else:
            txt = _('To start, create new document or open existing')
            events.emit(events.APP_STATUS, txt)
            self.load_plugins()
            if not wal.IS_WX2:
                events.emit(events.NO_DOCS)
        self.update_actions()
        for item in docs:
            self.open(item) 
开发者ID:sk1project,项目名称:sk1-wx,代码行数:20,代码来源:application.py

示例14: display

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def display():
    req = request.args.get('req', 0)

    if req == "progress":
        return jsonify(result="done")

    if req in ["alt", "ref", "amb"]:
        allele = req
        results = []
        for name, sample in dataHub.samples.items():
            # svg = open("{}.{}.svg".format(req, name)).read()
            track = sample.tracks[allele]
            track.render()
            svg = track.svg.asString("web")
            results.append({"name":name, "svg":svg})

        for annotation in dataHub.alleleTracks[allele]:
            track = dataHub.alleleTracks[allele][annotation]
            track.render(spacing=5)
            annoSVG = track.svg.asString("web")
            results.append({"name":annotation, "svg":annoSVG})

        return jsonify(results=results)


    if req == "counts":
        return jsonify(result=dataHub.getCounts())

    return jsonify(result="unknown request: {}".format(req)) 
开发者ID:svviz,项目名称:svviz,代码行数:31,代码来源:web.py

示例15: __call__

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open [as 别名]
def __call__(self, args, env):
        _AI, topic = args
        topic = " ".join(topic)
        if topic == "tutorial":
            if webbrowser.open(_TUTORIAL_URL, new=2):
                print("Opened {} in a new browser tab.".format(_TUTORIAL_URL))
            else:
                print("Could not access the web browser. Please use this URL to access the tutorial:")
                print(_TUTORIAL_URL)
        else:
            print(self.get_help(env, topic)) 
开发者ID:mme,项目名称:vergeml,代码行数:13,代码来源:help.py


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