Add a "health bar" factor B)

fsp_feeds
Tyler Goodlet 2021-07-27 06:11:47 -04:00
parent 63138ccbf4
commit 0ffbb15bc7
1 changed files with 27 additions and 18 deletions

View File

@ -188,6 +188,8 @@ class FieldsForm(QWidget):
font_size: Optional[int] = None, font_size: Optional[int] = None,
font_color: str = 'default_lightest', font_color: str = 'default_lightest',
**vbox_kwargs,
) -> QtGui.QLabel: ) -> QtGui.QLabel:
# add label to left of search bar # add label to left of search bar
@ -212,7 +214,7 @@ class FieldsForm(QWidget):
) )
label.show() label.show()
self.vbox.addWidget(label) self.vbox.addWidget(label, **vbox_kwargs)
self.labels[name] = label self.labels[name] = label
return label return label
@ -360,15 +362,36 @@ async def open_form(
values = list(config['default_value']) values = list(config['default_value'])
form.add_select_field(key, values) form.add_select_field(key, values)
async with open_handlers(
list(form.fields.values()),
event_types={QEvent.KeyPress},
async_handler=partial(
handle_field_input,
form=form,
),
# block key repeats?
filter_auto_repeats=True,
):
yield form
def mk_health_bar(
form: FieldsForm,
) -> FieldsForm:
form.vbox.addSpacing(6) form.vbox.addSpacing(6)
form.add_field_label('fill status') form.add_field_label('fill status', alignment=Qt.AlignCenter)
form.vbox.addSpacing(6) form.vbox.addSpacing(6)
fill_bar = QProgressBar(form) fill_bar = QProgressBar(form)
import math import math
slots = 4 slots = 4
border_size_px = 2 border_size_px = 2
slot_margin_px = 2 #1.375 slot_margin_px = 2 # 1.375
h = 150 #+ (2*2 + slot_margin_px*slots*2) h = 150 #+ (2*2 + slot_margin_px*slots*2)
# multiples, r = divmod(h, slots) # multiples, r = divmod(h, slots)
slot_height_px = math.floor((h - 2*border_size_px)/slots) - slot_margin_px*1 slot_height_px = math.floor((h - 2*border_size_px)/slots) - slot_margin_px*1
@ -431,18 +454,4 @@ async def open_form(
form.vbox.addWidget(fill_bar, alignment=Qt.AlignCenter) form.vbox.addWidget(fill_bar, alignment=Qt.AlignCenter)
# form.vbox.addStretch() # form.vbox.addStretch()
return form
async with open_handlers(
list(form.fields.values()),
event_types={QEvent.KeyPress},
async_handler=partial(
handle_field_input,
form=form,
),
# block key repeats?
filter_auto_repeats=True,
):
yield form