h-1.flet.3/test_force_size.py
2026-02-20 23:24:01 +09:00

44 lines
1.2 KiB
Python

"""
強制ウィンドウサイズテスト
"""
import flet as ft
import time
def main(page: ft.Page):
page.title = "強制サイズテスト"
# 複数の方法で試す
page.window.width = 350
page.window.height = 700
page.window.resizable = False
page.window_center = True
print(f"設定値: {page.window.width} x {page.window.height}")
# 遅延してから再度設定
def delayed_resize():
time.sleep(0.5)
page.window.width = 350
page.window.height = 700
page.update()
print("遅延設定完了")
page.add(
ft.Column([
ft.Text("強制サイズテスト", size=18, weight=ft.FontWeight.BOLD),
ft.Text(f"設定: 350 x 700"),
ft.Text("表示は?"),
ft.Button("遅延リサイズ", on_click=lambda _: delayed_resize()),
ft.Container(
content=ft.Text("テストコンテンツ", color=ft.Colors.WHITE),
bgcolor=ft.Colors.BLUE,
padding=15,
width=300,
height=100
)
], spacing=10)
)
if __name__ == "__main__":
ft.run(main)