From 12a6523cb3770c432b7e5e697d14a7f0feaf6ee2 Mon Sep 17 00:00:00 2001 From: none Date: Sun, 28 Jan 2024 12:10:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B8=D0=BA=D0=BE=D0=BD=D0=BA=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B7=D0=BD=D1=8B=D1=85=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calc.py | 2 +- site.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/calc.py b/calc.py index 2e9c5a2..d1856c1 100644 --- a/calc.py +++ b/calc.py @@ -25,7 +25,7 @@ def calc(el, amount, main = False): if main: recipe = {} - comps = db[el][1:] # Получаем составные + comps = db[el][2:] # Получаем составные out = db[el][0] #Количество на выходе # Считаем количество частей diff --git a/site.py b/site.py index cc8cc44..bb11fac 100644 --- a/site.py +++ b/site.py @@ -7,16 +7,34 @@ els = list(db.keys()) ###### ОФОРМЛЕНИЕ ####### from dash import Dash, dcc, html, Input, Output,callback - 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([ # Название + объём 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}), # Объём @@ -53,6 +71,7 @@ from calc import * ) def update_output(reaction, amount): if reaction: + reaction = reaction[2:] comps, res = calc(reaction, amount, main = True) # Форматирование для HTML