In article <18**************************@posting.google.com >,
me*****@hotmail.com (M.E.Farmer) wrote:
ju************@hotmail.com (JDevine) wrote in message news:<f9**************************@posting.google. com>... I am going through the painfull process of learning wxPython. Sincer
there is nearly no documentation, I am learning from the demos.
Unfortunately, I have realized these demos do some specialized
importing and that all the imports are not applicable. Specifially,
All I want to do now is insert a bmp I have drawn into a windows
application. The image clases from the demos are completely
unexplanatory about how to do this. The "images" module that is
imported has custom functions for calling a specific set of images
such as GetTest2Bitmap, which does not help me at all. Please help me
understand this.
Maybe this will help you.
# SimpleImage ver 1.0
# by M.E.Farmer Jr. 2003
# Utilizes the new wx namespace
# usage: python SimpleImage.py image.jpg
[ ... ]
pix = wx.Image(sys.argv[1], wx.BITMAP_TYPE_ANY).ConvertToBitmap()
[ ... ]
st = wx.StaticBitmap(frame, -1, pix, pos=(1,1),
size=wx.Size(pix.GetWidth(),pix.GetHeight()))
You can also with a little more difficulty write straight
to the window.. Below is a fragment from __init__ of a
wx.Frame descendant. (It's straight from working code but I
haven't tested it independently.)
w, h = self.GetClientSizeTuple()
bmp = wx.EmptyBitmap (w, h)
mdc = wx.MemoryDC()
if bmp.LoadFile ("sweeper.bmp", wx.BITMAP_TYPE_BMP):
mdc.SelectObject (bmp)
wx.ClientDC (self).Blit (0,0, w,h, mdc, 0,0)
The complication with such techniques is that you need to
coordinate a lot of different objects.. Frame, Bitmap, DC..
and look up the separate documentation on those guys.. to
get any work done. Also not shown is the paint routine that
replays that Blit operation after an EVT_PAINT. Just for
what it's worth because I was just working on this.
Regards. Mel.