implement some basic infrastructure to present device forms
This commit is contained in:
23
owrx/controllers/settings/devices/__init__.py
Normal file
23
owrx/controllers/settings/devices/__init__.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from owrx.form import Input
|
||||
from owrx.controllers.settings import Section
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import List
|
||||
|
||||
|
||||
class SdrDeviceType(ABC):
|
||||
@staticmethod
|
||||
def getByType(sdr_type: str) -> "SdrDeviceType":
|
||||
try:
|
||||
className = "".join(x for x in sdr_type.title() if x.isalnum()) + "DeviceType"
|
||||
module = __import__("owrx.controllers.settings.devices.{0}".format(sdr_type), fromlist=[className])
|
||||
cls = getattr(module, className)
|
||||
return cls()
|
||||
except ModuleNotFoundError:
|
||||
return None
|
||||
|
||||
@abstractmethod
|
||||
def getInputs(self) -> List[Input]:
|
||||
pass
|
||||
|
||||
def getSection(self):
|
||||
return Section("Device settings", *self.getInputs())
|
||||
13
owrx/controllers/settings/devices/rtl_sdr.py
Normal file
13
owrx/controllers/settings/devices/rtl_sdr.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import List
|
||||
from owrx.controllers.settings.devices import SdrDeviceType
|
||||
from owrx.form import Input, TextInput
|
||||
|
||||
|
||||
class RtlSdrDeviceType(SdrDeviceType):
|
||||
def getInputs(self) -> List[Input]:
|
||||
return [
|
||||
TextInput(
|
||||
"test",
|
||||
"This is a drill"
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user