quoting mr Robin Dunn
"When you add new widgets then you need to tell the ScrolledPanel
that
the virtual size of the form has changed. You can do that by calling
SetupScrolling again, passing False for scrollToTop so the scroll
position won't change."
well ive looked at the second part of his advice, and sorry i cant
find that scrollToTop method he is talking about, now its very anoying
to see the scroll back to top everytime the user enters data.
here is a small code that reproduces the efect (with the SetScrollbars
thing correctly done)
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
class MyApp(wx.App):
def OnInit(self):
pos=(50,50)
size=(150,50)
marco=marcoprincipal('no hace nada', pos = (50,50), size =
(550,350))
marco.Show(True)
self.SetTopWindow(marco)
return True
class marcoprincipal(wx.Frame):
def __init__(self,title, pos, size):
wx.Frame.__init__(self,None,-1,title, pos, size)
self.ventana = wx.ScrolledWindow(self)
self.ventana.SetBackgroundColour('wheat')
self.ventana.Show=(True)
self.ventana.pulsador = wx.Button(self.ventana, -1, 'Press
me', size=(150,50))
self.ventana.pulsador.Bind(wx.EVT_BUTTON, self.pulsar)
sizerpral = wx.BoxSizer(wx.VERTICAL)
sizer1col = wx.FlexGridSizer( cols=1, hgap=15, vgap=5)
sizer1col.AddGrowableCol(0)
fuentenegrita = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.BOLD)
self.a = wx.StaticText(self.ventana, -1, "Column A")
self.a.SetFont(fuentenegrita)
self.abis = wx.StaticText(self.ventana, -1, "")
self.abis.SetFont(fuentenegrita)
self.b = wx.StaticText(self.ventana, -1, "Column B")
self.b.SetFont(fuentenegrita)
self.bbis = wx.StaticText(self.ventana, -1, "")
self.bbis.SetFont(fuentenegrita)
sizer1col.Add(self.a, 0, wx.ALIGN_LEFT)
sizer1col.Add(self.abis, 0, wx.ALIGN_RIGHT)
sizer1col.Add(self.b, 0, wx.ALIGN_LEFT)
sizer1col.Add(self.bbis, 0, wx.ALIGN_RIGHT)
sizer1col.Add(self.ventana.pulsador, 0, wx.ALIGN_RIGHT)
sizerpral.Add(sizer1col)
self.ventana.SetSizer(sizerpral)
sizer = wx.BoxSizer()
sizer.Add(self.ventana, 1, wx.EXPAND)
self.ventana.Refresh()
self.ventana.Layout()
self.ventana.SetScrollbars(10, 10, 50, 50)
def pulsar(self,event):
leea = self.abis.GetLabel()
self.abis.SetLabel(leea+'\nnewline')
self.ventana.Refresh()
self.ventana.Layout()
self.ventana.SetScrollbars(10, 10, 50, 50)
if __name__=='__main__':
aplicacion=MyApp()
aplicacion.MainLoop()
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ