2021年9月26日日曜日

PySimpleGUIでフレーム要素の上下左右のスペースを指定する

PySimpleGUIでフレーム要素の上下左右のスペースを指定するには、padパラメータに((left, right), (top, bottom))の形式のタプルを渡します。

〇サンプル実行手順
以下のファイルを保存して、実行します。
frame_pad.py
import PySimpleGUI as sg

left=10
right=20
top=30
bottom=40
sg.theme('SystemDefault')
frame_layout = [
  [ sg.Text('Frameサンプル') ]
]
layout = [
  [
    sg.Frame(title="Frame1",  layout=frame_layout, pad=((left, right), (top, bottom)))
  ]
]

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

window.close()

実行コマンド
python frame_pad.py

〇実行結果

関連情報

PySimpleGUIでフレーム要素のタイトルを指定する

PySimpleGUIでフレーム要素のツールチップを設定する

PySimpleGUIでフレーム要素の境界線の太さを指定する

PySimpleGUIでフレーム要素のタイトルのフォントを指定する

PySimpleGUIでフレーム要素の線の種類を指定する

PySimpleGUIでフレーム要素のタイトル位置を指定する

PySimpleGUIでフレーム要素のタイトル色・背景色を指定する

・PySimpleGUIに関する他の記事はこちらを参照してください。

0 件のコメント:

コメントを投稿