Shorten edit name, passthrough kwargs to adder methods
parent
edcbc88a42
commit
12858e9113
|
@ -48,7 +48,7 @@ from ._style import hcolor, _font, _font_small, DpiAwareFont
|
||||||
from ._label import FormatLabel
|
from ._label import FormatLabel
|
||||||
|
|
||||||
|
|
||||||
class FontAndChartAwareLineEdit(QLineEdit):
|
class Edit(QLineEdit):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
||||||
|
@ -369,13 +369,14 @@ class FieldsForm(QWidget):
|
||||||
key: str,
|
key: str,
|
||||||
label_name: str,
|
label_name: str,
|
||||||
value: str,
|
value: str,
|
||||||
|
readonly: bool = False,
|
||||||
|
|
||||||
) -> FontAndChartAwareLineEdit:
|
) -> Edit:
|
||||||
|
|
||||||
# TODO: maybe a distint layout per "field" item?
|
# TODO: maybe a distint layout per "field" item?
|
||||||
label = self.add_field_label(label_name)
|
label = self.add_field_label(label_name)
|
||||||
|
|
||||||
edit = FontAndChartAwareLineEdit(
|
edit = Edit(
|
||||||
parent=self,
|
parent=self,
|
||||||
# width_in_chars=6,
|
# width_in_chars=6,
|
||||||
)
|
)
|
||||||
|
@ -386,6 +387,7 @@ class FieldsForm(QWidget):
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
edit.setReadOnly(readonly)
|
||||||
edit.setText(str(value))
|
edit.setText(str(value))
|
||||||
self.form.addRow(label, edit)
|
self.form.addRow(label, edit)
|
||||||
|
|
||||||
|
@ -478,13 +480,15 @@ def mk_form(
|
||||||
for key, conf in fields_schema.items():
|
for key, conf in fields_schema.items():
|
||||||
wtype = conf['type']
|
wtype = conf['type']
|
||||||
label = str(conf.get('label', key))
|
label = str(conf.get('label', key))
|
||||||
|
kwargs = conf.get('kwargs', {})
|
||||||
|
|
||||||
# plain (line) edit field
|
# plain (line) edit field
|
||||||
if wtype == 'edit':
|
if wtype == 'edit':
|
||||||
w = form.add_edit_field(
|
w = form.add_edit_field(
|
||||||
key,
|
key,
|
||||||
label,
|
label,
|
||||||
conf['default_value']
|
conf['default_value'],
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
# drop-down selection
|
# drop-down selection
|
||||||
|
@ -493,7 +497,8 @@ def mk_form(
|
||||||
w = form.add_select_field(
|
w = form.add_select_field(
|
||||||
key,
|
key,
|
||||||
label,
|
label,
|
||||||
values
|
values,
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
w._key = key
|
w._key = key
|
||||||
|
|
|
@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (
|
||||||
|
|
||||||
from ._forms import (
|
from ._forms import (
|
||||||
# FontScaledDelegate,
|
# FontScaledDelegate,
|
||||||
FontAndChartAwareLineEdit,
|
Edit,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class Selection(Field[DataType], Generic[DataType]):
|
||||||
class Edit(Field[DataType], Generic[DataType]):
|
class Edit(Field[DataType], Generic[DataType]):
|
||||||
'''An edit field which takes a number.
|
'''An edit field which takes a number.
|
||||||
'''
|
'''
|
||||||
widget_factory = FontAndChartAwareLineEdit
|
widget_factory = Edit
|
||||||
|
|
||||||
|
|
||||||
class AllocatorPane(BaseModel):
|
class AllocatorPane(BaseModel):
|
||||||
|
|
|
@ -72,7 +72,7 @@ from ._style import (
|
||||||
_font,
|
_font,
|
||||||
hcolor,
|
hcolor,
|
||||||
)
|
)
|
||||||
from ._forms import FontAndChartAwareLineEdit, FontScaledDelegate
|
from ._forms import Edit, FontScaledDelegate
|
||||||
|
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
|
@ -407,7 +407,7 @@ class CompleterView(QTreeView):
|
||||||
self.resize()
|
self.resize()
|
||||||
|
|
||||||
|
|
||||||
class SearchBar(FontAndChartAwareLineEdit):
|
class SearchBar(Edit):
|
||||||
|
|
||||||
mode_name: str = 'search'
|
mode_name: str = 'search'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue