• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python webbrowser.open_new_tab函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: serve_markdown_on_some_available_port

def serve_markdown_on_some_available_port(cfg,first_file_url):

    # try opening on a bunch of ports until we find one that is available
    attempt = 0
    while True:
        try:
            port = int(cfg.port) if (cfg.port is not None) else random.randint(5000,9999)
            server_address = ('127.0.0.1', port)

            httpd = http_md_server(cfg, server_address, http_md_handler)
        except:
            attempt += 1
            if attempt == 1000:
                raise
        else:
            break

    sa = httpd.socket.getsockname()
    print "Serving HTTP on", sa[0], "port", sa[1], "..."
    #httpd.serve_forever()
    cfg.tickle_time = time.time()
    threading.Thread(target=httpd.serve_forever).start()

    webbrowser.open_new_tab( "http://%s:%d/%s" % (server_address[0],server_address[1],first_file_url) )

    return httpd
开发者ID:BrentNoorda,项目名称:trivial_markdown_server,代码行数:26,代码来源:mdview.py


示例2: search_bare_weblink_and_open

    def search_bare_weblink_and_open(self, start, end):
        # expand selection to nearest stopSymbols
        view_size = self.view.size()
        stopSymbols = ['\t', ' ', '\"', '\'', '>', '<', ',']
        # move the selection back to the start of the url
        while (start > 0
                and not self.view.substr(start - 1) in stopSymbols
                and self.view.classify(start) & sublime.CLASS_LINE_START == 0):
            start -= 1

        # move end of selection forward to the end of the url
        while (end < view_size
                and not self.view.substr(end) in stopSymbols
                and self.view.classify(end) & sublime.CLASS_LINE_END == 0):
            end += 1

        # grab the URL
        url = self.view.substr(sublime.Region(start, end))
        # optional select URL
        self.view.sel().add(sublime.Region(start, end))

        exp = re.search(self.URL_REGEX, url, re.X)
        if exp and exp.group(0):
            strUrl = exp.group(0)
            if strUrl.find("://") == -1:
                strUrl = "http://" + strUrl
            webbrowser.open_new_tab(strUrl)
        else:
            sublime.status_message("Looks like there is nothing to open")
开发者ID:chenmo1996,项目名称:sublimeBackups,代码行数:29,代码来源:PlainTasks.py


示例3: openBrowser

def openBrowser():
    path = conf.OUTPUT_FILE_PATH
    try:
        webbrowser.open_new_tab(path)
    except Exception:
        errMsg = '\n[ERROR] Fail to open file with web browser: %s' % path
        raise ToolkitSystemException(errMsg)
开发者ID:PurpleHua,项目名称:POC-T,代码行数:7,代码来源:common.py


示例4: test_draw_html

	def test_draw_html(self):
		with tempfile.NamedTemporaryFile(suffix='.html') as f:
			f.write(webhive.build_string())  
			f.flush()
			print f.name
			webbrowser.open_new_tab('file://'+f.name)
			time.sleep(100)	
开发者ID:madelynfreed,项目名称:hive,代码行数:7,代码来源:test_web.py


示例5: __plot_points_on_map

    def __plot_points_on_map(self, locations, is_locations=True):
        if is_locations:
            points = self.__convert_locations_to_points(locations)
        else:
            points = locations
        zoom_level = 16
        p_count = len(points)
        center = points[int(p_count / 2)]
        mymap = pygmaps.pygmaps.maps(center[0], center[1], zoom_level)

        # mymap.setgrids(37.42, 37.43, 0.001, -122.15, -122.14, 0.001)
        # mymap.addradpoint(37.429, -122.145, 95, "#FF0000")

        # create range of colors for the points
        hex_colors = []
        for val in range(1, p_count + 1):
            col = self.__pseudo_color(val, 0, p_count)
            hex_colors.append(self.__rgb_to_hex(col))

        # draw marks at the points
        p_count = 0
        for pnt, col in zip(points, hex_colors):
            p_count += 1
            mymap.addpoint(pnt[0], pnt[1], col, title=str(p_count))

        # draw path using the points then show the map
        path_color = "#0A6491"
        mymap.addpath(points, path_color)
        mymap.draw('mymap.draw.html')
        url = 'mymap.draw.html'
        webbrowser.open_new_tab(url)
开发者ID:noureldien,项目名称:TrafficSignRecognition,代码行数:31,代码来源:stview.py


示例6: do_open

def do_open(args, _):
  """usage: open cluster[/role[/env/job]]

  Opens the scheduler page for a cluster, role or job in the default web browser.
  """
  cluster_name = role = env = job = None
  args = args[0].split("/")
  if len(args) > 0:
    cluster_name = args[0]
    if len(args) > 1:
      role = args[1]
      if len(args) > 2:
        env = args[2]
        if len(args) > 3:
          job = args[3]
        else:
          # TODO(ksweeney): Remove this after MESOS-2945 is completed.
          die('env scheduler pages are not yet implemented, please specify job')

  if not cluster_name:
    die('cluster is required')

  api = make_client(cluster_name)

  import webbrowser
  webbrowser.open_new_tab(
      synthesize_url(api.scheduler_proxy.scheduler_client().url, role, env, job))
开发者ID:sumanau7,项目名称:incubator-aurora,代码行数:27,代码来源:core.py


示例7: check_update

 def check_update(self):  # 强制更新
     u"""
         *   功能
             *   检测更新。
             *   若在服务器端检测到新版本,自动打开浏览器进入新版下载页面
             *   网页请求超时或者版本号正确都将自动跳过
         *   输入
             *   无
         *   返回
             *   无
     """
     print   u"检查更新。。。"
     try:
         updateTime = urllib2.urlopen(u"http://zhihuhelpbyyzy-zhihu.stor.sinaapp.com/ZhihuHelpUpdateTime.txt",
                                      timeout=10)
     except:
         return
     time = updateTime.readline().replace(u'\n', '').replace(u'\r', '')
     url = updateTime.readline().replace(u'\n', '').replace(u'\r', '')
     updateComment = updateTime.read()
     if time == SettingClass.UPDATETIME:
         return
     else:
         print u"发现新版本,\n更新说明:{}\n更新日期:{} ,点按回车进入更新页面".format(updateComment, time)
         print u'新版本下载地址:' + url
         raw_input()
         import webbrowser
         webbrowser.open_new_tab(url)
     return
开发者ID:Celthi,项目名称:ZhihuHelp__Python,代码行数:29,代码来源:main.py


示例8: main

def main():        
    parser = argparse.ArgumentParser(description='Download videos\
    from various video hosting sites\
    (youtube, vimeo, bliptv, dailymotion,...)')
    parser.add_argument("-cli",
                        help="Download link on the command line instead\
                        of opening link in the system's default browser ",
                        action='store_true')
    parser.add_argument("url",
                       help="The url of the file you wish to download")

    args = parser.parse_args()                         
    links = get_download_links(args.url)

    if links is not None:
        
        print "Choose File you wish to Download"    
        for i, link in enumerate(links):
            print "[%d] : %s" % (i, link[1])        

        chosen_link = int(raw_input('> '))

        if args.cli:
            download_video(links[chosen_link][0])    
        else:
            open_new_tab(links[chosen_link][0])                            
    else:
        print "Service unavailable please try again"
开发者ID:twinsant,项目名称:savevideo,代码行数:28,代码来源:savevideo.py


示例9: show_shortcuts

def show_shortcuts():
    hotkeys_html = resources.doc(N_('hotkeys.html'))
    try:
        from qtpy import QtWebEngineWidgets
    except (ImportError, qtpy.PythonQtError):
        # redhat disabled QtWebKit in their qt build but don't punish the users
        webbrowser.open_new_tab('file://' + hotkeys_html)
        return

    html = core.read(hotkeys_html)

    parent = qtutils.active_window()
    widget = QtWidgets.QDialog()
    widget.setWindowModality(Qt.WindowModal)
    widget.setWindowTitle(N_('Shortcuts'))

    web = QtWebEngineWidgets.QWebEngineView(parent)
    web.setHtml(html)

    layout = qtutils.hbox(defs.no_margin, defs.spacing, web)
    widget.setLayout(layout)
    widget.resize(800, min(parent.height(), 600))
    qtutils.add_action(widget, N_('Close'), widget.accept,
                       hotkeys.QUESTION, *hotkeys.ACCEPT)
    widget.show()
    widget.exec_()
开发者ID:sirtaj,项目名称:git-cola,代码行数:26,代码来源:about.py


示例10: open_web_link

def open_web_link(url):
	if not url:
		return
	try:
		webbrowser.open_new_tab(url)
	except:
		log_e('Could not open URL in browser')
开发者ID:peaceandpizza,项目名称:happypanda,代码行数:7,代码来源:utils.py


示例11: success

def success():
	action = 'created' if new else 'updated'
	print '\nYour stream "{}" has been {}!'.format(stream['Title'], action)
	if goto:
		webbrowser.open_new_tab(playlist.permalink_url)
	print '\nThank you for using soundcloud-streams'
	raise SystemExit
开发者ID:ssalka,项目名称:soundcloud-streams,代码行数:7,代码来源:streams.py


示例12: create_html_for_cluster

def create_html_for_cluster(list_baskets, num_cluster):
    """Create a html with the Freesound embed"""
    # This list contains the begining and the end of the embed
    # Need to insert the id of the sound
    embed_blocks = ['<iframe frameborder="0" scrolling="no" src="https://www.freesound.org/embed/sound/iframe/', '/simple/medium/" width="481" height="86"></iframe>']

    # Create the html string
    message = """
    <html>
        <head></head>
        <body>
    """
    for idx, ids in enumerate(list_baskets[num_cluster].ids):
        message += embed_blocks[0] + str(ids) + embed_blocks[1]
        if idx > 50:
            break
    message += """
        </body>
    </html>
    """

    # Create the file
    f = open('result_cluster'+ str(num_cluster) +'.html', 'w')
    f.write(message)
    f.close()

    # Open it im the browser
    webbrowser.open_new_tab('result_cluster'+ str(num_cluster) +'.html')
开发者ID:xavierfav,项目名称:freesound-python,代码行数:28,代码来源:script_clustering_igraph.py


示例13: preview

 def preview(self):
   """Preview the reponse in your browser.
   """
   fd, fname = tempfile.mkstemp()
   with os.fdopen(fd, 'w') as f:
     f.write(self.content)
   webbrowser.open_new_tab(fname)
开发者ID:RahulPande90,项目名称:burst,代码行数:7,代码来源:http.py


示例14: execute

  def execute(self):
    response = utilities.call_srclib(self.view, self.view.sel()[0],
      ['--no-examples'])

    if 'Def' not in response:
      utilities.StatusTimeout(self.view, 'definition not found')
      return

    definition = response['Def']

    if 'Repo' in definition:
      # TODO: Resolve to local file - waiting for Src API to expose method for this
      url = utilities.BASE_URL + "/%s/.%s/%s/.def/%s" % (definition['Repo'],
          definition['UnitType'], definition['Unit'], definition['Path'])
      webbrowser.open_new_tab(url)
      utilities.StatusTimeout(self.view, 'definition is opened in browser')
      return

    file_path = definition['File']
    if not os.path.isfile(file_path):
      utilities.StatusTimeout(self.view, 'definition found but file %s does ' +
        'not exist.' % file_path)
      return

    view = self.view.window().open_file(file_path)
    sublime.set_timeout(lambda: utilities.show_location(view,
      definition['DefStart'], definition['DefEnd']), 10)

    utilities.StatusTimeout(self.view, 'definition found')
开发者ID:dinfekted,项目名称:sourcegraph-sublime,代码行数:29,代码来源:commands.py


示例15: run

def run(t):
    while(True):
        # response = requests.get(URL)
        # response.encoding = 'gb2312'
        # text = response.text[1:-1]
        # test = json.loads(text)

        html = urllib2.urlopen(Json_URL)

        context = json.loads(html.read())
        tag = False

        for store in context.keys():
            if store != "updated":
                for model in context[store].keys():
                    # print util.getStore(store)+util.getMode(model)

                    if context[store][model] == True:
                        tag = True
                        print store+''+model
                        print util.getStore(store)+' '+util.getMode(model)
                        webbrowser.open_new_tab(Output_URL)
                        message.send_mail(mail_list,"iphone",util.getStore(store)+' '+util.getMode(model))
        if tag:
            time.sleep(120)
        time.sleep(float(t))
开发者ID:vincentnifang,项目名称:iPhone6Check,代码行数:26,代码来源:main.py


示例16: save_list

def save_list():
    f = open('index.html','w')
    text = source.get()
    message = "<html><head></head><body><p>%s</p></body></html>" % text
    f.write(message)
    f.close()
    webbrowser.open_new_tab('index.html')
开发者ID:SMaguina,项目名称:Python-GUI-Apps,代码行数:7,代码来源:htmlgeneratorproject_py2.py


示例17: serve

def serve(port):
    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    httpd = SocketServer.TCPServer(('', port), Handler)
    print('Serving on port: {0}'.format(port))
    webbrowser.open_new_tab('http://localhost:{0}/'
                            'output/classify.html'.format(port))
    httpd.serve_forever()
开发者ID:fastturtle,项目名称:classify,代码行数:7,代码来源:main.py


示例18: main

def main():
    """Run the app."""
    # NOTE(jk0): Disable unnecessary requests logging.
    requests.packages.urllib3.disable_warnings()

    endpoint = os.environ.get("PASTE_ENDPOINT")

    parser = argparse.ArgumentParser(version=__VERSION__)
    parser.add_argument("-f", "--file", help="upload a file")
    #parser.add_argument("-k", "--key", help="encrypt the pastee with a key")
    #parser.add_argument("-l", "--lexer", default="text",
    #                    help="use a particular lexer (default: text)")
    #parser.add_argument("-t", "--ttl", default=30,
    #                    help="days before paste expires (default: 30)")

    parsed_args = parser.parse_args()

    if parsed_args.file:
        with open(parsed_args.file, "r") as fp:
            paste = fp.read()
    else:
        paste = sys.stdin.read()

    #paste = PasteeClient(endpoint).create(
    #    paste,
    #    key=parsed_args.key,
    #    lexer=parsed_args.lexer,
    #    ttl=parsed_args.ttl)
    paste = PyholeClient(endpoint).create(paste)

    webbrowser.open_new_tab(paste.url)
开发者ID:gvsurenderreddy,项目名称:pastee-client,代码行数:31,代码来源:pastee.py


示例19: on_hover_navigate

 def on_hover_navigate(self, href):
     if href == "#enable_globally":
         self.window.run_command("code_intel_enable_language_server_globally")
     elif href == "#enable_project":
         self.window.run_command("code_intel_enable_language_server_in_project")
     else:
         webbrowser.open_new_tab(href)
开发者ID:Kronuz,项目名称:SublimeCodeIntel,代码行数:7,代码来源:configuration.py


示例20: openInBrowserTab

def openInBrowserTab(url):
    if sys.platform[:3] in ("win", "dar"):
        webbrowser.open_new_tab(url)
    else:
        # some Linux OS pause execution on webbrowser open, so background it
        cmd = "import webbrowser;" 'webbrowser.open_new_tab("{0}")'.format(url)
        subprocess.Popen([sys.executable, "-c", cmd], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
开发者ID:EmilyHueni,项目名称:Quantum-GIS,代码行数:7,代码来源:utilities.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python webbrowser.register函数代码示例发布时间:2022-05-26
下一篇:
Python webbrowser.open_new函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap