I test scrolledpanel show image, not support maximize window.
How to support maximize window with scrolledpanel widgets.
my example code:
import wx
import wx.lib.scrolledpanel as scrolled
image_filename = "image.jpg"
class TestPanel(wx.Panel):
def __init__(self, parent, lsize):
wx.Panel.__init__(self, parent=parent)
self.scrollPnl = scrolled.ScrolledPanel(self, -1, size=lsize,
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
self.btn_add = wx.Button(self, label="Add")
self.Bind(wx.EVT_BUTTON, self.on_add, self.btn_add)
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
self.scrollPnlSizer = wx.BoxSizer(wx.VERTICAL)
img = wx.Image(image_filename, wx.BITMAP_TYPE_ANY)
staticBitmap = wx.StaticBitmap(self.scrollPnl, wx.ID_ANY,
wx.BitmapFromImage(img))
self.scrollPnlSizer.Add(staticBitmap, 1, wx.EXPAND | wx.ALL, 3)
self.mainSizer.Add(self.btn_add)
self.mainSizer.Add(self.scrollPnl)
self.SetSizer(self.mainSizer)
#self.scrollPnl.SetSizer(self.scrollPnlSizer)
#self.scrollPnl.SetAutoLayout(1)
#self.scrollPnl.SetupScrolling()
self.Centre()
def on_add(self, event):
img = wx.Image(image_filename, wx.BITMAP_TYPE_ANY)
staticBitmap = wx.StaticBitmap(self.scrollPnl, wx.ID_ANY,
wx.BitmapFromImage(img))
self.scrollPnlSizer.Add(staticBitmap, 1, wx.EXPAND | wx.ALL, 3)
self.scrollPnl.SetSizer(self.scrollPnlSizer)
self.scrollPnl.SetAutoLayout(1)
self.scrollPnl.SetupScrolling()
self.Refresh()
self.Layout()
class TestFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent)
self.Maximize(True)
size = self.GetSize()
TestPanel(self, size)
if __name__ == "__main__":
app = wx.PySimpleApp()
frame = TestFrame(None)
frame.Show()
app.MainLoop()
···
--
jiang zhixiang