I'm using winxp and wxpython ( wxpython 3.1, python 2.6 ) to make a GUI program which will copy the text from a TextCtrl, into a ScrollablePanel that contains a StaticText. This all works fine, however, the Scrolled part doesn't work quite right. It seems like it won't update in real time. When I ummaximize the window and maximize it again, the scroll bar updates. However, if I start typing in the TextCtrl again ( Thereby adding text to the StaticText inside the ScrollablePanel using an event ) the scrollbar on the panel doesn't update unless I minimize again and so on.
So the question is, how can I update the ScrolledPanel in real time? I have an event setup waiting for the text to change in the TextCtrl, which is where I think the update would need to go. I've tried Update, Refresh, and Layout but they didn't seem to do much. The bigger question is, what does minimizing the window and maximixing it again do that Update, Refresh and Layout do not? Thanks for you help in this. Sorry I can't post code, confidential. I would appreciate any help you could give me. I can normally find problems out on my own by searching but I just haven't found any documentation about this kind of thing. This is the first time for me, but I get a lot of help from your answers. Thanks again! :)
Added:
import wx
import wx.lib.inspection
from wx.lib.scrolledpanel import ScrolledPanel
class MyFrame( wx.Frame ):
# TODO: add all class variables here for convention
tin = None
hsizer = None
def __init__( self, parent, ID, title ):
wx.Frame.__init__( self, parent, ID, title,
wx.DefaultPosition, wx.Size( 200, 150 ) )
self.InitWidgets()
self.InitBindings()
self.InitFinish()
def InitWidgets( self ):
self.hsizer = wx.BoxSizer( wx.HORIZONTAL )
# Add the TextCtrl
vsizer = wx.BoxSizer( wx.VERTICAL )
self.tin = wx.TextCtrl( self, style=wx.TE_MULTILINE )
vsizer.Add( self.tin, 1, wx.EXPAND )
self.hsizer.Add( vsizer, 3, wx.TOP|wx.LEFT|wx.BOTTOM|wx.EXPAND, border=20 )
# Add ScrolledPanel widget
self.hsizer.Add( wx.Size( 200, -1 ), 1 )
vsizer2 = wx.BoxSizer( wx.VERTICAL )
self.test_panel = ScrolledPanel( self )
self.test_panel.SetupScrolling()
# Setup static text ( label ) tvs is the
# vertical sizer inside the panel
self.tvs = wx.BoxSizer( wx.VERTICAL )
self.tin2 = wx.StaticText( self.test_panel )
self.tvs.Add( self.tin2, 0, wx.EXPAND )
vsizer2.Add( self.test_panel, 1, wx.EXPAND )
self.hsizer.Add( vsizer2, 3, wx.TOP|wx.LEFT|wx.BOTTOM|wx.EXPAND, border=20 )
# Add Spacer
self.hsizer.Add( wx.Size( 500, -1 ), 1 )
def InitBindings( self ):
self.tin.Bind( wx.EVT_TEXT, self.TextChange )
def InitFinish( self ):
# Setup sizers and frame
self.SetAutoLayout( True )
self.test_panel.SetAutoLayout( True )
self.test_panel.SetSizer( self.tvs )
self.SetSizer( self.hsizer )
self.Layout()
self.Update()
self.Maximize()
def TextChange( self, event ):
#self.CopyValues()
self.tin2.Label = self.tin.GetValue()
self.Layout()
self.Update()
self.test_panel.Refresh()
self.test_panel.Update()
print self.tin.GetValue().split( "\n" )
class MyApp( wx.App ):
fr = None
def OnInit( self ):
self.fr = MyFrame( None, -1, "TitleX" )
self.fr.Show( True )
self.SetTopWindow( self.fr )
return True
app = MyApp( 0 )
app.MainLoop()
def main():
win = 1
if ( __name__ == "__main__" ):
main()
Generally, This is what is going on without giving too much of the purpose of the program. I setup the virtual size thinking that would make the size of the panel bigger than the area it was filling, hoping it would have permanent scroll bars but its not the case.