Skip to content

Instantly share code, notes, and snippets.

// 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();
}
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:
my_expander = st.beta_expander()
with my_expander:
'Hello there!'
clicked = st.button('Click me!')
my_expander = st.beta_expander()
my_expander.write('Hello there!')
clicked = my_expander.button('Click me!')
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)
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)
(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!"]
private onClicked = (): void => {
this.setState(
prevState => ({ numClicks: prevState.numClicks + 1 }),
() => Streamlit.setComponentValue(this.state.numClicks)
)
}
public render = (): ReactNode => {
return (
<span>
Hello, {this.props.args["name"]}! &nbsp;
<button onClick={this.onClicked} disabled={this.props.disabled}>
Click Me!
</button>
</span>
)
}
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,
)