From 911c20441f11d14b132d460b21ac5d5811fce91e Mon Sep 17 00:00:00 2001 From: none Date: Sun, 28 Jan 2024 22:50:30 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0:=20'Updating..?= =?UTF-8?q?.'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site.py b/site.py index ace08b4..6cb1ef0 100644 --- a/site.py +++ b/site.py @@ -7,7 +7,7 @@ els = list(db.keys()) ###### ОФОРМЛЕНИЕ ####### from dash import Dash, dcc, html, Input, Output,callback -app = Dash(__name__, title="SS14 Tools") +app = Dash(__name__, title="SS14 Tools", update_title=None) # Форматируем список для красоты From 0eb57482d0ab9855c13d0698fb409aa8fe6674a9 Mon Sep 17 00:00:00 2001 From: none Date: Mon, 29 Jan 2024 01:39:57 +0300 Subject: [PATCH 2/6] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=BE=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5!=20?= =?UTF-8?q?=D0=A1=D0=BF=D0=B0=D1=81=D0=B8=D0=B1=D0=BE=20=D1=85=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=83=20=D0=A0=D0=B0=D0=B4=D0=B8=D1=83=D0=BC=D0=B0=20?= =?UTF-8?q?=D0=B7=D0=B0=20=D0=BF=D0=BE=D0=BC=D0=BE=D1=89=D1=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/style.css | 28 ++++++++++++++++++++++++++++ site.py | 24 +++++++++++++++++------- 2 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 assets/style.css diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 0000000..5a5e4d6 --- /dev/null +++ b/assets/style.css @@ -0,0 +1,28 @@ +body { + background-color: #242829; +} + +.Select { + background-color: rgb(27, 29, 30); + color: #fff; +} + +.Select .Select-value { + background-color: rgb(27, 29, 30); +} + +.Select-control { + background-color: rgb(25, 25, 25) !important; + color: #fff; +} + +.Select-menu-outer { + background-color: rgb(27, 29, 30); + color: #fff; + border-radius: 10; +} + + +.has-value.Select--single>.Select-control .Select-value .Select-value-label, .has-value.is-pseudo-focused.Select--single>.Select-control .Select-value .Select-value-label{ + color: white +} diff --git a/site.py b/site.py index 6cb1ef0..5bad8d6 100644 --- a/site.py +++ b/site.py @@ -19,14 +19,20 @@ def list_form(ll): 'chemicals': '🧪'} for i in ll: + if type(i) == int: + formatted.append(i) #print(db[i][1]) - if db[i][1] in imgs: + elif db[i][1] in imgs: +# formatted.append({"label": html.Span(f"{imgs[db[i][1]]} {i}", style={'background-color': 'rgb(27, 29, 30)', 'color': 'rgb(0,0,0)'}), +# 'value': f"{imgs[db[i][1]]} {i}"}) +# formatted.append(html.P(f"{imgs[db[i][1]]} {i}", style={'background-color': 'rgb(27, 29, 30)', 'color': 'rgb(0,0,0)'})) formatted.append(imgs[db[i][1]] + ' ' + i) else: formatted.append(i) return formatted +# 'background-color': 'rgb(27, 29, 30)', 'color': 'rgb(255,255,255)' app.layout = html.Div([ @@ -34,14 +40,15 @@ app.layout = html.Div([ html.Div([ # Реакция html.Div([ - dcc.Dropdown(list_form(els), id='reaction', placeholder="Реакция", maxHeight=500, style={'font-size': '120%'}) + dcc.Dropdown(list_form(els), id='reaction', placeholder="Реакция", maxHeight=500, + style={'font-size': '120%'}) #, 'background-color': 'rgb(27, 29, 30)'}) ], style={'flex': 4}), # Объём html.Div([ - dcc.Dropdown([30, 50, 100, 300, 1000], 100, id='amount', clearable=False, searchable=False - , style={'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) - ], style={'flex': 1, 'padding-left': 25}) + dcc.Dropdown(list_form([30, 50, 100, 300, 1000]), 100, id='amount', clearable=False, searchable=False + , style={'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) #, 'background-color': 'rgb(27, 29, 30)'}) + ], style={'flex': 1, 'padding-left': 25}) #, 'background-color': 'rgb(27, 29, 30)'}) ], style={'display': 'flex', 'flexDirection': 'row'}), @@ -50,6 +57,9 @@ html.Div([ ], style={'padding': '5%', 'margin-left': '30%', 'margin-right': '30%'}) +# vh - высота окна, vw - ширина окна +# +# 'background-color': '#242829', # padding - отступ # [#####] # margin - сужение @@ -78,11 +88,11 @@ def update_output(reaction, amount): result = [] for i in comps: result.append( html.Div(i + ': ' + str(comps[i]) -, style={'background-color': '#3f3b17', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) ) +, style={'background-color': 'rgb(213, 193, 86)', 'color': '#ffffff', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) ) # Выходное вещество result.append( html.Div(f'{reaction}: {res}' -, style={'background-color': '#183929', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) ) +, style={'background-color': 'rgb(61, 164, 113)', 'color': '#ffffff', 'margin-top': 10, 'border-radius': 10, 'padding': 15, 'font-family': '"Source Sans Pro", sans-serif', 'font-size': '120%'}) ) return result From 778238770a7e3cfce7c74dfe6d3dc6ab19b4ea6f Mon Sep 17 00:00:00 2001 From: none Date: Mon, 29 Jan 2024 22:13:50 +0300 Subject: [PATCH 3/6] =?UTF-8?q?=D0=AD=D0=BA=D1=81=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=BA=D1=80=D1=83=D0=B3=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calc.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/calc.py b/calc.py index d1856c1..5f0b35c 100644 --- a/calc.py +++ b/calc.py @@ -6,19 +6,67 @@ db = read_db() # Составные recipe = {} +''' # Функция для спец. округления # 16.666...8 => 15 def sround(num): num = floor(num) +# num = round(num) # Подмены rep = [[16,15], [33,30], [21,20], [12,10], [8,5], [6,5]] + if num == 0: + return 1 + for i in rep: if num == i[0]: + print('ПОДМЕНА: ', num) num = i[1] return num +''' + +def sround(num, parts): + acc = [1,2,3,4,5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100] + amount = num*parts + + # Ловим частые повторения + tries = 0 + + # Пока не вывели хорошее число + good = False + while not good: + num = floor(num) + print(good, ' ', num) + st = 1 ; good = True + # Перебираем различное количество частей + while st < parts: + # Если в допустимых значениях + if num*st in acc: + st += 1 + continue + + good = False + # Перебираем допустимые значения + for i in acc: + if abs(i - num*st) <= 2: + num = i + break + st += 1 + +# if num*parts > amount: +# num = num - 3 +# good = False + + # Ловим частые повторения + tries += 1 + if tries > 500: + return 0 + + print(num) + return num + def calc(el, amount, main = False): global db, recipe @@ -36,8 +84,8 @@ def calc(el, amount, main = False): # Делаем поправку на выход while out < parts: # Предварительная часть - part = sround(amount/parts) - print(el, ': ',out,' < ', parts) + part = sround(amount/parts, parts) + #print(el, ': ',out,' < ', parts) # Если итоговый объём <= входного объёма if (parts+1)*part <= amount: parts += 1 @@ -47,7 +95,7 @@ def calc(el, amount, main = False): # parts = out # Считаем 1 часть - part = sround(amount/parts) + part = sround(amount/parts, parts) # Перебираем составные и делаем рекурсию for i in comps: @@ -57,6 +105,7 @@ def calc(el, amount, main = False): # 50/3, часть = 16, ИТОГ: 16*3=48 < try: if lpart < part: + print("LPART: ",lpart) part = lpart except: pass @@ -80,3 +129,5 @@ def calc(el, amount, main = False): return part*parts #print( calc("Лексорин", 100, True)) +#print( calc("Бикаридин", 100, True)) +print( calc("Эфедрин", 100, True)) From b803125133db501d5b05632cf82744feb9260b30 Mon Sep 17 00:00:00 2001 From: none Date: Mon, 29 Jan 2024 23:20:42 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D1=81=D1=82=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=BA=D1=80=D1=83?= =?UTF-8?q?=D0=B3=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA?= =?UTF-8?q?=20=D0=BD=D0=B5=D0=BC=D1=83.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calc.py | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/calc.py b/calc.py index 5f0b35c..c2e0084 100644 --- a/calc.py +++ b/calc.py @@ -7,26 +7,6 @@ db = read_db() recipe = {} ''' -# Функция для спец. округления -# 16.666...8 => 15 -def sround(num): - num = floor(num) -# num = round(num) - - # Подмены - rep = [[16,15], [33,30], [21,20], [12,10], [8,5], [6,5]] - - if num == 0: - return 1 - - for i in rep: - if num == i[0]: - print('ПОДМЕНА: ', num) - num = i[1] - - return num -''' - def sround(num, parts): acc = [1,2,3,4,5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100] amount = num*parts @@ -55,18 +35,32 @@ def sround(num, parts): break st += 1 -# if num*parts > amount: -# num = num - 3 -# good = False - # Ловим частые повторения tries += 1 if tries > 500: - return 0 + return sround1(num, parts) + + if num*parts > amount: + return sround1(num, parts) - print(num) return num +''' + +def sround(num, parts): + acc = [1,2,3,4,5] + num = floor(num) + + if num in acc: + return num + elif num%5 == 0: + return num + elif num == 0: + return 1 + + while num%5 != 0: + num -= 1 + return num def calc(el, amount, main = False): global db, recipe @@ -130,4 +124,5 @@ def calc(el, amount, main = False): #print( calc("Лексорин", 100, True)) #print( calc("Бикаридин", 100, True)) -print( calc("Эфедрин", 100, True)) +#print( calc("Диловен", 100, True)) +#print( calc("Эфедрин", 100, True)) From b68d86e0a1f7cace942e73c722cdc6f088ea0cef Mon Sep 17 00:00:00 2001 From: none Date: Mon, 29 Jan 2024 23:23:33 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=D0=97=D0=B0=D0=B1=D1=8B=D0=BB=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?0=20=D0=BD=D0=B0=201=20=D0=B2=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B2=D0=B5=20=D0=B2=D0=B5=D1=89=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/calc.py b/calc.py index c2e0084..0976458 100644 --- a/calc.py +++ b/calc.py @@ -51,12 +51,12 @@ def sround(num, parts): acc = [1,2,3,4,5] num = floor(num) + if num == 0: + return 1 if num in acc: return num elif num%5 == 0: return num - elif num == 0: - return 1 while num%5 != 0: num -= 1 From 5b6da19331d0f5fc0071e3c3199d45ef14a0232f Mon Sep 17 00:00:00 2001 From: none Date: Mon, 29 Jan 2024 23:38:37 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=87=D1=91=D1=80=D0=BD=D1=8B=D0=B9=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=87=D1=91=D0=BD=D0=BE=D0=BC=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/style.css b/assets/style.css index 5a5e4d6..fbf6fc6 100644 --- a/assets/style.css +++ b/assets/style.css @@ -7,6 +7,10 @@ body { color: #fff; } +.Select-input > input { + color: #fff; +} + .Select .Select-value { background-color: rgb(27, 29, 30); }