Start using a small schema for generating forms
parent
4336939507
commit
f27db80bf4
|
@ -309,7 +309,7 @@ async def handle_field_input(
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def mk_form(
|
async def open_form(
|
||||||
|
|
||||||
parent: QWidget,
|
parent: QWidget,
|
||||||
fields: dict,
|
fields: dict,
|
||||||
|
@ -319,10 +319,18 @@ async def mk_form(
|
||||||
|
|
||||||
form = FieldsForm(parent)
|
form = FieldsForm(parent)
|
||||||
|
|
||||||
for name, value in fields.items():
|
for name, config in fields.items():
|
||||||
form.add_edit_field(name, value)
|
wtype = config['type']
|
||||||
|
key = str(config['key'])
|
||||||
|
|
||||||
form.add_select_field('policy:', ['uniform'])
|
# plain (line) edit field
|
||||||
|
if wtype == 'edit':
|
||||||
|
form.add_edit_field(key, config['default_value'])
|
||||||
|
|
||||||
|
# drop-down selection
|
||||||
|
elif wtype == 'select':
|
||||||
|
values = list(config['default_value'])
|
||||||
|
form.add_select_field(key, values)
|
||||||
|
|
||||||
form.add_field_label('fills:')
|
form.add_field_label('fills:')
|
||||||
fill_bar = QProgressBar(form)
|
fill_bar = QProgressBar(form)
|
||||||
|
|
|
@ -35,7 +35,7 @@ from ._editors import LineEditor, ArrowEditor
|
||||||
from ._lines import LevelLine
|
from ._lines import LevelLine
|
||||||
from ._position import PositionTracker
|
from ._position import PositionTracker
|
||||||
from ._window import MultiStatus
|
from ._window import MultiStatus
|
||||||
from ._forms import FieldsForm, mk_form
|
from ._forms import FieldsForm, open_form
|
||||||
|
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
|
@ -378,6 +378,27 @@ async def run_order_mode(
|
||||||
positions
|
positions
|
||||||
),
|
),
|
||||||
|
|
||||||
|
open_form(
|
||||||
|
parent=chart.linked.godwidget,
|
||||||
|
fields={
|
||||||
|
'dollar_size': {
|
||||||
|
'key': '**$size**:',
|
||||||
|
'type': 'edit',
|
||||||
|
'default_value': 5000,
|
||||||
|
},
|
||||||
|
'slots': {
|
||||||
|
'key': '**slots**:',
|
||||||
|
'type': 'edit',
|
||||||
|
'default_value': 4,
|
||||||
|
},
|
||||||
|
'disti_policy': {
|
||||||
|
'key': '**policy**:',
|
||||||
|
'type': 'select',
|
||||||
|
'default_value': ['uniform'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
) as pp_config,
|
||||||
|
|
||||||
):
|
):
|
||||||
view = chart._vb
|
view = chart._vb
|
||||||
lines = LineEditor(chart=chart)
|
lines = LineEditor(chart=chart)
|
||||||
|
@ -389,15 +410,6 @@ async def run_order_mode(
|
||||||
pp.hide()
|
pp.hide()
|
||||||
|
|
||||||
# insert order mode config to left of mode label
|
# insert order mode config to left of mode label
|
||||||
pp_config = mk_form(
|
|
||||||
parent=chart.linked.godwidget,
|
|
||||||
fields={
|
|
||||||
'**$size**:': 5000,
|
|
||||||
'**slots**:': 4,
|
|
||||||
# '**policy**:': 'uniform',
|
|
||||||
# '**type**:': 'live-buy',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
sb = chart.window().statusBar()
|
sb = chart.window().statusBar()
|
||||||
sb.insertPermanentWidget(0, pp_config)
|
sb.insertPermanentWidget(0, pp_config)
|
||||||
pp_config.hide()
|
pp_config.hide()
|
||||||
|
|
Loading…
Reference in New Issue