Using the standard dialog button sizer
Each platform has varying conventions or standards for the way buttons are displayed on a dialog. For example, on Windows, the OK button is to the left of the Cancel button; however, on OS X, the OK button is to its right. wxPython provides a way to deal with these platform differences without the need for platform-specific code. In this recipe, we will explore how to use the StdDialogButtonSizer
class to manage the layout of buttons on a dialog in a platform-independent way.
How to do it…
Here are the steps that you need to perform for this:
For this recipe, we will make a custom message dialog class that uses
StdDialogButtonSizer
. The first step is to define the class' special text Sizer for the message, which can be done through the following code:class CustomMessageDialog(wx.Dialog): def __init__(self, parent, title, msg, flags): super(CustomMessageDialog, self).__init__(parent, title=title) sizer = wx.BoxSizer(wx.VERTICAL) ...