Need help w/ wxStaticBitmap (novice)

Mike Fletcher mfletch at tpresence.com
Fri Feb 16 05:49:35 EST 2001


The problem is likely that find window is defined as:

	wxWindow* FindWindow(long id)

So you're getting back a wxWindow pointer/object instead of a
wxStaticBitmap.  You need to cast it to a wxStaticBitmap (yes, it's ugly to
have to cast things in Python):

	wxPyTypeCast(
		self.FindWindowById(
			ID_STATICBITMAP
		),
		'wxStaticBitmap',
	).SetBitmap(MyBitmapsFunc(1))

Haven't tested that, but it sounds right.  No idea, incidentally, why you're
able to get the other two to work, seems to me they'd require a cast too.

HTH,
Mike

-----Original Message-----
From: Eric Myers [mailto:erictodd at texas.net]
Sent: Friday, February 16, 2001 12:51 AM
To: python-list at python.org
Subject: Need help w/ wxStaticBitmap (novice)


Hello.  Using wxDesigner, I've created a small dialog (dialer_wdr.py) whose 
job is to change as it catches certain events.  The contents of the dialog 
are as follows:
-A button, whose Id is ID_BUTTON
-A static text box whose Id is ID_TEXT
-A static bitmap whose Id is ID_STATICBITMAP, and whose initial bitmap is 
MyBitmapsFunc(0)

The event-catching and dialog-changing is handled by my implementation 
file,  which is named dialer.py.  When the event referred to is detected, 
dialer.py executes the following:

self.FindWindowById(ID_TEXT).SetLabel("new text")
--and the static text successfully gets changed to "new text"

self.FindWindowById(ID_BUTTON).SetLabel("new caption")
--and the button's caption successfully gets changed

self.FindWindowById(ID_STATICBITMAP).SetBitmap(MyBitmapsFunc(1))
--and I get an error that says "AttributeError: 'wxWindowPtr' instance has 
no attribute 'SetBitmap'"

I don't understand why this technique works in the first two situations but 
gives me problems with the bitmap thing.  If for some reason I can't 
accomplish what I'm trying to do in this way, can somebody please point me 
in the right direction?

                            Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list