This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wait for ICE gathering to complete | |
return new Promise(function(resolve) { | |
if (pc.iceGatheringState === 'complete') { | |
resolve(); | |
} else { | |
function checkState() { | |
if (pc.iceGatheringState === 'complete') { | |
pc.removeEventListener('icegatheringstatechange', checkState); | |
resolve(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def my_widget(key): | |
st.subheader('Hello there!') | |
clicked = st.button("Click me " + key) | |
# This works in the main area | |
clicked = my_widget("first") | |
# And within an expander | |
my_expander = st.beta_expander("Expand", expanded=True) | |
with my_expander: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_expander = st.beta_expander() | |
with my_expander: | |
'Hello there!' | |
clicked = st.button('Click me!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_expander = st.beta_expander() | |
my_expander.write('Hello there!') | |
clicked = my_expander.button('Click me!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
st.title("Let's create a table!") | |
for i in range(1, 10): | |
cols = st.beta_columns(4) | |
cols[0].write(f'{i}') | |
cols[1].write(f'{i * i}') | |
cols[2].write(f'{i * i * i}') | |
cols[3].write('x' * i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
from PIL import Image | |
image = st.file_uploader("Select an image!") | |
col1, col2 = st.beta_columns(2) | |
original = Image.open(image) | |
col1.header("Original") | |
col1.image(original, use_column_width=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defonce counter (atom 0)) | |
(defn increment-counter [] | |
(swap! counter inc) | |
(send-message-to-streamlit :set-component-value {:value @counter})) | |
(defn app [] | |
[:button {:on-click increment-counter} "Click Me!"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private onClicked = (): void => { | |
this.setState( | |
prevState => ({ numClicks: prevState.numClicks + 1 }), | |
() => Streamlit.setComponentValue(this.state.numClicks) | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public render = (): ReactNode => { | |
return ( | |
<span> | |
Hello, {this.props.args["name"]}! | |
<button onClick={this.onClicked} disabled={this.props.disabled}> | |
Click Me! | |
</button> | |
</span> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def github_gist(gist_creator, gist_id, height=600, scrolling=True): | |
components.html( | |
f""" | |
<script src="https://gist.github.com/{gist_creator}/{gist_id}.js"> | |
</script> | |
""", | |
height=height, | |
scrolling=scrolling, | |
) |
NewerOlder