In my testing, you can (and probably should) use the standard IDs -- in fact that will get you a platform (and perhaps locale?) standard caption. But it will not, by itself, position and size the buttons correctly. StdDialogButtonSizer does that.
This should be in the wiki and/or the demo then. I tried to come up with a simple example, but I've never used this sizer and can't seem to quite get it.
I agree -- in fact I searched through the demo before posting my question (and came up empty-handed). Here's how I'm using it in my dialog:
class MemberEntryWindow(Window):
def __init__(self, title = "Member"):
Window.__init__(self, title, size=(
(80+200+8)*2 + gui.SIDE_MARGIN*2 + 16,451),
style=wx.SYSTEM_MENU | wx.CAPTION
> wx.CLOSE_BOX | wx.MINIMIZE_BOX)
panel = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
panel.SetSizer(vbox)
# ... add all my other controls ...
buttonsBox = wx.StdDialogButtonSizer()
vbox.Add(buttonsBox, 0,
wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT, gui.SIDE_MARGIN)
cancelButn = wx.Button(panel, wx.ID_CANCEL)
buttonsBox.AddButton(cancelButn)
okButn = wx.Button(panel, wx.ID_OK)
buttonsBox.AddButton(okButn)
okButn.SetDefault()
buttonsBox.Realize()
cancelButn.Bind(wx.EVT_BUTTON, self.OnCancel)
okButn.Bind(wx.EVT_BUTTON, self.OnOK)
This seems to work for me (but I'm still a newbie to wxPython, and confess that I still get confused by sizers on occasion, so if I'm doing anything pointless or silly in the above, I hope someone will point it out).
I haven't tested this on Windows or Linux yet, but I can confirm that on the Mac, the OK button appears on the right where it belongs. It should be on the left on other platforms.
For the wiki, I would guess the most appropriate place would be here?
<http://wiki.wxpython.org/SizerTutorials>
I don't know what to make of the bit there about "Until I get them all moved over" though (and who is "I" in a wiki that can be edited by anybody?).
As for the demo, how does one go about contributing to that?
Best,
- Joe
···
On Oct 31, 2008, at 8:40 AM, Mike Driscoll wrote: