wxpython滚动面板不会调整大小

时间:2017-11-13 07:25:03

标签: scroll wxpython pan

我正在使用wxpython并尝试使用滚动条调整框架面板,但是当我调整框架滚动条面板时,不会调整大小,我需要更改什么? AdressGUI是一个制作wxpython框架的类。 python verison 2.7 python verison 2.7

def OpenShowAddressList(self,e):
self.ShowAdressFrame=AdressGUI(self,"Frame")
panel=self.ShowAdressFrame.panel

panel2 = wx.lib.scrolledpanel.ScrolledPanel(panel,-1, size=(AdressWidthSize-15,AdressHeightSize-10),pos=(0,0), style=wx.SIMPLE_BORDER)
panel2.SetupScrolling()

font = wx.Font(18, wx.DEFAULT, wx.ITALIC, wx.NORMAL)
font.SetPointSize(9)
vbox = wx.BoxSizer(wx.VERTICAL)
bmp = wx.Bitmap(PATHIMAGES+"xbutton.jpg", wx.BITMAP_TYPE_ANY)
hboxlis=[]

hbox1 = wx.BoxSizer(wx.HORIZONTAL)
iptext = wx.StaticText(panel2, label="כתובת")
usernametext = wx.StaticText(panel2, label="משתמש")
passwordtext=wx.StaticText(panel2, label="סיסמא")
bmaptxt=wx.StaticText(panel2,label="מחק")
iptext.SetFont(font)
usernametext.SetFont(font)
passwordtext.SetFont(font)
bmaptxt.SetFont(font)
hbox1.Add(iptext,proportion=3 ,flag=wx.RIGHT, border=0)
hbox1.Add(usernametext,proportion=2, flag=wx.RIGHT, border=0)
hbox1.Add(passwordtext, proportion=2,flag=wx.RIGHT, border=8)
hbox1.Add(bmaptxt, proportion=0)
hbox1.Add(wx.StaticText(panel2), proportion=4,flag=wx.RIGHT, border=8) # add just for empty space to fit the sizer
hboxlis.append(hbox1)
vbox.Add(hbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)    
for add in self.DevicesList:
    bmapBtn = wx.BitmapButton(panel2, id=wx.ID_ANY, bitmap=bmp,size=(bmp.GetWidth(), bmp.GetHeight()),name=add['IP'])
    hbox1 = wx.BoxSizer(wx.HORIZONTAL)
    iptext = wx.StaticText(panel2, label=add['IP'])
    usernametext = wx.StaticText(panel2, label=add['user'])
    passwordtext=wx.StaticText(panel2, label=add['pas'])
    iptext.SetFont(font)
    usernametext.SetFont(font)
    passwordtext.SetFont(font)
    hbox1.Add(iptext,proportion=3, flag=wx.RIGHT, border=8)
    hbox1.Add(usernametext,proportion=2, flag=wx.RIGHT, border=8)
    hbox1.Add(passwordtext,proportion=2, flag=wx.RIGHT, border=8)
    hbox1.Add(bmapBtn, proportion=0)
    hbox1.Add(wx.StaticText(panel2), proportion=4,flag=wx.RIGHT, border=2) # add just for empty space to fit the sizer
    hboxlis.append(hbox1)
    vbox.Add(hbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)
    bmapBtn.Bind(wx.EVT_BUTTON, lambda event: self.DeleteIPFromList(event,hboxlis ,vbox,panel2) )


hbox5 = wx.BoxSizer(wx.HORIZONTAL)
hbox5.Add(wx.StaticText(panel2), proportion=2,flag=wx.EXPAND, border=8) # add just for empty space to fit the sizer
btn1 = wx.Button(panel2, label='ADD', size=(70, 30))
btn1.Bind(wx.EVT_BUTTON,self.CloseShowAddressAndOpenAddAdressList)
hbox5.Add(btn1, proportion=1)
btn2 = wx.Button(panel2, label='CLOSE', size=(70, 30))
btn2.Bind(wx.EVT_BUTTON,self.ShowAdressFrame.CloseWindow) #send show address frame as self
hbox5.Add(btn2,proportion=1)


vbox.Add(hbox5)
panel2.SetSizer(vbox)        
panel2.Layout()
panel.Fit(panel2)

1 个答案:

答案 0 :(得分:0)

在添加子项目之后以及在调用滚动面板的SetupScrolling之后,应调用SetSizer方法。