Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Completed CLI for input colours 😊

Syrus Dark64b27ab63c7e
diff --git a/example_scenes/rich.cfg b/example_scenes/rich.cfg
new file mode 100644
index 000000000..9bbb2c046
--- /dev/null
+++ b/example_scenes/rich.cfg
@@ -0,0 +1,13 @@
+{
+ "logging.keyword": "bold yellow",
+ "logging.level.notset": "dim",
+ "logging.level.debug": "green",
+ "logging.level.info": "blue",
+ "logging.level.warning": "red",
+ "logging.level.error": "red bold",
+ "logging.level.critical": "red bold reverse",
+ "log.level": "",
+ "log.time": "cyan dim",
+ "log.message": "",
+ "log.path": "dim"
+}
\ No newline at end of file
diff --git a/example_scenes/rich.json b/example_scenes/rich.json
deleted file mode 100644
index 40b5451a3..000000000
--- a/example_scenes/rich.json
+++ /dev/null
@@ -1 +0,0 @@
-{"info": "green", "danger": "bold red", "warning": "green", "logging.keyword":"red","logging.level.notset":"green","logging.level.info":"green","log.message":"green","log.path":"#000000"}
\ No newline at end of file
diff --git a/manim/extract_scene.py b/manim/extract_scene.py
index c25e3aa09..8f81a971b 100644
--- a/manim/extract_scene.py
+++ b/manim/extract_scene.py
@@ -77,7 +77,7 @@ def prompt_user_for_choice(scene_classes):
num_to_class = {}
for count, scene_class in zip(it.count(1), scene_classes):
name = scene_class.__name__
- console.print("%d: %s" % (count, name),style="warning")
+ console.print("%d: %s" % (count, name),style="logging.level.info")
num_to_class[count] = scene_class
try:
user_input = console.input("[log.message]"+constants.CHOOSE_NUMBER_MESSAGE+"[/log.message]")
diff --git a/manim/logger/__init__.py b/manim/logger/__init__.py
index 9c10e7e22..36891721b 100644
--- a/manim/logger/__init__.py
+++ b/manim/logger/__init__.py
@@ -11,6 +11,4 @@ logging.basicConfig(
)
logger = logging.getLogger("rich")
-
-
\ No newline at end of file
diff --git a/manim/logger/__main__.py b/manim/logger/__main__.py
index 32d4ff689..f1d1fcf38 100644
--- a/manim/logger/__main__.py
+++ b/manim/logger/__main__.py
@@ -1,7 +1,10 @@
-from .console import console
+from rich.console import Console
+from rich.progress import track
+import json
if __name__=="__main__":
+ console = Console()
default={"logging.keyword":"bold yellow",
"logging.level.notset":"dim",
"logging.level.debug":"green",
@@ -9,12 +12,20 @@ if __name__=="__main__":
"logging.level.warning":"red",
"logging.level.error": "red bold",
"logging.level.critical": "red bold reverse",
- "log.level":None,
+ "log.level":"",
"log.time": "cyan dim",
- "log.message": None,
+ "log.message": "",
"log.path": "dim",
}
console.print("[yellow bold]Manim Logger Configuration Editor[/yellow bold]",justify="center")
+ console.print("[red]The default colour is shown as input Statement.\nIf left empty default value will be assigned.[/red]")
+ console.print("[magenta]Please follow the link for available styles.[/magenta][link=https://rich.readthedocs.io/en/latest/style.html]docs[/link]")
for key in default:
- console.print('Enter the Style for %s'%key+':',style=key)
- default[key]=
\ No newline at end of file
+ console.print('Enter the Style for %s'%key+':',style=key,end='')
+ temp=input()
+ if temp:
+ default[key]=temp
+ for n in track(range(100), description="Converting to JSON"):
+ with open("rich.cfg","w") as fp:
+ json.dump(default,fp,indent=4)
+ console.print("A file called [yellow]rich.cfg[/yellow] is created. To save your theme please save that file and each time \nplace it in you current working directory(The directory where you execute manim command) for the your theme to be displayed.")
\ No newline at end of file
diff --git a/manim/logger/console.py b/manim/logger/console.py
index c6df4ff69..3508e923e 100644
--- a/manim/logger/console.py
+++ b/manim/logger/console.py
@@ -6,8 +6,11 @@ def parseTheme(fp):
with open(fp,'r') as f:
content=f.read()
theme=json.loads(content)
- theme['listScenes']='yellow'
customTheme=Theme(theme)
return customTheme
-customTheme = parseTheme("rich.json")
-console = Console(theme=customTheme)
\ No newline at end of file
+try:
+ customTheme = parseTheme("rich.cfg")
+ console = Console(theme=customTheme)
+except:
+ console = Console()
+
diff --git a/manim/logger/theme.txt b/manim/logger/theme.txt
deleted file mode 100644
index 3dbba6c97..000000000
--- a/manim/logger/theme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-[styles]
-info = dim cyan
-warning = magenta
-danger = bold red
-listScenes = yellow
\ No newline at end of file