实时变化的流程图-streamlit系列

实时变化的流程图

import streamlit as st
import graphviz

if 'num' not in st.session_state:
    st.session_state.num = "1"

def update2():
    st.session_state.num = "2"

def update3():
    st.session_state.num = "3"

st.write(st.session_state.num)
st.button("Perform calculation 2", on_click=update2, key='key_2')
st.button("Perform calculation 3", on_click=update3, key='key_3')

graph= graphviz.Digraph(graph_attr={'rankdir':'LR'})
graph.edge(f'3', '12 ', label='3*4')
graph.edge(f'4', '12 ', label='4*3')
graph.edge('12 ', '12', label='max(0,12)')
graph.edge('12', '60', label='12*5')
graph.edge(st.session_state.num, '60', label='5*12')
graph.edge('60', '1600', label='(100 - 60)**2')

#red arrows

graph.edge('1600', '60', label='2*(100 - 60)=80', color='red')
graph.edge('60', '12', label='5*80=400', color='red',)
graph.edge('60', st.session_state.num, label='12*80=960', color='red')
graph.edge('12', '12 ', label='1*400=400', color='red')
graph.edge('12 ', '3', label='400*4=1600', color='red')
graph.edge('12 ', '4', label='400*3=1200', color='red')

st.graphviz_chart(graph)

销售查询

from streamlit_option_menu import option_menu
import pandas as pd
import streamlit as st
from st_aggrid import AgGrid
from st_aggrid.grid_options_builder import GridOptionsBuilder
from st_aggrid.shared import ColumnsAutoSizeMode
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode
import streamlit.components.v1 as components

custom_css = {
    ".ag-row-hover": {"background-color": "#98FB98 !important"},
    ".ag-row-odd": {"background-color": "#FFF8DC"},
    ".ag-row-even": {"background-color": "#D2B48C"},
    ".ag-root-wrapper": {"border": "3px solid #98FB98"},
    ".ag-header": {"background-color": "#2c2d30"},
    ".ag-status-bar": {"background-color": "#232323"},
    ".ag-right-cols-container": {"background-color": "#98FB98"},
    ".ag-side-buttons": {"background-color": "#2c2d30"},
    ".ag-paging-panel": {"background-color": "#98FB98"},
    ".ag-root": {"background-color": "#98FB98"},
    ".ag-cell-focus .ag-cell-value": {"background-color": "#4895ef !important"},
    ".ag-root": {"background-color": "#98FB98"},
    ".ag-cell-focus .ag-cell-value": {"background-color": "#4895ef !important"},
    ".ag-row-selected": {"color": "#4895ef !important"},
    ".ag-theme-streamlit": {'transform': "scale(0.8)", "transform-origin": '0 0'}
}

components.iframe("https://www.mixdiy.com/",650,800)


df = pd.read_excel(r"C:\Users\1\Downloads\ab.xls")

#gb = GridOptionsBuilder.from_dataframe(df, min_column_width=100)
#AgGrid(df, gridOptions=gb.build(), fit_columns_on_grid_load=True)

other_options = {'suppressColumnVirtualisation': True}
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_pagination(paginationAutoPageSize=True)
gb.configure_grid_options(**other_options)
gridOptions = gb.build()
AgGrid(df,gridOptions,columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS,custom_css=custom_css)
hide_streamlit_style = """
                        <style>
                        #MainMenu {visibility: hidden;}
                        footer {visibility: hidden;}
                        </style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)