ユーザ用ツール

サイト用ツール


lang:python:wxpython:sizer

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
lang:python:wxpython:sizer [2025/08/17 07:11] – 作成 editorlang: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:
  
 </file> </file>
 +
 +===== 自動サイズ調整 =====
 +wx.EXPAND でサイズ調整される
 +
 +  layout = wx.BoxSizer(wx.HORIZONTAL)
 +  layout.Add(button, 1, wx.EXPAND)
 +  # 0: サイズ変更なし
 +  # 1: 自動調整あり。数字は、比率。
 +
 +<file python sizer2.py>
 +import os
 +import sys
 +import wx
 +
 +class Panel(wx.Panel) :
 +    def __init__(self, parent, *args, **kwargs) :
 +        wx.Panel.__init__(self, parent, wx.ID_ANY)
 +        
 +        button4 = wx.Button(self, wx.ID_ANY, 'only vertical exapnd', name='button4', size=(200, 50))
 +        layout = wx.BoxSizer(wx.HORIZONTAL)
 +        layout.Add(button4, 0, wx.EXPAND)
 +        self.SetSizer(layout)
 +        
 +class TopPanel(wx.Panel) :
 +    def __init__(self, parent, *args, **kwargs) :
 +        wx.Panel.__init__(self, parent, wx.ID_ANY)
 +        
 +        button1 = wx.Button(self, wx.ID_ANY, 'ogriginal Size', name='button1', size=(200, 50))
 +        button2 = wx.Button(self, wx.ID_ANY, 'both vertical and horizontal expand', name='button2', size=(200, 50))
 +        button3 = wx.Button(self, wx.ID_ANY, 'only horizontal exapnd', name='button3', size=(200, 50))
 +        p = Panel(self, wx.ID_ANY)
 +        
 +        layout = wx.BoxSizer(wx.VERTICAL)
 +        layout.Add(button1, 0)
 +        layout.Add(button2, 1, flag=wx.EXPAND)        
 +        layout.Add(button3, 0, flag=wx.EXPAND)        
 +
 +        layout.Add(p, 1, flag=wx.EXPAND)        
 +
 +        self.SetSizer(layout)
 +
 +
 +class MainFrame(wx.Frame) :
 +    def __init__(self, *args, **kwargs) :
 +        super().__init__(None, title="exFrame", **kwargs)
 +        
 +        topPanel = TopPanel(self)
 +        layout = wx.BoxSizer(wx.VERTICAL)
 +        layout.Add(topPanel, 1, flag=wx.EXPAND)
 +        self.SetSizer(layout)
 +        
 +        self.SetSize(500,500)
 +        self.SetMinSize((100, 100))
 +        self.Center(wx.BOTH)
 +        self.Show()
 +
 +def main() :
 +
 +    app = wx.App()
 +    MainFrame()
 +    app.MainLoop()
 +    return
 +
 +if __name__ == '__main__' :
 +    main()
 +
 +</file>
 +
  
lang/python/wxpython/sizer.1755414695.txt.gz · 最終更新: by editor

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki