first commit
This commit is contained in:
26
screenshot_backend.py
Normal file
26
screenshot_backend.py
Normal file
@@ -0,0 +1,26 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user