本文整理汇总了Python中webbrowser.open_new_tab函数的典型用法代码示例。如果您正苦于以下问题:Python open_new_tab函数的具体用法?Python open_new_tab怎么用?Python open_new_tab使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了open_new_tab函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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")
示例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)
示例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)
示例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)
示例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))
示例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
示例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"
示例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_()
示例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')
示例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
示例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')
示例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)
示例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')
示例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))