lang:python:wxpython:sizer
差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン | ||
lang:python:wxpython:sizer [2025/08/17 07:11] – 作成 editor | lang:python:wxpython:sizer [2025/08/17 07:57] (現在) – [自動サイズ調整] editor | ||
---|---|---|---|
行 5: | 行 5: | ||
* wx.FrexGridSizer | * wx.FrexGridSizer | ||
- | 配置の例: | + | ---- |
+ | ===== BoxSizer | ||
<file python sizer.py> | <file python sizer.py> | ||
行 82: | 行 83: | ||
</ | </ | ||
+ | |||
+ | ===== 自動サイズ調整 ===== | ||
+ | wx.EXPAND でサイズ調整される | ||
+ | |||
+ | layout = wx.BoxSizer(wx.HORIZONTAL) | ||
+ | layout.Add(button, | ||
+ | # 0: サイズ変更なし | ||
+ | # 1: 自動調整あり。数字は、比率。 | ||
+ | |||
+ | <file python sizer2.py> | ||
+ | import os | ||
+ | import sys | ||
+ | import wx | ||
+ | |||
+ | class Panel(wx.Panel) : | ||
+ | def __init__(self, | ||
+ | wx.Panel.__init__(self, | ||
+ | | ||
+ | button4 = wx.Button(self, | ||
+ | layout = wx.BoxSizer(wx.HORIZONTAL) | ||
+ | layout.Add(button4, | ||
+ | self.SetSizer(layout) | ||
+ | | ||
+ | class TopPanel(wx.Panel) : | ||
+ | def __init__(self, | ||
+ | wx.Panel.__init__(self, | ||
+ | | ||
+ | button1 = wx.Button(self, | ||
+ | button2 = wx.Button(self, | ||
+ | button3 = wx.Button(self, | ||
+ | p = Panel(self, wx.ID_ANY) | ||
+ | | ||
+ | layout = wx.BoxSizer(wx.VERTICAL) | ||
+ | layout.Add(button1, | ||
+ | layout.Add(button2, | ||
+ | layout.Add(button3, | ||
+ | |||
+ | layout.Add(p, | ||
+ | |||
+ | self.SetSizer(layout) | ||
+ | |||
+ | |||
+ | class MainFrame(wx.Frame) : | ||
+ | def __init__(self, | ||
+ | super().__init__(None, | ||
+ | | ||
+ | topPanel = TopPanel(self) | ||
+ | layout = wx.BoxSizer(wx.VERTICAL) | ||
+ | layout.Add(topPanel, | ||
+ | self.SetSizer(layout) | ||
+ | | ||
+ | self.SetSize(500, | ||
+ | self.SetMinSize((100, | ||
+ | self.Center(wx.BOTH) | ||
+ | self.Show() | ||
+ | |||
+ | def main() : | ||
+ | |||
+ | app = wx.App() | ||
+ | MainFrame() | ||
+ | app.MainLoop() | ||
+ | return | ||
+ | |||
+ | if __name__ == ' | ||
+ | main() | ||
+ | |||
+ | </ | ||
+ | |||
lang/python/wxpython/sizer.1755414695.txt.gz · 最終更新: by editor