def _repr_html_(self, compact=False) -> str: from paquo._repr import div from paquo._repr import h4 from paquo._repr import repr_html images = [ repr_html(img, compact=True, index=idx) for idx, img in enumerate(self) ] header_css = {"margin-top": "0"} if not compact else {} return div( h4(text="Images:", style=header_css), div(*images, style={"display": "flex"}), )
def _repr_html_(self): from paquo._repr import div from paquo._repr import span a = self.alpha / 255. alpha = f"alpha={a:0.3f}" if self.alpha != 255 else "" return div( span(text=f"{self.__class__.__name__}: ", style={"font-weight": "bold"}), div( style={ "display": "inline-block", "vertical-align": "text-top", "margin-right": "0.2em", "width": "1em", "height": "1em", "border": "1px solid black", "opacity": str(a), "background": self.to_hex() }), span(text=f"{self.to_hex()} {alpha}"), )
def _repr_html_(self): from paquo._repr import br from paquo._repr import div from paquo._repr import h4 from paquo._repr import p from paquo._repr import span return div( h4(text=f"Hierarchy: {self._image_name}", style={"margin-top": "0"}), p( span(text="annotations: ", style={"font-weight": "bold"}), span(text=f"{len(self._annotations)}"), br(), span(text="detections: ", style={"font-weight": "bold"}), span(text=f"{len(self._detections)}"), style={"margin": "0.5em"}, ), )
def _repr_html_(self) -> str: from paquo._repr import br from paquo._repr import div from paquo._repr import h3 from paquo._repr import p from paquo._repr import repr_html from paquo._repr import span return div( h3(style={"margin-top": "0"}, text=f"Project: {self.name}"), p( span(text="path: ", style={"font-weight": "bold"}), span(text=str(self._path)), br(), span(text="mode: ", style={"font-weight": "bold"}), span(text=self._mode), style={"margin": "0.5em"}, ), repr_html(self.images), )
def _repr_html_(self): from paquo._repr import br from paquo._repr import div from paquo._repr import h4 from paquo._repr import p from paquo._repr import rawhtml from paquo._repr import repr_svg from paquo._repr import span obj_class_name = self.__class__.__name__ if obj_class_name.startswith('QuPath'): obj_class_name = obj_class_name[6:] name = self.name or "N/A" path_class = self.path_class path_class_name = path_class.name if path_class else "N/A" roi = self.roi if hasattr(roi, '_repr_svg_'): roi_tag = span(rawhtml(repr_svg(roi)), style={"vertical-align": "text-top"}) else: roi_tag = span(text=roi.wkt) # pragma: no cover return div( h4(text=f"{obj_class_name}:", style={"margin-top": "0"}), p( span(text="name: ", style={"font-weight": "bold"}), span(text=name), br(), span(text="path_class: ", style={"font-weight": "bold"}), span(text=path_class_name), br(), span(text="roi_type: ", style={"font-weight": "bold"}), span(text=roi.type), br(), span(text="roi: ", style={"font-weight": "bold"}), roi_tag, style={"margin": "0.5em"}, ), )
def _repr_html_(self, compact=False, index=0): from base64 import b64encode from paquo._repr import br from paquo._repr import div from paquo._repr import h4 from paquo._repr import img from paquo._repr import p from paquo._repr import span img_css = { "max-width": "100px", "max-height": "100px", "border": "1px solid", "margin": "auto", } header_css = { "position": "absolute", "top": "-1.6em", "width": "100px", "overflow": "hidden", "text-overflow": "ellipsis", "font-size": "0.75em", } container_css = { "display": "flex", "align-items": "center", "justify-content": "center", "position": "relative", "width": "100px", "height": "100px", "background": "#ddd", "margin": "2px", } try: with (self.entry_path / "thumbnail.jpg").open(mode="rb") as f: data = b64encode(f.read()).decode('utf-8') except FileNotFoundError: # pragma: no cover image = span(style={"font-size": "3em"}, text="?") else: image = img(title=self.image_name, src=f"data:image/jpeg;base64,{data}", style=img_css) if compact: container_css["margin-top"] = "1em" return div(span(text=f"[{index}]\xa0{self.image_name}", style=header_css), image, style=container_css) try: uri = self.uri[5:] except RuntimeError as err: # pragma: no cover uri = f"N/A ({err})" return div( h4(text=f"Image: {self.image_name}", style={"margin-top": "0"}), p( span(text="path: ", style={"font-weight": "bold"}), span(text=uri), br(), span(text="type: ", style={"font-weight": "bold"}), span(text=str(self.image_type.value)), style={"margin": "0.5em"}, ), div( image, style=container_css, ))