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


Python webbrowser.open_new方法代码示例

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


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

示例1: run

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [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: run

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def run(self, unused_args, unused_config):
    """Generates and opens a URL to get auth code, then retrieve a token."""

    auth_url = ee.oauth.get_authorization_url()
    webbrowser.open_new(auth_url)

    print("""
    Opening web browser to address %s
    Please authorize access to your Earth Engine account, and paste
    the resulting code below.
    If the web browser does not start, please manually browse the URL above.
          """ % auth_url)

    auth_code = input('Please enter authorization code: ').strip()

    token = ee.oauth.request_token(auth_code)
    ee.oauth.write_token(token)
    print('\nSuccessfully saved authorization token.') 
开发者ID:mortcanty,项目名称:earthengine,代码行数:20,代码来源:commands.py

示例3: showbrowser

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def showbrowser(self):
        """
        Show this response in a browser window (for debugging purposes,
        when it's hard to read the HTML).
        """
        import webbrowser
        import tempfile
        f = tempfile.NamedTemporaryFile(prefix='webtest-page',
                                        suffix='.html')
        name = f.name
        f.close()
        f = open(name, 'w')
        if PY3:
            f.write(self.body.decode(self.charset or 'ascii', 'replace'))
        else:
            f.write(self.body)
        f.close()
        if name[0] != '/':  # pragma: no cover
            # windows ...
            url = 'file:///' + name
        else:
            url = 'file://' + name
        webbrowser.open_new(url) 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:25,代码来源:response.py

示例4: coverage_html

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def coverage_html():
    """ 将coverage结果放置到html中并自动打开浏览器 """
    output_dir = os.path.join(os.getcwd(), 'coverage_output')
    if os.path.exists(output_dir):
        shutil.rmtree(output_dir)
    os.mkdir(output_dir)

    now_str = time.strftime("%Y%m%d%H%M")
    html_result_path = os.path.join(output_dir, now_str)
    html_cmd = 'coverage html -d {path}'.format(path=html_result_path)
    for test_file_path in find_test_file_paths():
        coverage_cmd = "coverage run -a --source=risk_models,builtin_funcs {path}".format(
            path=test_file_path)
        os.system(coverage_cmd)
    os.system(html_cmd)
    os.remove(os.path.join(os.getcwd(), '.coverage'))
    webbrowser.open_new(
        'file:///{base_dir}/index.html'.format(base_dir=html_result_path)) 
开发者ID:momosecurity,项目名称:aswan,代码行数:20,代码来源:run_test.py

示例5: updateInfo

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def updateInfo (self) :
		if self.udInfo != [] :
			if self.udInfo['version'] != '' :
				version = str(self.udInfo['version'])
			else :
				version = str(self.app['ver']) + ' Build (' + str(self.app['build']) + ')'
			verlabel = tkinter.Label(self.frame, text = 'Version : ' + version, fg = '#ddd', bg="#444", font = ("Helvetica", "10"), anchor = 'center')
			verlabel.grid(row = 1, column = 1)

			self.information = tkinter.Text(self.frame, height = 8, width = 35, bd = 0, fg = '#ddd', bg="#222", highlightthickness = 1, highlightcolor="#111", highlightbackground = '#111', selectbackground = '#116cd6', font = ("Helvetica", "12"))
			self.information.grid(row = 2, column = 1, pady = 10)
			self.information.delete('0.0', 'end')
			self.information.insert('end', self.udInfo['msg'])

			btn = tkinter.Button(self.frame, text = 'Download', width = 10, fg = '#222', highlightbackground = '#444', command = lambda target = self.udInfo['dUrl'] : webbrowser.open_new(target))
			btn.grid(row = 3, column = 1)
		else :
			self.timer = self.frame.after(50, self.updateInfo) 
开发者ID:EvilCult,项目名称:moviecatcher,代码行数:20,代码来源:UpdateInfoView.py

示例6: showDlLink

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def showDlLink (self, link) :
		window = tkinter.Toplevel()
		window.title('下载链接')
		window.resizable(width = 'false', height = 'false')
		if self.Tools.isWin() :
			window.iconbitmap(self.Tools.getRes('biticon.ico'))

		topZone = tkinter.Frame(window, bd = 0, bg="#444")
		topZone.pack(expand = True, fill = 'both')

		textZone = tkinter.Text(topZone, height = 8, width = 50, bd = 10, bg="#444", fg = '#ddd', highlightthickness = 0, selectbackground = '#116cd6')
		textZone.grid(row = 0, column = 0, sticky = '')
		textZone.insert('insert', link)

		dlBtn = tkinter.Button(topZone, text = '下载', width = 10, fg = '#222', highlightbackground = '#444', command =  lambda url = link : webbrowser.open_new(url))
		dlBtn.grid(row = 1, column = 0, pady = 5) 
开发者ID:EvilCult,项目名称:moviecatcher,代码行数:18,代码来源:PlayerView.py

示例7: main

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Parse a random forest')
    parser.add_argument('--trees', dest='trees', help='Path to file holding the trees.', required=True)
    parser.add_argument('--columns', dest='columns', default=None,
                        help='Path to csv file holding column index and column name.')
    parser.add_argument('--output_path', dest='output_path', default='.',
                        help='Path to outputted files.')
    args = parser.parse_args()
    column_name_dict = {}
    if args.columns:
        column_name_dict = read_columns(args.columns)
    trees = read_trees(args.trees)
    tree_list = []
    for index, tree in enumerate(trees):
        tree_obj = Tree()
        tree_obj.create_tree(tree, column_name_dict)
        js_struct = tree_obj.get_js_struct(tree_obj.root)
        node_dict = {'tree': [js_struct], 'max_depth': tree_obj.max_depth, 'max_breadth': tree_obj.max_breadth}
        tree_list.append(node_dict)
    make_tree_viz(tree_list, args.output_path)
    webbrowser.open_new(os.path.join(args.output_path, 'home.html')) 
开发者ID:ChuckWoodraska,项目名称:EurekaTrees,代码行数:23,代码来源:eurekatrees.py

示例8: get_page

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def get_page(wiki, path, version=None, open=False,  # pylint: disable=redefined-builtin
             include_content=False, organization=None, project=None, detect=None):
    """Get the content of a page or open a page.
    :param wiki: Name or Id of the wiki.
    :type wiki: str
    :param path: Path of the wiki page.
    :type path: str
    :param version: Version (ETag) of the wiki page.
    :type version: str
    :param include_content: Include content of the page.
    :type include_content: str
    :param open: Open the wiki page in your web browser.
    :type open: bool
    """
    organization, project = resolve_instance_and_project(detect=detect,
                                                         organization=organization,
                                                         project=project)
    wiki_client = get_wiki_client(organization)
    page_object = wiki_client.get_page(
        wiki_identifier=wiki, project=project, path=path,
        recursion_level=None, version_descriptor=version,
        include_content=include_content)
    if open:
        webbrowser.open_new(url=page_object.page.remote_url)
    return page_object 
开发者ID:Azure,项目名称:azure-devops-cli-extension,代码行数:27,代码来源:wiki.py

示例9: __init__

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def __init__(self, argres):
        self.root_dir = argres.root_dir
        self.redis_dir = os.path.join(self.root_dir, 'redis')

        self.user_manager = None

        self.browser_redis = None

        self.default_user = argres.default_user

        self.browser_id = base64.b32encode(os.urandom(15)).decode('utf-8')

        self.dat_share_port = argres.dat_share_port
        self.behaviors_tarfile = argres.behaviors_tarfile

        super(WebrecorderRunner, self).__init__(argres, rec_port=0)

        if not argres.no_browser:
            import webbrowser
            webbrowser.open_new(os.environ['APP_HOST'] + '/') 
开发者ID:Rhizome-Conifer,项目名称:conifer,代码行数:22,代码来源:webrecorder_full.py

示例10: __menu

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def __menu (self) :
		menubar = Tkinter.Menu(self.master)

		fileMenu = Tkinter.Menu(menubar, tearoff = 0)
		fileMenu.add_command(label = "Config", command = self.__configPanel)
		fileMenu.add_command(label = "Close", command = self.master.quit)
		menubar.add_cascade(label = "File", menu = fileMenu)

		aboutMenu = Tkinter.Menu(menubar, tearoff = 0)
		aboutMenu.add_command(label = "Info", command = self.__showInfo)
		aboutMenu.add_command(label = "Check Update", command = self.__chkUpdate)
		menubar.add_cascade(label = "About", menu = aboutMenu)

		helpMenu = Tkinter.Menu(menubar, tearoff = 0)
		helpMenu.add_command(label = "GitHub", command = lambda target = self.gitUrl : webbrowser.open_new(target))
		helpMenu.add_command(label = "Release Notes", command = lambda target = self.appUrl : webbrowser.open_new(target))
		helpMenu.add_command(label = "Send Feedback", command = lambda target = self.feedUrl : webbrowser.open_new(target))
		menubar.add_cascade(label = "Help", menu = helpMenu)

		self.master.config(menu = menubar) 
开发者ID:EvilCult,项目名称:Video-Downloader,代码行数:22,代码来源:guiClass.py

示例11: get_image_link

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def get_image_link(self, parent_link, page):
        javascript_script = ''
        while javascript_script is '':
            javascript_script = self.get_data(self.general_formula % (parent_link, parent_link[2:-1], page),
                                              'http://www.dm5.com%s' % parent_link)
            if javascript_script is '':
                webbrowser.open_new('http://www.dm5.com%s' % parent_link)
                time.sleep(3)
        link = execjs.eval(javascript_script)[0]
        link_safe = self.unicodeToURL(link)
        return link_safe 
开发者ID:XIAZY,项目名称:DriveIt,代码行数:13,代码来源:sites.py

示例12: openBlendHelp

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def openBlendHelp(self):
        threading.Thread(target=lambda: webbrowser.open_new('https://easings.net')).start() 
开发者ID:RiotGames,项目名称:leaguedirector,代码行数:4,代码来源:sequencer.py

示例13: launch

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def launch(app):
    http_server = WSGIServer(('', app.config['XCESSIV_PORT']), app)
    webbrowser.open_new('http://localhost:' + str(app.config['XCESSIV_PORT']))
    http_server.serve_forever() 
开发者ID:reiinakano,项目名称:xcessiv,代码行数:6,代码来源:server.py

示例14: showbrowser

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def showbrowser(self):
        """
        Show this response in a browser window (for debugging purposes,
        when it's hard to read the HTML).
        """
        import webbrowser
        fn = tempnam_no_warning(None, 'paste-fixture') + '.html'
        f = open(fn, 'wb')
        f.write(self.body)
        f.close()
        url = 'file:' + fn.replace(os.sep, '/')
        webbrowser.open_new(url) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:14,代码来源:fixture.py

示例15: showpage

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import open_new [as 别名]
def showpage(path):
    """Helper function to open webpages"""
    try:
        import webbrowser
        webbrowser.open_new(os.path.abspath(path))
    except:
        traceback.print_exc() 
开发者ID:linuxscout,项目名称:mishkal,代码行数:9,代码来源:PySourceColor.py


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