BUG IN WXWINDOWS-BINDING TO PYTHON ?
hi!
i'm a c++ professional,
but i consider using python and wxwindows for my win32 gui tools.
i find them very powerfull, but recently a bug (?) stopped me:
i construct some gui-controls in a function, an so i can not access them
directly.
i need to find them with 'FindWindowById' and 'wxPyTypeCast'
for wxButton and wxSlider and much other stuff this is no problem,
but it does not works for wxTreeCtrl.
sample:
PlaceTree(self) #constructs a tree
self.tree = wxPyTypeCast( self.FindWindowById( 151515 ),
"wxTreeCtrl" )
self.tree.Unselect() #this crashes at compiletime
self.tree.AddRoot("ral") #this too
self.tree = wxPyTypeCast( self.FindWindowById( 161616 ), "wxButton"
)
self.tree.Enable(false) #this works fine
the errormessage is as follows:
File "python20\wxPython\controls2.py", line 746, in Unselect
val = apply(controls2c.wxTreeCtrl_Unselect,(self,) + _args, _kwargs)
TypeError: Type error in argument 1 of wxTreeCtrl_Unselect, Expected
_wxPyTreeCtrl_p.
if i call AddRoot() directly in the 'PlaceTree' function, where the tree
gets constructed,
everything is fine.
so i think there must be a bug in 'FindWindowById', or more probably in
'wxPyTypeCast'
exactly the same error appears for the button, if i exchange "wxButton" to
"wxTreeCtrl".
(cast to a wrong type)
can you help me with this?
i can not debug this code.
but i dont want to use mfc or tcl..
inserting my c++ code in python seems much better.
below is the TypCast function from wx.py
···
#----------------------------------------------------------------------
# This helper function will take a wxPython object and convert it to
# another wxPython object type. This will not be able to create objects
# that are derived from wxPython classes by the user, only those that are
# actually part of wxPython and directly corespond to C++ objects.
#
# This is useful in situations where some method returns a generic
# type such as wxWindow, but you know that it is actually some
# derived type such as a wxTextCtrl. You can't call wxTextCtrl specific
# methods on a wxWindow object, but you can use this function to
# create a wxTextCtrl object that will pass the same pointer to
# the C++ code. You use it like this:
#
# textCtrl = wxPyTypeCast(window, "wxTextCtrl")
#
#
# WARNING: Using this function to type cast objects into types that
# they are not is not recommended and is likely to cause your
# program to crash... Hard.
#
def wxPyTypeCast(obj, typeStr):
if hasattr(obj, "this"):
newPtr = ptrcast(obj.this, typeStr+"_p")
else:
newPtr = ptrcast(obj, typeStr+"_p")
theClass = globals()[typeStr+"Ptr"]
theObj = theClass(newPtr)
if hasattr(obj, "this"):
theObj.thisown = obj.thisown
return theObj
Another minor problem is:
if i use wxStaticBoxSizers, their client-area is not
correctly updated, if directly embedded into a wxFrame.
(the background from UNDER the wxFrame shines trought partialy)
if embedded into a wxDialog, everything is fine.
this bugs rise on win nt4.0 (with the new comctrl.dll)
not tested on win95
Matthias
--
Sent through GMX FreeMail - http://www.gmx.net
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users