Добавлены иконки для разных категорий

main
none 9 months ago
parent 4d2341d706
commit 12a6523cb3

@ -25,7 +25,7 @@ def calc(el, amount, main = False):
if main: if main:
recipe = {} recipe = {}
comps = db[el][1:] # Получаем составные comps = db[el][2:] # Получаем составные
out = db[el][0] #Количество на выходе out = db[el][0] #Количество на выходе
# Считаем количество частей # Считаем количество частей

@ -7,16 +7,34 @@ els = list(db.keys())
###### ОФОРМЛЕНИЕ ####### ###### ОФОРМЛЕНИЕ #######
from dash import Dash, dcc, html, Input, Output,callback from dash import Dash, dcc, html, Input, Output,callback
app = Dash(__name__) app = Dash(__name__)
# Форматируем список для красоты
def list_form(ll):
global db
formatted = []
imgs = {'medicine': '💊',
'chemicals': '🧪'}
for i in ll:
print(db[i][1])
if db[i][1] in imgs:
formatted.append(imgs[db[i][1]] + ' ' + i)
else:
formatted.append(i)
return formatted
app.layout = html.Div([ app.layout = html.Div([
# Название + объём # Название + объём
html.Div([ html.Div([
# Реакция # Реакция
html.Div([ html.Div([
dcc.Dropdown(els, id='reaction', placeholder="Реакция", maxHeight=500, style={'font-size': '120%'}) dcc.Dropdown(list_form(els), id='reaction', placeholder="Реакция", maxHeight=500, style={'font-size': '120%'})
], style={'flex': 4}), ], style={'flex': 4}),
# Объём # Объём
@ -53,6 +71,7 @@ from calc import *
) )
def update_output(reaction, amount): def update_output(reaction, amount):
if reaction: if reaction:
reaction = reaction[2:]
comps, res = calc(reaction, amount, main = True) comps, res = calc(reaction, amount, main = True)
# Форматирование для HTML # Форматирование для HTML

Loading…
Cancel
Save