English 中文(简体)
• 如何将申请页打印成国防军档案?
原标题:How to Print Streamlit App Pages into a PDF file?

我下面的这个简单例子在@MathCatsAnd的帮助下创立。 每一页<代码><>>>有多个数据基,每个网页仅显示一个<编码>数据框架>。 我谨以标准11x8.5纸张尺寸将每个<代码>(有多个数据机)打印到一个pdf文档。 我想能够把纸张宽度中的26栏和长效的数值放在多页上,因为下几页是继续使用。 你是否有任何建议?

import streamlit as st
import pandas as pd
import numpy as np

# Initialize session state with dataframes
# Include initialization of "edited" slots by copying originals
if  df1  not in st.session_state:
    st.title("**:blue[Title123]**")
    Nvals = 200
    rows = [ a{} .format(i) for i in range(1, Nvals+1)] # a1:a19
    values = np.arange(Nvals)
    st.session_state.df1 = pd.DataFrame({
        "rows/cols": rows, 
         A : list(range(Nvals)),  B : list(range(Nvals)),  C : list(range(Nvals)),  D : list(range(Nvals)),  E : list(range(Nvals)),
         F : list(range(Nvals)),  G : list(range(Nvals)),  H : list(range(Nvals)),  I : list(range(Nvals)),  J : list(range(Nvals)),
         K : list(range(Nvals)),  L : list(range(Nvals)),  M : list(range(Nvals)),  N : list(range(Nvals)),  Q : list(range(Nvals)),
         O : list(range(Nvals)),  P : list(range(Nvals)),  R : list(range(Nvals)),  S : list(range(Nvals)),  T : list(range(Nvals)),
         U : list(range(Nvals)),  V : list(range(Nvals)),  W : list(range(Nvals)),  X : list(range(Nvals)),  Y : list(range(Nvals)),  Z : list(range(Nvals)),
    })
    st.session_state.edited_df1 = st.session_state.df1.copy()
    #
    st.session_state.df2 = pd.DataFrame({
        "col1": ["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10"], 
        "Values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        "col2": ["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10"], 
        "Values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        "col3": ["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10"], 
        "Values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    })
    st.session_state.edited_df2 = st.session_state.df2.copy()

# Save edits by copying edited dataframes to "original" slots in session state
def on_change_callback_fcn():
    st.session_state.df1 = st.session_state.edited_df1 
    st.session_state.df2 = st.session_state.edited_df2

# Sidebar to select page and commit changes upon selection
page = st.sidebar.selectbox("Select: ", ("A","B"), on_change=on_change_callback_fcn, key= SelectedSelectboxVal ) 
# Convenient shorthand notation used below in funct1 and funct2
def funct1():
    st.session_state.edited_df1 = st.data_editor(st.session_state.df1, num_rows="dynamic",height=10*len(st.session_state.edited_df1)) 

def funct2():
    st.session_state.edited_df2 = st.data_editor(st.session_state.df2, num_rows="dynamic")

if  page == "A":
    st.header("Page A")
    funct1()
elif page == "B":
    st.header("Page B")
    funct2()

print( 
 ...................... 
 Entire Code Ran 
 ...................... 
 )
print(len(st.session_state.edited_df1))

<代码>Ctrl+Pt=t work。 我没有找到这方面的许多在线材料。

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签