サイザーを極めたい(きれいにコントロールを並べる)

今の私にとっては、パネルの中できれいにコントロールを配置することは非常に難しい課題だ。絶対的な方法というものが見えてこない。いろいろ試行錯誤している。

demoの中のSizedControls.pyで使われている方法は、かなり自分の理想と近い配置を実現していることに気づいた。そこで、SizedControls.pyから必要な部分を抜き出して、自分のコードの中に埋め込んだ。
wxaddons.sized_controlsなんていう今まで聞いたこともないものを使っているが、今後これを雛型として応用させていただく。
以下、ScaleFrame.pyモジュール(これだけでは動作しない)。

import wx
import wxaddons.sized_controls as sc

class ScaleFrame(sc.SizedDialog):
    def __init__(self, parent, id):
        sc.SizedDialog.__init__(self, None, -1, "SizedForm Dialog",
                                style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
        pane = self.GetContentsPane()
        pane.SetSizerType("form")

        wx.StaticText(pane, -1, "Name")
        textCtrl = wx.TextCtrl(pane, -1, "Your name here")
        textCtrl.SetSizerProps(expand=True)

        wx.StaticText(pane, -1, "Gender")
        wx.Choice(pane, -1, choices=["male", "female"])

        wx.StaticText(pane, -1, "State")
        wx.TextCtrl(pane, -1, size=(60,-1)) #two chrs

        wx.StaticText(pane, -1, "Title")

        #here's how to add a 'nested sizer' using sized_controls
        radioPane = sc.SizedPanel(pane, -1)
        radioPane.SetSizerType("horizontal")
        radioPane.SetSizerProps(expand=True)

        # make these children of the radioPane to have them use
        # the horizontal layout
        wx.RadioButton(radioPane, -1, "Mr.")
        wx.RadioButton(radioPane, -1, "Mrs.")
        wx.RadioButton(radioPane, -1, "Dr.")

        # add dialog buttons
        self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL))

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the contols need
        self.Fit()
        self.SetMinSize(self.GetSize())

実行結果は写真の通り。
ほとんど問題はないが、パネルが開くとwarningのような次のメッセージが出力される。

18:25:20: Debug: ..\..\include\wx/msw/private.h(338): 'GetWindowRect' failed with error 0x00000578 (ウィンドウ ハンドルが無効です。).

やっぱり何かまずいのだろうなー。ちゃんと実行はできているのに。