Python/WXWidgets: ST_NO_AUTORESIZE not being honored for wx.StaticText
Question: I want to throw up a view in the center of the screen at a fixed size, with
some static text being displayed centered both horizontally and vertically.

So far, I have the following code:

    
    
    import wx
    class DisplayText(wx.Dialog):
    
        def __init__(self, parent, text="", displayMode=0):
    
            # Initialize dialog
            wx.Dialog.__init__(self, parent, size=(480,320), style=( wx.DIALOG_EX_METAL | wx.STAY_ON_TOP ) )
    
            # Center form
            self.Center()
            self.txtField = wx.StaticText(self, label=text, pos=(80,120), size=(320,200), style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ST_NO_AUTORESIZE)
    
            self.txtField.SetFont(wx.Font(24, wx.DEFAULT, wx.BOLD, 0))      
    
    app = wx.App(False)
    
    c = DisplayText(None, text="Now is the time for all good men to come to the aid of their country.")
    c.Show()
    app.MainLoop()
    

The goal is to actually have the text vertically centered, but for now, I was
just trying to be explicit about the positioning of the static text on the
frame.

For a brief split second, the text appears in the position I put it in, but
then it quickly jumps to the very top bound of the window and expands to the
maximum width. (I deliberately set the width and position low so I'd be able
to see if this behavior was occurring or not.)

It does not matter if I use wx.Dialog or wx.Frame.

As you can see I did define the NO_AUTORESIZE flag, but this is not being
honored.

Can anyone explain what's happening?

Python 2.7.5/wxWidgets 2.8.12.1/Mac OS X 10.8.4


Answer: Turns out that it's a limitation of Mac OS X's native dialog implementation.

The following made it work on OS X. I never did try it on Windows but from
other forum posts it appears it would have worked as-is on Windows.

    
    
    import wx
    class DisplayText(wx.Dialog):
    
        def __init__(self, parent, text="", displayMode=0):
    
            # Initialize dialog
            wx.Dialog.__init__(self, parent, size=(480,320), style=( wx.DIALOG_EX_METAL | wx.STAY_ON_TOP ) )
    
            # Center form
            self.Center()
    
            # (For Mac) Setup a panel
            self.panel = wx.Panel(self)
    
            # Create text field     
            self.txtField = wx.StaticText(self.panel, label=text, pos=(80,120), size=(320,200), style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ST_NO_AUTORESIZE)
            self.txtField.SetFont(wx.Font(24, wx.DEFAULT, wx.BOLD, 0))      
            self.txtField.SetAutoLayout(False)
    
    app = wx.App(False)
    
    c = DisplayText(None, text="Now is the time for all good men to come to the aid of their country.")
    c.Show()
    app.MainLoop()
    

