remove streamlit as gui

This commit is contained in:
2023-07-25 17:44:59 +02:00
parent b2f166d232
commit e3bd42a19d
8 changed files with 499 additions and 124 deletions
+1 -47
View File
@@ -90,53 +90,7 @@ def set_pixels(color):
# @click.option("-v", help="Set HEX Color as base visualizer color: -v ffffff")
def main(arg):
if arg == ():
# proc = subprocess.Popen(["python", "-m", "streamlit", "run", "/var/lib/lc/gui.py", "--server.headless", "True", "--theme.base", "dark", "--theme.primaryColor", "#9f0000", "--theme.backgroundColor", "#181a1b", "--theme.secondaryBackgroundColor", "#1f2123", "--theme.textColor", "#c4c0b8"], stdout=subprocess.PIPE)
# for line in proc.stdout:
# if line == b' You can now view your Streamlit app in your browser.\n':
# break
import streamlit.web.bootstrap as bootstrap
from streamlit import config
import gui as gui
di = {'global_disableWatchdogWarning': None, 'global_showWarningOnDirectExecution': None, 'global_developmentMode': None, 'global_logLevel': None, 'global_unitTest': None, 'global_suppressDeprecationWarnings': None, 'global_minCachedMessageSize': None, 'global_maxCachedMessageAge': None, 'global_dataFrameSerialization': None, 'logger_level': None, 'logger_messageFormat': None, 'logger_enableRich': None, 'client_caching': None, 'client_displayEnabled': None, 'client_showErrorDetails': None, 'runner_magicEnabled': None, 'runner_installTracer': None, 'runner_fixMatplotlib': None, 'runner_postScriptGC': None, 'runner_fastReruns': None, 'server_folderWatchBlacklist': None, 'server_fileWatcherType': None, 'server_cookieSecret': None, 'server_headless': True, 'server_runOnSave': None, 'server_allowRunOnSave': None, 'server_address': None, 'server_port': None, 'server_scriptHealthCheckEnabled': None, 'server_baseUrlPath': None, 'server_enableCORS': None, 'server_enableXsrfProtection': None, 'server_maxUploadSize': None, 'server_maxMessageSize': None, 'server_enableWebsocketCompression': None, 'browser_serverAddress': None, 'browser_gatherUsageStats': None, 'browser_serverPort': None, 'ui_hideTopBar': None, 'ui_hideSidebarNav': None, 'mapbox_token': None, 'deprecation_showfileUploaderEncoding': None, 'deprecation_showImageFormat': None, 'deprecation_showPyplotGlobalUse': None, 'theme_base': None, 'theme_primaryColor': None, 'theme_backgroundColor': None, 'theme_secondaryBackgroundColor': None, 'theme_textColor': None, 'theme_font': None}
import multiprocessing
def run():
config.set_option('server.headless', True)
bootstrap.run(gui.__file__, 'streamlit run gui.py --server.headless True', [], di)
p = multiprocessing.Process(target=run)
p.start()
# import requests
# while True:
# try:
# print(requests.get('http://localhost:8501'))
# except:
# continue
# print('asdf')
# break
# cli.main_run(str(gui.__file__))
# from streamlit.web.server import Server
# server = Server(gui.__file__, 'streamlit run gui.py --server.headless True')
# import tornado.web
# class MainHandler(tornado.web.RequestHandler):
# def get(self):
# self.write("Hello, world")
# application = tornado.web.Application([
# (r"/", ), ])
# application.listen(8888)
webview.create_window('LED Control', application)
webview.start()
# proc.terminate()
exit()
pass
match arg[0]:
case "help":
-75
View File
@@ -1,75 +0,0 @@
def main():
import streamlit as st
import controller
import colorsys
import pickle
import os
from PIL import Image
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
def hex_to_rgb(hex):
r = int(hex[1:3],16)
g = int(hex[3:5],16)
b = int(hex[5:7],16)
return r,g,b
def rgb_to_hex(r,g,b):
return "#" + hex(r)[2:].zfill(2) + hex(g)[2:].zfill(2) + hex(b)[2:].zfill(2)
def load_config():
try:
path = os.path.expanduser("~/.config/lc/lc.dmp")
with open(path, 'rb') as f:
return pickle.load(f)
except FileNotFoundError:
return {'color': '000000', 'saved': []}
def save(conf):
path = os.path.expanduser("~/.config/lc/lc.dmp")
with open(path, 'wb') as f:
pickle.dump(conf, f)
def add_to_conf():
st.session_state.config['saved'].append(color)
if 'config' not in st.session_state:
init = 1
st.session_state.config = load_config()
color = st.session_state.config['color']
st.title("LED Control")
# r = st.slider("Red", 0, 255, 0)
# g = st.slider("Green", 0, 255, 0)
# b = st.slider("Blue", 0, 255, 0)
h = st.slider("Hue", 0.0, 1.0, 0.0, 0.01)
s = st.slider("Saturation", 0.0, 1.0, 0.0, 0.01)
v = st.slider("Value", 0.0, 1.0, 0.0, 0.01)
r,g,b = colorsys.hsv_to_rgb(h,s,v)
color = rgb_to_hex(int(r * 255),int(g * 255),int(b * 255))
st.session_state.config['color'] = color[1:]
save(st.session_state.config)
#controller.set_pixels(color[1:])
img = Image.new(mode="RGB", size=(30,30), color=(int(r * 255),int(g * 255),int(b * 255)))
st.subheader(color)
st.image(img)
st.button("Save Color", add_to_conf)
st.session_state.config['saved']
if __name__ == "__main__":
main()
+53 -2
View File
@@ -1,3 +1,54 @@
altair==5.0.1
altgraph==0.17.3
attrs==23.1.0
blinker==1.6.2
bottle==0.12.25
cachetools==5.3.1
certifi==2023.5.7
charset-normalizer==3.1.0
click==8.1.3
pywebview==3.7.2
streamlit==1.17.0
decorator==5.1.1
gitdb==4.0.10
GitPython==3.1.31
idna==3.4
importlib-metadata==6.7.0
Jinja2==3.1.2
jsonschema==4.17.3
markdown-it-py==3.0.0
MarkupSafe==2.1.3
mdurl==0.1.2
numpy==1.25.0
packaging==23.1
pandas==2.0.3
Pillow==9.5.0
protobuf==4.23.3
proxy-tools==0.1.0
pyarrow==12.0.1
pycairo==1.24.0
pydeck==0.8.1b0
Pygments==2.15.1
PyGObject==3.44.1
pyinstaller==5.13.0
pyinstaller-hooks-contrib==2023.4
Pympler==1.0.1
pyrsistent==0.19.3
python-dateutil==2.8.2
pytz==2023.3
pytz-deprecation-shim==0.1.0.post0
pywebview==4.2.2
requests==2.31.0
rich==13.4.2
six==1.16.0
smmap==5.0.0
streamlit==1.24.0
tenacity==8.2.2
toml==0.10.2
toolz==0.12.0
tornado==6.3.2
typing_extensions==4.7.0
tzdata==2023.3
tzlocal==4.3.1
urllib3==2.0.3
validators==0.20.0
watchdog==3.0.0
zipp==3.15.0