I have a wx.StaticLine
separating some buttons in a wx.GridBagSizer
. When the window initially draws, the StaticLine
does not show up. Sometimes after a long running task (and I move the window around or something, presumably forcing the frame to be redrawn) it will show up out of nowhere.
Here is what it looks like:
When window initially draws:
After some long running task (or resize):
I create the line with:
self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
gbSizer101.Add( self.m_staticline1, wx.GBPosition( 2, 0 ), wx.GBSpan( 1, 2 ), wx.EXPAND |wx.ALL, 5 )
and at the end of the init
I draw with:
self.SetSizer( gbSizer1 )
self.Layout()
gbSizer1.Fit( self )
I'm not sure if this is significant, but here is how I start the application:
app = wx.App(False)
frame = FWHM_Application(None)
frame.Show()
app.MainLoop()
Any ideas why this might be happening and how to make it draw initially?
EDIT: Here is a working sample program demonstrating the issue:
import wx
class Test_Frame ( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Test GUI", pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
# Outer container
gbSizer_outer = wx.GridBagSizer( 4, 3 )
gbSizer_outer.SetFlexibleDirection( wx.BOTH )
gbSizer_outer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
# Static box for analysis
analyzeImageBox = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Analyze Single Image" ), wx.VERTICAL )
# Sizer for button/label layout within static box
gbSizer_single = wx.GridBagSizer( 0, 0 )
gbSizer_single.SetFlexibleDirection( wx.BOTH )
gbSizer_single.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
self.analyzeImage = wx.Button( self, wx.ID_ANY, u"Analyze Image", wx.DefaultPosition, wx.Size( 170,45 ), 0 )
gbSizer_single.Add( self.analyzeImage, wx.GBPosition( 0, 0 ), wx.GBSpan( 1, 2 ), wx.ALL, 5 )
self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
gbSizer_single.Add( self.m_staticline1, wx.GBPosition( 1, 0 ), wx.GBSpan( 1, 2 ), wx.EXPAND |wx.ALL, 5 )
self.plotX = wx.Button( self, wx.ID_ANY, u"Plot X", wx.DefaultPosition, wx.Size( 70,35 ), 0 )
gbSizer_single.Add( self.plotX, wx.GBPosition( 2, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 )
self.plotY = wx.Button( self, wx.ID_ANY, u"Plot Y", wx.DefaultPosition, wx.Size( 70,35 ), 0 )
gbSizer_single.Add( self.plotY, wx.GBPosition( 2, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 )
analyzeImageBox.Add( gbSizer_single, 1, wx.EXPAND, 5 )
gbSizer_outer.Add( analyzeImageBox, wx.GBPosition( 1, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 )
self.SetSizer( gbSizer_outer )
gbSizer_outer.Fit( self )
self.Layout()
self.Centre( wx.BOTH )
app = wx.App(False)
frame = Test_Frame(None)
frame.Show()
app.MainLoop()