# -*- coding=utf-8 -*-
import wx
import wx.lib.scrolledpanel as scrolled
class IFCDetails(wx.Frame):
#单个滚动条 本次提交作为还原节点
def __init__(self, parent, id):
# 首先检索屏幕大小
screenSize = wx.DisplaySize()
screenWidth = screenSize[0]
screenHeight = screenSize[1]
panelWidth = (screenWidth / 3)+100
a = panelWidth * 2
b = screenHeight + screenHeight
#, size=(screenWidth, screenHeight)
wx.Frame.__init__(self, parent, id, title="IFC转化工具", size=(screenWidth, screenHeight))
self.panel1 = scrolled.ScrolledPanel(self, -1, size=(panelWidth, screenHeight), pos=(0, 0))
self.panel2 = scrolled.ScrolledPanel(self, id, size=(panelWidth, screenHeight), pos=(panelWidth+20, 0))
self.panel1.SetScrollbars(0, 10, 1440, 900, xPos=100, yPos=0)
self.panel2.SetScrollbars(0, 10, 1440, 900, xPos=100, yPos=0)
bt = wx.Button(self.panel1, id, label="点击")
bt.Bind(wx.EVT_BUTTON, self.onclick)
def onclick(self,event):
gs = wx.GridSizer(4, 4, 0, 0)
for i in range(1, 17):
btn = "Btn" + str(i)
gs.Add(wx.Button(self.panel2, label=btn), 0, 0)
self.SetSizer(gs)
if __name__ == '__main__':
app = wx.App()
frame = IFCDetails(parent=None, id=-1)
frame.Show()
app.MainLoop()
为什么我点击按钮后,girdSizer 布局没有效果,拖动窗口大小,就又有效果了???
SetSizer之后self.Layout()
不过你的布局有问题,最好多用Sizer