Skip to content

Commit

Permalink
implement AnswerRegistry and AnswerWidget
Browse files Browse the repository at this point in the history
* new class exercise.Textarea that implements AnswerWidget
* CodeDemo implements AnswerWidget
* CodeDemo: merge member functions handle_checks_result and _output_results
* add _utils.py with Printer static class for nicer printing using termcolor
* replace prints with Printer.print_* functions
* adapt save css style to more readable
* parameters in ParameterPanel are now settable
  • Loading branch information
agoscinski committed Dec 22, 2023
1 parent 520988c commit d7f901f
Show file tree
Hide file tree
Showing 13 changed files with 1,683 additions and 75 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ dependencies = [
"ipywidgets>=8.0.0",
"numpy",
"widget_code_input",
"matplotlib"
"matplotlib",
"termcolor"
]
dynamic = ["version"]

Expand Down
16 changes: 16 additions & 0 deletions src/scwidgets/_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from termcolor import colored


class Printer:
# move to output
@staticmethod
def print_error_message(message: str):
print(colored(message, "red", attrs=["bold"]))

@staticmethod
def print_success_message(message: str):
print(colored(message, "green", attrs=["bold"]))

@staticmethod
def print_info_message(message: str):
print(colored(message, "blue", attrs=["bold"]))
3 changes: 3 additions & 0 deletions src/scwidgets/answer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._widget_answer_registry import AnswerRegistry, AnswerWidget

__all__ = ["AnswerWidget", "AnswerRegistry"]
Loading

0 comments on commit d7f901f

Please sign in to comment.