/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/sizers.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Thuban/UI/sizers.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1808 - (hide annotations)
Fri Oct 10 16:59:40 2003 UTC (21 years, 4 months ago) by bh
Original Path: trunk/thuban/Thuban/UI/sizers.py
File MIME type: text/x-python
File size: 1948 byte(s)
New file with custom sizers.

1 bh 1808 # Copyright (C) 2003 by Intevation GmbH
2     # Authors:
3     # Bernhard Herzog <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with the software for details.
7    
8     """Custom Sizers"""
9    
10     __version__ = "$Revision$"
11     # $Source$
12     # $Id$
13    
14     from wxPython.wx import wxPySizer, wxSize
15    
16     class NotebookLikeSizer(wxPySizer):
17    
18     """Similar to a wxNotebookSizer but doesn't need a real notebook
19     """
20    
21     def __init__(self):
22     wxPySizer.__init__(self)
23     self.item_dict = {}
24    
25     def Add(self, item):
26     """Add the item to the sizer.
27    
28     The children added with Add must must be an object that has
29     Show() and Hide() methods
30     """
31     wxPySizer.Add(self, item)
32    
33     def Activate(self, item):
34     """Activate the item.
35    
36     Call this item's Show method and the Hide method of all other
37     items. The item must have been added to the sizer with Add.
38     """
39     for child in self.GetChildren():
40     window = child.GetWindow()
41     if window is item:
42     window.Show()
43     else:
44     window.Hide()
45    
46     def RecalcSizes(self):
47     """Set all children to the current size of the sizer
48    
49     This method is automatically called by the wxWindows sizer
50     mechanism.
51     """
52     pos = self.GetPosition()
53     size = self.GetSize()
54    
55     for item in self.GetChildren():
56     item.SetDimension(pos, size)
57    
58     def CalcMin(self):
59     """Return the maximum of the minimum sizes of the children.
60    
61     This method is automatically called by the wxWindows sizer
62     mechanism.
63     """
64     widths = []
65     heights = []
66     for item in self.GetChildren():
67     size = item.CalcMin()
68     widths.append(size.width)
69     heights.append(size.height)
70     if widths:
71     return wxSize(max(widths), max(heights))
72     return wxSize(0, 0)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26