首页 新闻 会员 周边 捐助

wxPython使用wx.GridSizer的问题

0
悬赏园豆:100 [待解决问题]
# -*- 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 布局没有效果,拖动窗口大小,就又有效果了???
嘿嘿我是小白的主页 嘿嘿我是小白 | 初学一级 | 园豆:69
提问于:2018-08-16 17:30
< >
分享
所有回答(1)
0

SetSizer之后self.Layout()

不过你的布局有问题,最好多用Sizer

Uteki | 园豆:573 (小虾三级) | 2018-08-17 14:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册