From 06944c9dcd4c9bef226af8fef4ca7dd4fef507ca Mon Sep 17 00:00:00 2001 From: none Date: Wed, 24 Jan 2024 12:39:30 +0300 Subject: [PATCH] Init files --- db.py | 19 +++++++++++++++++++ site.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 db.py create mode 100644 site.py diff --git a/db.py b/db.py new file mode 100644 index 0000000..5074580 --- /dev/null +++ b/db.py @@ -0,0 +1,19 @@ +import os +import json + +if not os.path.exists('db.json'): + db = {} + js = json.dumps(db, indent=2) + with open("db.json", "w") as outfile: + outfile.write(js) + print('Created new db.json') + + +def read_db(): + with open('db.json', 'r') as openfile: + db = json.load(openfile) + return db +def write_db(db): + js = json.dumps(db, indent=2) + with open("db.json", "w") as outfile: + outfile.write(js) diff --git a/site.py b/site.py new file mode 100644 index 0000000..d3b8fbc --- /dev/null +++ b/site.py @@ -0,0 +1,52 @@ +import streamlit as st + +df = { + 'first column': [1, 2, 3, 4], + 'second column': [10, 20, 30, 40] +} + +## LOAD DB ## + +#{ +# "Бикаридин": [0, [0, "Углерод", 1], [1, "Инапровалин"] ], +# "Инапровалин": [0, [0, "Кислород", 1], [0, "Сахар", 1], [0, "Углерод", 1] ] +#} +# Тип Название Часть (1 к 1) +# +# 0 - без нагрева и т.п., 1 - зависит от того-то +# +# 100 = 50 углерод + 50 инапровалин = +# = 50 углерод + round(50/3) * составные +# = 50 углерод + 16 кислород + 16 сахар + 16 углерод +# !!! 50 != 48 => делаем 48 !!! +# = 48 углерод + 16 кислород + 16 сахар + 16 углерод +# = 96 бикаридин +# +# Список составных: ["Кислород", "Сахар", "Углерод"] + +############# + + +# Set columns +react, star, amount = st.columns([73, 7, 20]) + +with react: + option = st.selectbox( + label = '0', + options = df['first column'], + index = None, + placeholder = 'Реакция', + label_visibility = 'collapsed' + ) + +with star: + st.button(':orange[:star:]') + +with amount: + option = st.selectbox( + label = '0', + options = [100], + index = 0, + placeholder = 'Объём', + label_visibility = 'collapsed' + )