From 06700d5fe1b6b9e539e4c000c48b279daca829ef Mon Sep 17 00:00:00 2001 From: Marco Musy Date: Sun, 3 Mar 2024 23:42:45 +0100 Subject: [PATCH] fix #1064 --- vedo/applications.py | 8 ++++---- vedo/cli.py | 14 ++++++++++---- vedo/file_io.py | 6 +++--- vedo/utils.py | 12 ++++++++++-- vedo/version.py | 2 +- vedo/volume.py | 4 ++-- 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/vedo/applications.py b/vedo/applications.py index c445a0ee..44b9d22e 100644 --- a/vedo/applications.py +++ b/vedo/applications.py @@ -316,7 +316,8 @@ def button_func(obj, ename): size=16, bold=True, ) - bu.pos([0.04, 0.01], "bottom-left") + if bu: + bu.pos([0.04, 0.01], "bottom-left") #################################################################################### @@ -1024,7 +1025,7 @@ def __init__( delayed=False, sliderpos=4, **kwargs, - ): + ) -> None: """ Generate a `vedo.Plotter` for Volume isosurfacing using a slider. @@ -1163,8 +1164,7 @@ def slider_isovalue(widget, event): mesh = volume.isosurface(value).color(c).alpha(alpha) bacts.update({value_name: mesh}) # store it - self.renderer.RemoveActor(prevact) - self.renderer.AddActor(mesh) + self.remove(prevact).add(mesh) self.vol_actors[0] = mesh ################################################ diff --git a/vedo/cli.py b/vedo/cli.py index 9e609047..d29c5d71 100644 --- a/vedo/cli.py +++ b/vedo/cli.py @@ -229,10 +229,16 @@ def exe_run(args): from pygments import highlight from pygments.lexers import Python3Lexer from pygments.formatters import Terminal256Formatter - - # from pygments.styles import STYLE_MAP - # print(STYLE_MAP.keys()) - result = highlight(code, Python3Lexer(), Terminal256Formatter(style="zenburn")) + from pygments.styles import STYLE_MAP + + # print("Terminal256Formatter STYLE_MAP", STYLE_MAP.keys()) + if "zenburn" in STYLE_MAP.keys(): + tform = Terminal256Formatter(style="zenburn") + elif "monokai" in STYLE_MAP.keys(): + tform = Terminal256Formatter(style="monokai") + else: + tform = Terminal256Formatter() + result = highlight(code, Python3Lexer(), tform) print(result, end="") printc("(" + matching[0] + ")", c="y", bold=0, italic=1) diff --git a/vedo/file_io.py b/vedo/file_io.py index bf490b5d..35173c97 100644 --- a/vedo/file_io.py +++ b/vedo/file_io.py @@ -2,7 +2,7 @@ import os import time from tempfile import NamedTemporaryFile, TemporaryDirectory -from typing import Any, List, Union +from typing import Any, List, Tuple, Union import numpy as np @@ -591,7 +591,7 @@ def gunzip(filename: str) -> str: return tmp_file.name ######################################################################## -def file_info(file_path: str) -> tuple[str, str]: +def file_info(file_path: str) -> Tuple[str, str]: """Return the file size and creation time of input file""" siz, created = "", "" if os.path.isfile(file_path): @@ -751,7 +751,7 @@ def loadDolfin(filename: str) -> Union[Mesh, "vedo.TetMesh", None]: ######################################################################## -def loadPVD(filename: str) -> Union[list[Any], None]: +def loadPVD(filename: str) -> Union[List[Any], None]: """Read paraview files.""" import xml.etree.ElementTree as et diff --git a/vedo/utils.py b/vedo/utils.py index 9c962d9a..d090bc1c 100644 --- a/vedo/utils.py +++ b/vedo/utils.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import os import time -from typing import Union, Tuple, MutableSequence, List, Dict +from typing import Union, Tuple, MutableSequence, List import numpy as np from vtkmodules.util.numpy_support import numpy_to_vtk, vtk_to_numpy @@ -2200,7 +2200,15 @@ def vtkCameraToK3D(vtkcam) -> np.ndarray: return np.array(kam).ravel() -def make_ticks(x0: float, x1: float, n=None, labels=None, digits=None, logscale=False, useformat="") -> Tuple[np.ndarray, List[str]]: +def make_ticks( + x0: float, + x1: float, + n=None, + labels=None, + digits=None, + logscale=False, + useformat="", + ) -> Tuple[np.ndarray, List[str]]: """ Generate numeric labels for the `[x0, x1]` range. diff --git a/vedo/version.py b/vedo/version.py index 67327b35..69fb6b52 100644 --- a/vedo/version.py +++ b/vedo/version.py @@ -1 +1 @@ -_version = '2024.5.1+dev03' +_version = '2024.5.1+dev04' diff --git a/vedo/volume.py b/vedo/volume.py index ae840fd4..244cee39 100644 --- a/vedo/volume.py +++ b/vedo/volume.py @@ -812,7 +812,7 @@ def spacing(self, s=None) -> Union["Volume", Iterable[float]]: return self return np.array(self.dataset.GetSpacing()) - def origin(self, s=None) -> Union["Volume", np.ndarray[Any, Any]]: + def origin(self, s=None) -> Union["Volume", Iterable[float]]: """ Set/get the origin of the volumetric dataset. @@ -827,7 +827,7 @@ def origin(self, s=None) -> Union["Volume", np.ndarray[Any, Any]]: return self return np.array(self.dataset.GetOrigin()) - def pos(self, p=None) -> Union["Volume", np.ndarray]: + def pos(self, p=None) -> Union["Volume", Iterable[float]]: """Set/get the position of the volumetric dataset.""" if p is not None: self.origin(p)