implement some basic infrastructure to present device forms

This commit is contained in:
Jakob Ketterl
2021-02-19 00:46:52 +01:00
parent 872c7a4bfd
commit 012952f6f3
4 changed files with 58 additions and 9 deletions

View 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())

View 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"
),
]