def make_box_for_grid(image_widget, title, size=(250, 250)): """ Make a VBox to hold caption/image for demonstrating option_fit values. """ modes = ['oblique', 'X', 'Y', 'Z'] # make layout box_layout = Layout() box_layout.width = f'{size[0]}px' box_layout.height = f'{size[1]}px' box_layout.border = '0px' # Make the caption if title is not None: title_str = "'{}'".format(title) else: title_str = str(title) h = HTML(value='' + str(title_str) + '') # Make the box with the image widget inside it boxb = Box() boxb.layout = box_layout boxb.children = [image_widget] # Compose into a vertical box vb = VBox() vb.layout.align_items = 'center' vb.children = [h, boxb] return vb
def _online_notebook_login(username, passwd): import requests import json from ipywidgets import HTML, Layout if username is not None and passwd is not None: SSO_URL = 'https://sso.supermap.com/login' params = {'format': 'json'} params.update({'service': 'https://www.supermapol.com/shiro-cas'}) session = requests.session() lt_res = session.get(SSO_URL, params=params, allow_redirects=False) params.update(json.loads(lt_res.content)) params.update({"username": username, "password": passwd}) ticket_res = session.post(SSO_URL, params=params, allow_redirects=False) if ticket_res.status_code != 302: raise Exception("登录失败,请确保用户名和密码输入正确") url = ticket_res.headers["location"] layout = Layout() layout.visibility = 'hidden' layout.width = '0px' layout.height = '0px' return HTML(value='<iframe src="' + url + '">', layout=layout)