Skip to content

Commit

Permalink
check with 1.34.0, added Window_executable.py, remove not .md emojies
Browse files Browse the repository at this point in the history
  • Loading branch information
Arslan committed May 8, 2024
1 parent e89fa24 commit 131bfb5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 16 deletions.
7 changes: 0 additions & 7 deletions pages/2_📖_Build_App.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,4 @@
### Complex workflow using TOPP tools
This template app features a module in `src/workflow` that allows for complex and long workflows to be built very efficiently. Check out the `TOPP Workflow Framework` page for more information (on the *sidebar*).
## How to package everything for window executables
This guide explains how to package streamlit apps into Windows executables using two different methods:
- [window executable with pyinstaller](https://github.com/OpenMS/streamlit-template/blob/main/win_exe_with_pyinstaller.md)
- [window executable with embeddable python](https://github.com/OpenMS/streamlit-template/blob/main/win_exe_with_embed_py.md)
""")
78 changes: 78 additions & 0 deletions pages/4_📖_Windows_executable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import streamlit as st
import requests

import streamlit as st

# Define CSS styles
css = '''
<style>
/* Add space between tabs */
.stTabs [data-baseweb="tab-list"] button {
margin-right: 20px;
border-radius: 5px;
transition: background-color 0.3s ease, color 0.3s ease; /* Add smooth transition */
}
/* Style active tab */
.stTabs [data-baseweb="tab-list"] button:focus {
background-color: #f0f0f0; /* Change background color of active tab */
color: #333333; /* Change text color of active tab */
border-width: 3px; /* Increase thickness of blue line */
}
/* Style tab text */
.stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
font-size: 2rem;
font-weight: bold;
}
/* Add hover effect */
.stTabs [data-baseweb="tab-list"] button:hover {
background-color: #f8f8f8; /* Change background color on hover */
}
</style>
'''


st.markdown(css, unsafe_allow_html=True)

st.markdown("""
# 💻 How to package everything for window executables
This guide explains how to package streamlit apps into Windows executables using two different methods:
""")

def fetch_markdown_content(url):
response = requests.get(url)
if response.status_code == 200:
# Remove the first line from the content
content_lines = response.text.split("\n")
markdown_content = "\n".join(content_lines[1:])
return markdown_content
else:
return None

tabs = ["window executable with embeddable python", "window executable with pyinstaller"]
tabs = st.tabs(tabs)

# window executable with embeddable python
with tabs[0]:
markdown_url = "https://raw.githubusercontent.com/Arslan-Siraj/streamlit-template/main/win_exe_with_embed_py.md"

markdown_content = fetch_markdown_content(markdown_url)

if markdown_content:
st.markdown(markdown_content, unsafe_allow_html=True)
else:
st.error("Failed to fetch Markdown content from the specified URL.", markdown_url)

# window executable with pyinstaller
with tabs[1]:
# URL of the Markdown document
markdown_url = "https://raw.githubusercontent.com/Arslan-Siraj/streamlit-template/main/win_exe_with_pyinstaller.md"

markdown_content = fetch_markdown_content(markdown_url)

if markdown_content:
st.markdown(markdown_content, unsafe_allow_html=True)
else:
st.error("Failed to fetch Markdown content from the specified URL. ", markdown_url)


File renamed without changes.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# the requirements.txt file is intended for deployment on streamlit cloud and if the simple container is built
# note that it is much more restricted in terms of installing third-parties / etc.
# preferably use the batteries included or simple docker file for local hosting
streamlit==1.33.0
streamlit==1.34.0
streamlit-plotly-events==0.0.6
streamlit-aggrid==0.3.4.post3
pandas==2.1.2
Expand Down
3 changes: 1 addition & 2 deletions win_exe_with_embed_py.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ Install all required packages from `requirements.txt`:

#### 🚀 <code> After successfully completing all these steps, the Streamlit app will be available by running the run_app.bat file.</code>

> [!NOTE]
You can still change the configuration of Streamlit app with .streamlit/config.toml file, e.g., provide a different port, change upload size, etc.
:pencil: You can still change the configuration of Streamlit app with .streamlit/config.toml file, e.g., provide a different port, change upload size, etc.

## Build executable in github action automatically
Automate the process of building executables for your project with the GitHub action example [Test streamlit executable for Windows with embeddable python](https://github.com/OpenMS/streamlit-template/blob/main/.github/workflows/test-win-exe-w-embed-py.yaml)
Expand Down
9 changes: 3 additions & 6 deletions win_exe_with_pyinstaller.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
:heavy_check_mark:
Tested with streamlit v1.29.0, python v3.11.4</br>

> [!WARNING]
Support until streamlit version `1.29.0` </br>
:warning: Support until streamlit version `1.29.0` </br>
:point_right: For higher version, try streamlit app with embeddable python #TODO add link

To create an executable for Streamlit app on Windows, we'll use an pyinstaller.</br>
Expand Down Expand Up @@ -126,11 +125,9 @@ pyinstaller run_app.spec --clean
```
#### 🚀 <code> After successfully completing all these steps, the Windows executable will be available in the dist folder.</code>

> [!NOTE]
you can still change the configuration of streamlit app with .streamlit/config.toml file e-g provide different port, change upload size etc
:pencil: you can still change the configuration of streamlit app with .streamlit/config.toml file e-g provide different port, change upload size etc

> [!TIP]
> if problem with altair, Try version altair==4.0.1, and again compile
ℹ️ if problem with altair, Try version altair==4.0.1, and again compile

## Build executable in github action automatically
Automate the process of building executables for your project with the GitHub action example [Test streamlit executable for Windows with pyinstaller](https://github.com/OpenMS/streamlit-template/blob/main/.github/workflows/test-win-exe-w-pyinstaller.yaml)
Expand Down

0 comments on commit 131bfb5

Please sign in to comment.