2021年3月4日木曜日

PySimpleGUIで入力フィールド要素の初期値を指定する

PySimpleGUIで入力フィールド要素の初期値を指定するには、default_textパラメータを指定します。

サンプル実行手順

以下のファイルを保存して、実行します。

 input_default_text.py

import PySimpleGUI as sg

sg.theme('SystemDefault')
layout = [[sg.Input(default_text='初期値' )]]

window = sg.Window('サンプル', layout)
# イベントループ
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED:
        break

window.close()

実行コマンド
python input_default_text.py

〇実行結果

関連情報

PySimpleGUIで入力フィールドのフォント・フォントサイズを指定する

PySimpleGUIで入力フィールドの文字色と背景色を指定する

PySimpleGUIでパスワード入力フィールドのマスク文字を指定する

PySimpleGUIで入力フィールド要素の幅を指定する

PySimpleGUIで入力フィールド要素のパディングを指定する

PySimpleGUIで入力フィールド要素を左寄せ・中央寄せ・右寄せに設定する

PySimpleGUIで入力フィールド要素を読取専用に設定する

0 件のコメント:

コメントを投稿