diff --git a/piker/ui/_forms.py b/piker/ui/_forms.py index 38184ca4..993073a9 100644 --- a/piker/ui/_forms.py +++ b/piker/ui/_forms.py @@ -48,7 +48,7 @@ from ._style import hcolor, _font, _font_small, DpiAwareFont from ._label import FormatLabel -class FontAndChartAwareLineEdit(QLineEdit): +class Edit(QLineEdit): def __init__( @@ -369,13 +369,14 @@ class FieldsForm(QWidget): key: str, label_name: str, value: str, + readonly: bool = False, - ) -> FontAndChartAwareLineEdit: + ) -> Edit: # TODO: maybe a distint layout per "field" item? label = self.add_field_label(label_name) - edit = FontAndChartAwareLineEdit( + edit = Edit( parent=self, # width_in_chars=6, ) @@ -386,6 +387,7 @@ class FieldsForm(QWidget): }} """ ) + edit.setReadOnly(readonly) edit.setText(str(value)) self.form.addRow(label, edit) @@ -478,13 +480,15 @@ def mk_form( for key, conf in fields_schema.items(): wtype = conf['type'] label = str(conf.get('label', key)) + kwargs = conf.get('kwargs', {}) # plain (line) edit field if wtype == 'edit': w = form.add_edit_field( key, label, - conf['default_value'] + conf['default_value'], + **kwargs, ) # drop-down selection @@ -493,7 +497,8 @@ def mk_form( w = form.add_select_field( key, label, - values + values, + **kwargs, ) w._key = key diff --git a/piker/ui/_orm.py b/piker/ui/_orm.py index 152da505..67050e95 100644 --- a/piker/ui/_orm.py +++ b/piker/ui/_orm.py @@ -36,7 +36,7 @@ from PyQt5.QtWidgets import ( from ._forms import ( # FontScaledDelegate, - FontAndChartAwareLineEdit, + Edit, ) @@ -97,7 +97,7 @@ class Selection(Field[DataType], Generic[DataType]): class Edit(Field[DataType], Generic[DataType]): '''An edit field which takes a number. ''' - widget_factory = FontAndChartAwareLineEdit + widget_factory = Edit class AllocatorPane(BaseModel): diff --git a/piker/ui/_search.py b/piker/ui/_search.py index 48561a24..94a2fd56 100644 --- a/piker/ui/_search.py +++ b/piker/ui/_search.py @@ -72,7 +72,7 @@ from ._style import ( _font, hcolor, ) -from ._forms import FontAndChartAwareLineEdit, FontScaledDelegate +from ._forms import Edit, FontScaledDelegate log = get_logger(__name__) @@ -407,7 +407,7 @@ class CompleterView(QTreeView): self.resize() -class SearchBar(FontAndChartAwareLineEdit): +class SearchBar(Edit): mode_name: str = 'search'