I have an application which I have built using wxPython 2.2.5 running on
Python 2.0 and am running on Linux (SuSE 7.2). I am trying to port this to
wxPython 2.5.2.7 running on Python 2.3.4 running on Windows 2000/XP.
Unfortunately, I don't want to have to maintain two versions so I'm looking
to minimise the changes I have to make and make them backwards compatible.
1) First problem is with the NewId function - it doesn't exist. The wxNewId
function does. I added the following line to wxPython/_utils.py after line
131:
NewId = wx._misc.NewId
But I realise that it is autogenerated from the XML file so I guess the
change needs to go in there but I can't figure out if an additional <method>
entry is allowed or not.
2) I realise that wxGridSizer has been deprecated but I still need to use it
:-(. I seem to be having a few problems with this.
i) I have fixed on problem: in wx/lib/grids.py. Here is the patch:
--- grids.orig.py 2004-08-19 17:12:45.947649600 +0100
+++ grids.py 2004-08-19 14:08:34.175982400 +0100
@@ -201,7 +201,7 @@
class PyFlexGridSizer(PyGridSizer):
def __init__(self, rows=0, cols=0, hgap=0, vgap=0):
- wxGridSizer.__init__(self, rows, cols, hgap, vgap)
+ PyGridSizer.__init__(self, rows, cols, hgap, vgap)
self.rowHeights = []
self.colWidths = []
self.growableRows = []
ii) Trying to resize a dialog with a wxGridSizer in a panel doesn't seem to
work whereas it did before:
# Instatiate Outer Box Sizer
oOuterBox = wxBoxSizer(wxVERTICAL)
# Instatiate Grid Box Sizer
oGridBox = wxFlexGridSizer(2, 3, 2, 2) # rows, cols, hgap, vgap
# Other stuff here...
oOuterBox.Add(oGridBox, 0, wxALIGN_LEFT)
#### Get the Panel to use the Sizer ####
self.SetAutoLayout(true)
self.SetSizer(oOuterBox)
# Tell the Sizer to resize the Panel to match the sizer's minimal
size,
# and then tell the Sizer to set the minimal size of this Frame to
that size
oOuterBox.Fit(self)
oOuterBox.SetSizeHints(self)
Any idea how I should be doing this? I remember fiddling when I first wrote
this but this seemed to work so I just stuck with it.
iii) I get an exception when trying to create another square grid as
follows:
Traceback (most recent call last):
File "C:\Python23\lib\site-packages\wx\lib\grids.py", line 290, in
RecalcSizes
self.SetItemBounds(items[i], x, y, w, h)
File "C:\Python23\lib\site-packages\wx\lib\grids.py", line 195, in
SetItemBounds
item.SetDimension(ipt, isz)
File "C:\Python23\Lib\site-packages\wx\_core.py", line 8722, in
SetDimension
return _core_.SizerItem_SetDimension(*args, **kwargs)
TypeError: Expected a pointer
Again, I never use to get this. I can supply code if required.
Robert Cragie, Design Engineer
Direct: +44 (0) 114 281 4512
···
_______________________________________________________________
Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
http://www.jennic.com Tel: +44 (0) 114 281 2655 Confidential
_______________________________________________________________