an Image

M.E.Farmer mefjr75 at hotmail.com
Thu Jul 29 00:40:29 EDT 2004


justin__devine at hotmail.com (JDevine) wrote in message news:<f9d01b73.0407271254.427a271a at 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.
> 
> -Thanks
> 
> -Justin
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
import sys
import wx 
try:
    frame = wx.Frame(None, -1, "SimpleImage", size=(-1,-1),pos=(1,1))
    wx.InitAllImageHandlers()
    # Converts the image into a wx compatible bitmap 
    pix = wx.Image(sys.argv[1], wx.BITMAP_TYPE_ANY).ConvertToBitmap()
    # Now wx.StaticBitmap() can be used to place that bitmap onto the parent 
    st = wx.StaticBitmap(frame, -1, pix, pos=(1,1),
                         size=wx.Size(pix.GetWidth(),pix.GetHeight()))
    frame.SetClientSize(wx.Size(pix.GetWidth(),pix.GetHeight()))
    app = wx.PySimpleApp()
    frame.Show()
    app.MainLoop()
except:frame.Destroy()

Hth, 
 M.E. Farmer



More information about the Python-list mailing list