scrolledpanel + image support Maximize window?

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

scrolledpanel support maximize window.

I modify test code, now scrolledpanel with max widow work find.

import wx
import wx.lib.scrolledpanel as scrolled

image_filename = “image.jpg”

class TestPanel(scrolled.ScrolledPanel):
def init(self, parent, lsize):
scrolled.ScrolledPanel.init(self, parent, -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.scrollPnlSizer = wx.BoxSizer(wx.VERTICAL)

    img = wx.Image(image_filename, wx.BITMAP_TYPE_ANY)
    staticBitmap = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(img))
   
    self.scrollPnlSizer.Add(self.btn_add)
    self.scrollPnlSizer.Add(staticBitmap, 1, wx.EXPAND | wx.ALL, 3)

    self.SetSizer(self.scrollPnlSizer)

    self.Centre()

def on_add(self, event):
    img = wx.Image(image_filename, wx.BITMAP_TYPE_ANY)
    staticBitmap = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(img))
    self.scrollPnlSizer.Add(staticBitmap, 1, wx.EXPAND | wx.ALL, 3)
    self.SetSizer(self.scrollPnlSizer)
    self.SetAutoLayout(1)
    self.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()

···

On Friday, September 14, 2012 9:53:05 AM UTC+8, luckrill wrote:

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