27 lines
480 B
Python
27 lines
480 B
Python
from abc import ABC, abstractmethod
|
|
|
|
|
|
class ScreenshotBackend(ABC):
|
|
@abstractmethod
|
|
def supports(self) -> bool:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def active_window(self) -> str:
|
|
pass
|
|
|
|
|
|
_backends = []
|
|
|
|
|
|
def register_backend(cls):
|
|
_backends.append(cls())
|
|
return cls
|
|
|
|
|
|
def get_backend() -> ScreenshotBackend:
|
|
for backend in _backends:
|
|
if backend.supports():
|
|
return backend
|
|
raise RuntimeError("No screenshot backend available")
|