python PySimpleGUIでラジオボタンの幅と高さを設定する

pythonで、ライブラリPySimpleGUIを使用して、ラジオボタンの幅と高さを設定するサンプルコードを記述してます。pythonのバージョンは3.8.5を使用してます。
環境
- OS windows10 pro 64bit
- python 3.8.5
PySimpleGUIインストール
PySimpleGUIをインストールされていない方は、pipでインストールしておきます。
PySimpleGUI
<出力結果>
Collecting PySimpleGUI
Downloading PySimpleGUI-4.41.2-py3-none-any.whl (348 kB)
|████████████████████████████████| 348 kB 1.3 MB/s
Installing collected packages: PySimpleGUI
Successfully installed PySimpleGUI-4.41.2
幅と高さを設定
ラジオボタンの幅と高さは「size」で指定することが可能です。
import PySimpleGUI as sg
sg.Radio(text='radio', size=(幅,高さ))
以下は、ラジオボタンの幅と高さを指定したサンプルコードとなります。
import PySimpleGUI as sg
# ウィンドウのテーマ
sg.theme('LightTeal')
# 幅と高さ
width = 25
height = 25
# ウィンドウのレイアウト
layout = [
[sg.Radio(text='radio1radio1radio1radio1radio1', group_id='1', size=(width,height))],
[sg.Radio(text='radio2radio2radio2radio2radio2radio2', group_id='1', size=(width,height))],
[sg.Radio(text='radio3radio3radio3radio3radio3radio3radio3', group_id='1', size=(width,height))]
]
# ウィンドウオブジェクトの作成
window = sg.Window('title', layout, size=(300, 300))
# イベントのループ
while True:
# イベントの読み込み
event, values = window.read()
# ウィンドウの×ボタンクリックで終了
if event == sg.WIN_CLOSED:
break
# ウィンドウ終了処理
window.close()
実行結果

-
前の記事
javascript lodashを使って文字実体参照に変換する 2022.02.03
-
次の記事
VSCODE 連番で入力する 2022.02.03
コメントを書く