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 show_movies(name=''): modes = ['oblique', 'X', 'Y', 'Z'] # define layout hbox_layout = Layout() hbox_layout.width = '100%' #hbox_layout.justify_content = 'space-around' # Use this margin to eliminate space between the image and the box image_margin = '0 0 0 0' # Set size of captions in figures below caption_size = 'h4' # open GIF files boxes = [] for mode in modes: ib = open_image(filename=f'{name}{mode}.gif') ib.layout.object_fit = 'contain' ib.layout.margin = image_margin boxes.append(make_box_for_grid(ib, title=mode)) # generate widgets vb = HBox() vb.layout.align_items = 'center' hb = HBox() hb.layout = hbox_layout hb.children = boxes vb.children = [hb] 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)