Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Deleting a key from Session State WILL ~~not~~ revert the widget to a default value

オープン 初心者向け
#1,489 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
64/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
documentation

調査の方向性

ウィジェットの動作に関するドキュメントページから始め、提供されている Python スニペットを Streamlit で再現します。観測したリセットを、st.session_state からキーを削除することについての現在の記述と比較します。ページが動作を正確に説明し、その例がドキュメントに記載された結果と矛盾しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

docs needs triage

The following statement in the docs dont seem to be true to me. I cant replicate the behaviour stated.

Doc Page: https://docs.streamlit.io/develop/concepts/architecture/widget-behavior
"

Calling a widget command when the widget already exists

When rerunning a script without changing a widget's identity:

Streamlit will connect to the existing frontend and backend parts.
If the widget has a key that was deleted from st.session_state, then Streamlit will recreate the key using the current frontend value. This is because deleting a key from Session State will not revert the widget to a default value.
The widget command will return the current value of the widge
"

Here is the code I used to replicate the stated behaviour:
"

import streamlit as st

st.title("Streamlit Widget Behavior Demo")

if "my_slider" in st.session_state:
del st.session_state["my_slider"]

Initialize a widget with a key.,

current_val = st.slider("Move this slider:", min_value=0, max_value=100, value=0, key="my_slider")

Display the current state

st.write(f"The widget command returned: {current_val}")
st.write("Current st.session_state contents:", st.session_state.to_dict())

"

The widget command does return the default value if the related key is deleted beforehand.
Please explain to me why this is the case if I misunderstodd the docs.

主要言語
JavaScript
スター
178
フォーク
711
平均マージ
1日 21時間
マージ済み PR(30日)
19

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

streamlit/docs のほかの issue

streamlit/docs の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。