# -*- coding: UTF-8 -*- ############################################################################### # Name: flowsizer.py # Purpose: A demonstration custom sizer # Author: Ricardo Pedroso # Modified by: # Created: 11 Jun 2005 # RCS-ID: $Id: flowsizer.py,v 1.3 2005/11/26 16:57:42 rpedroso Exp $ # Copyright: (c) Ricardo Pedroso # Licence: wxWindows licence ############################################################################### import wx class FlowSizer(wx.PySizer): def __init__(self): wx.PySizer.__init__(self) def CalcMin(self): width = 0 height = 0 for item in self.GetChildren(): item_width, item_height = item.GetSize() width += item_width height = max(height, item_height) return wx.Size(width, height) def RecalcSizes(self): x = 0 y = 0 size_x, dummy = self.GetSize() max_item_height = 0 for item in self.GetChildren(): item_width, item_height = item.GetSize() max_item_height = max(max_item_height, item_height) if x + item_width > size_x: x = 0 y += item_height item.SetDimension(wx.Point(x,y), wx.Size(item_width, max_item_height)) x += item_width
Anonymous
Solving the next 5% probably costs more than the previous 90%.