creating custom controls example error

hi

I am having a go at
http://wiki.wxpython.org/index.cgi/CreatingCustomControls

I downloaded the example and tried to execute it getting this error:
$ python CustomCheckBoxDemo.py
Traceback (most recent call last):
   File "CustomCheckBoxDemo.py", line 251, in ?
     main()
   File "CustomCheckBoxDemo.py", line 244, in main
     size=(600, 400))
   File "CustomCheckBoxDemo.py", line 68, in __init__
     self.ccb1 = CCB.CustomCheckBox(self.mainPanel, -1, "Hello wxPython!")
   File "/home/r2d2/Desktop/customwx/CustomCheckBox.py", line 111, in __init__
     self.SetInitialSize(size)
AttributeError: 'CustomCheckBox' object has no attribute 'SetInitialSize'

After commenting out this line (111 on customcheckbox.py) it works
# self.SetInitialSize(size)

This is my system: debian with python 2.4.4 and wx-2.6-gtk2-unicode

enrike

Hi Enrike,

I am having a go at
http://wiki.wxpython.org/index.cgi/CreatingCustomControls

I am happy that someone found it useful :smiley:

I downloaded the example and tried to execute it getting this error:
$ python CustomCheckBoxDemo.py
Traceback (most recent call last):
   File "CustomCheckBoxDemo.py", line 251, in ?
     main()
   File "CustomCheckBoxDemo.py", line 244, in main
     size=(600, 400))
   File "CustomCheckBoxDemo.py", line 68, in __init__
     self.ccb1 = CCB.CustomCheckBox(self.mainPanel, -1,
"Hello wxPython!")
   File "/home/r2d2/Desktop/customwx/CustomCheckBox.py", line
111, in __init__
     self.SetInitialSize(size)
AttributeError: 'CustomCheckBox' object has no attribute
'SetInitialSize'

After commenting out this line (111 on customcheckbox.py) it
works # self.SetInitialSize(size)

This is my system: debian with python 2.4.4 and wx-2.6-gtk2-unicode

I believe the problem is the wxPython version: SetInitialSize was introduced somewhere between 2.7 and 2.8 (I don't remember), so it won't work with 2.6. However, for your wxPython version, it should be enough to use the old equivalent of SetInitialSize:

SetInitialSize -->SetBestFittingSize

HTH.

Andrea.

···

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯