wxStdDialogButtonSizer Oddity (?)

Hi Andrea,

Hi All,

   I am building my own custom wx.MessageDialog. I have pretty much
finished, but I noticed something odd about the behaviour of
wxStdDialogButtonSizer. In the the wxPython demo, if you try the
wx.MessageDialog example under "Common Dialogs" on Windows XP, a
simple message dialog appears on screen: this message box has the Ok
button horizontally centered on the dialog.
The generic implementation of wxMessageDialog uses
wxStdDialogButtonSizer to layout the buttons in the dialog, and I
found this comments in the source code of wxStdDialogButtonSizer:

#elif defined(__WXMSW__)
       // Windows

       // right-justify buttons
       Add(0, 0, 1, wxEXPAND, 0);

in the Realize method of wxStdDialogButtonSizer (sizer.cpp). The
buttons are right-aligned, which is what I see in my custom version of
wx.MessageDialog (the Ok button is shifted to the right).
So, the question is: why there is this difference between the native
version and the generic one? Or, re-phrasing, why is
wxStdDialogButtonSizer right-aligning the buttons? Am I missing
something here?

I'm pretty sure the case of just an OK button was just overlooked, since wxStdDialogButtonSizer was concerned with situations it'd be hard for the programmer to keep right on their own. I agree wxStdDialogButtonSizer should handle this case, though.

Thanks,

Kevin

···

On Apr 10, 2008, at 8:56 AM, Andrea Gavana wrote:

Thank you for your suggestions.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi Kevin,

Hi Andrea,

> Hi All,
>
> I am building my own custom wx.MessageDialog. I have pretty much
> finished, but I noticed something odd about the behaviour of
> wxStdDialogButtonSizer. In the the wxPython demo, if you try the
> wx.MessageDialog example under "Common Dialogs" on Windows XP, a
> simple message dialog appears on screen: this message box has the Ok
> button horizontally centered on the dialog.
> The generic implementation of wxMessageDialog uses
> wxStdDialogButtonSizer to layout the buttons in the dialog, and I
> found this comments in the source code of wxStdDialogButtonSizer:
>
> #elif defined(__WXMSW__)
> // Windows
>
> // right-justify buttons
> Add(0, 0, 1, wxEXPAND, 0);
>
> in the Realize method of wxStdDialogButtonSizer (sizer.cpp). The
> buttons are right-aligned, which is what I see in my custom version of
> wx.MessageDialog (the Ok button is shifted to the right).
> So, the question is: why there is this difference between the native
> version and the generic one? Or, re-phrasing, why is
> wxStdDialogButtonSizer right-aligning the buttons? Am I missing
> something here?
>

I'm pretty sure the case of just an OK button was just overlooked, since
wxStdDialogButtonSizer was concerned with situations it'd be hard for the
programmer to keep right on their own. I agree wxStdDialogButtonSizer should
handle this case, though.

Thank you for your answer. I think I have to re-implement
wxStbDialogButtonSizer anyway as the C++ version (and its wxPython
bindings) accepts only wxButtons, while I would like to use the
ThemedGenBitmapTextButton from wx.lib.buttons. And when I try this, I
get this nice traceback:

Traceback (most recent call last):
  File "D:\MyProjects\CustomWidgets\GenericMessageDialog\GenericMessageDialog.py",
line 155, in <module>
    wx.CANCEL | wx.ICON_ERROR
  File "D:\MyProjects\CustomWidgets\GenericMessageDialog\GenericMessageDialog.py",
line 42, in __init__
    sizerBtn = self.CreateSeparatedButtonSizer(self._dialogStyle &
self.ButtonSizerFlags)
  File "D:\MyProjects\CustomWidgets\GenericMessageDialog\GenericMessageDialog.py",
line 92, in CreateSeparatedButtonSizer
    sizer = self.CreateButtonSizer(flags)
  File "D:\MyProjects\CustomWidgets\GenericMessageDialog\GenericMessageDialog.py",
line 85, in CreateButtonSizer
    sizer = self.CreateStdDialogButtonSizer(flags)
  File "D:\MyProjects\CustomWidgets\GenericMessageDialog\GenericMessageDialog.py",
line 116, in CreateStdDialogButtonSizer
    sizer.AddButton(cancel)
  File "C:\Python25\lib\site-packages\wx-2.8-msw-ansi\wx\_core.py",
line 13404, in AddButton
    return _core_.StdDialogButtonSizer_AddButton(*args, **kwargs)
TypeError: in method 'StdDialogButtonSizer_AddButton', expected
argument 2 of type 'wxButton *'

:smiley: :smiley: . Not a big issue, I think, but some more code to write :wink:

Thank you for your suggestion.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On Fri, Apr 11, 2008 at 3:09 AM, Kevin Ollivier wrote:

On Apr 10, 2008, at 8:56 AM, Andrea Gavana wrote: