diff --git a/README.md b/README.md index b2e7439..3b468f2 100644 --- a/README.md +++ b/README.md @@ -629,6 +629,20 @@ example: vm.event.ldirty = True vm.event.pdirty = False +``` + +Or add, remove a list of events. + +The following methods are available: + +- `add()` +- `remove()` +- `get()` + +example: + +```python +vm.event.remove(["pdirty", "mdirty", "midi"]) # get a list of currently subscribed print(vm.event.get()) diff --git a/pyproject.toml b/pyproject.toml index 47edf17..d24480b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "voicemeeter-api" -version = "0.8.3" +version = "0.8.4" description = "A Python wrapper for the Voiceemeter API" authors = ["onyx-and-iris "] license = "MIT" diff --git a/voicemeeterlib/event.py b/voicemeeterlib/event.py index 799ce29..0c24b4d 100644 --- a/voicemeeterlib/event.py +++ b/voicemeeterlib/event.py @@ -1,4 +1,5 @@ import logging +from typing import Iterable, Union class Event: @@ -59,8 +60,14 @@ class Event: def any(self) -> bool: return any(self.subs.values()) - def add(self, event): - setattr(self, event, True) + def add(self, events: Union[str, Iterable[str]]): + if isinstance(events, str): + events = [events] + for event in events: + setattr(self, event, True) - def remove(self, event): - setattr(self, event, False) + def remove(self, events: Union[str, Iterable[str]]): + if isinstance(events, str): + events = [events] + for event in events: + setattr(self, event, False)