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 test_widget_utils(): box = HBox() i0 = IntText() i0._ngl_name = 'i0' i1 = IntText() i1._ngl_name = 'i1' box.children = [i0, i1] assert i0 is widget_utils.get_widget_by_name(box, 'i0') assert i1 is widget_utils.get_widget_by_name(box, 'i1') box.children = [i1, i0] assert i0 is widget_utils.get_widget_by_name(box, 'i0') assert i1 is widget_utils.get_widget_by_name(box, 'i1') nt.assert_equal(widget_utils.get_widget_by_name(box, 'i100'), None)
def test_widget_utils(): box = HBox() i0 = IntText() i0._ngl_name = 'i0' i1 = IntText() i1._ngl_name = 'i1' box.children = [i0, i1] assert i0 is widget_utils.get_widget_by_name(box, 'i0') assert i1 is widget_utils.get_widget_by_name(box, 'i1') box.children = [i1, i0] assert i0 is widget_utils.get_widget_by_name(box, 'i0') assert i1 is widget_utils.get_widget_by_name(box, 'i1') assert widget_utils.get_widget_by_name(box, 'i100') is None assert widget_utils.get_widget_by_name(None, 'i100') is None
def __init__(self, candidate_labels, propositions): # internal vars self.header = '<p style="font-size: 150%;font-weight: 300;line-height: 1.39;margin: 0 0 12.5px;">{} <a target="_blank" href="{}">source</a></p>' self.candidate_labels = candidate_labels self.propositions = propositions self.choice = None self.clicked = False self.confusion_matrix = np.zeros((len(candidate_labels), len(candidate_labels)), dtype=np.int) # candidate buttons buttons = [Button(description=label) for label in self.candidate_labels] for b in buttons: b.on_click(self.on_button_clicked) hbox1 = HBox() hbox1.children = buttons self.buttons = buttons # scorebox and new_question button and confusion matrix self.scorebox = IntText(description='score', value=0, disabled=True) self.number = IntText(description='questions', value=0, disabled=True) new_question = Button(description='nouvelle question !') new_question.on_click(self.create_new_question) confusion_matrix_button = Button(description='afficher matrice de confusion') confusion_matrix_button.on_click(self.show_confusion_matrix) hbox2 = HBox() hbox2.children = [self.scorebox, self.number, new_question, confusion_matrix_button] # proposition box self.html = HTML() # general layout vbox = VBox() vbox.children = [hbox1, hbox2, self.html] self.box = vbox # generate first question self.create_new_question()
def createDefaultLayout(self, layout): ui = {} lkeys = list(layout.keys()) tkeys = len(lkeys) for i in range(tkeys): k = lkeys[i] ui[k] = {} if i < tkeys - 1: ui[k]["next"] = Button(description="Go to " + lkeys[i + 1], layout=Layout(width="50%")) if 'click' in layout[lkeys[i + 1]]: ui[k]["next"].on_click(layout[lkeys[i + 1]]["click"]) else: ui[k]["next"] = Button(description="", layout=Layout(width="50%"), disabled=True) if i > 0: ui[k]["back"] = Button(description="Go to " + lkeys[i - 1], layout=Layout(width="50%")) if 'click' in layout[lkeys[i - 1]]: ui[k]["back"].on_click(layout[lkeys[i - 1]]["click"]) else: ui[k]["back"] = Button(description="", layout=Layout(width="50%"), disabled=True) ui[k]["button_container"] = HBox(layout=Layout(width="100%")) ui[k]["button_container"].children = [ui[k]["back"], ui[k]["next"]] ui[k]["container"] = VBox( layout=Layout(width="100%", border="1px solid #6666")) children = [] children.append(ui[k]["button_container"]) if "children" in layout[k]: for k2, v in layout[k]["children"].items(): ui[k][k2] = v children.append(v) children.append(ui[k]["button_container"]) ui[k]["container"].children = children ui[k]["action"] = layout[k]["action"] return ui
'Equil Return': 'UD_EQUIL_RETURN', 'BL Return': 'UD_BL_RETURN' } #pd.DataFrame({'ID':list(dict_settings['security'].keys()),'Equil Return': [x[0] for x in Pi]}).set_index('ID') try: df = df.rename(columns=upload_dict) list_to_upload = list(upload_dict.values()) #fs = bqcde.get_fields(mnemonics=list_to_upload) df['AS_OF_DATE'] = as_of_date df['AS_OF_DATE'] = pd.to_datetime(df['AS_OF_DATE']) #bqcde.write(fields=fs, dataframe=df.fillna("N/A")) except Exception as e: print(e) obj.description = 'Upload to CDE' #upload_to_cde() #button = Button(description='Upload to CDE') #button.on_click(upload_to_cde) # END OF ************************************************************************************************************** (use of bqcde) *********************** preload_box.children = [] #VBox([button,tab]) VBox([tab]) #[Open Weight](output.xlsx) #for slider in list_slider: #print(slider.description, ": ", slider.value) #supressing this print out
def _create_title(self, title, tab_controls): """Creates title controls for this tab widget. - Adds title label - Adds download button for query result. Disabled if one of the following conditions hold: * query result contains ExplicitVBR or ExplicitVBROverlay type column * number of rows in the query result exceeds DOWNLOAD_THRESHOLD - Adds paginator if there exists no ExplicitVBR or ExplicitVBROverlay type column - Adds any controls related to column types in the result set Parameters ---------- title: str result set title. tab_controls: list list of controls related to columns in the result set. """ # initialize widgets # add title label title_label = HTML(f"<h3>{title}</h3>", layout=Layout(padding="0px 5px 5px 0px")) self._hbox_title = HBox(layout=Layout(justify_content="space-between", align_items="center")) # create download link dw = NlDownloadLink(layout=Layout( width="30px", max_width="30px", min_width="30px", margin="5px 5px 5px 0", padding="0 0 0 0", flex="0 1 0", align_self="center", )) hbox_table_info = HBox( [title_label, dw], layout=Layout(justify_content="flex-start", align_items="center"), ) if not self._columns_manager.hasVBRColumn: if self._total_nb_rows <= ResultTabPageWidget.DOWNLOAD_THRESHOLD: dw.filename = f"{title}.csv.gz" dw.mimetype = "application/gz" dw.tooltip = f"Download {dw.filename} file." def clicked(event): dw.content = gzip.compress( self._df.to_csv(index=False).encode()) dw.on_click(clicked) else: dw.disabled = True dw.tooltip = "Not available for download due to size!" # add paginator if there exist no ExplicitVBR or ExplicitVBROverlay column paginator = PaginationWidget( self._df.shape[0], layout=Layout(padding="0px 0px 0px 50px")) self._limit = paginator.limit paginator.observe(self._page_number_changed, names="page") paginator.observe(self._limit_changed, names="limit") hbox_table_info.children = hbox_table_info.children + (paginator, ) else: dw.tooltip = "Not available for download due to column type!" dw.disabled = True self._limit = self._total_nb_rows return [hbox_table_info, HBox(tab_controls)]