Openfile dialog and painting a picture

ok, i’ll ask this better this time.

I’m trying to make a program that will open a bitmap file and paint it on the frame allow the user to draw rectangles on the picture giving the coordinates of the rectangle.

But first thing first. I can’t get the image to paint on the workspace without an error

Code as follows:

def OnOpen(self, event):
    dlg = wx.FileDialog(self, "Choose a picture", os.getcwd(), "", "*.*", wx.OPEN)
    if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            self.SetStatusText("You selected: %s" % path)
    dlg.Destroy()
    self.Bitmap = wx.Bitmap(path)
    wx.EVT_PAINT(self, self.OnPaint)

def OnPaint(self, event):
    dc = wx.PaintDC(self)
    dc.DrawBitmap(self.bitmap, 1, 1)

any help would be great thanks

Eric Hunter
hunter.eric1@gmail.com

Hi guys,
    I have a really big big big problem with an external module:

BEFORE: I used python2.3, wxPython2.6 and PIL 1.1.4 ( and it's source code for building ). For my utility, I was build and external module defined _gauss with this distutils setup:

#!/usr/bin/env python

from distutils.core import setup, Extension

setup(name='_gauss', version='0.0.1',
      ext_modules=[Extension(
    '_gauss', ['_gauss.c'],
    extra_compile_args=['-I./Imaging-1.1.6/libImaging'],
    library_dirs=['./Imaging-1.1.6/libImaging'],
    libraries=['Imaging'],
    )]
      )

And it was build properly without any warnings/errors.

NOW: I must upgrade to python2.5, wxPython2.8 and PIL1.1.6.
When I run the script, it shows me this message:

    running build
    running build_ext
    error: Python was built with Visual Studio 2003;
    extensions must be built with a compiler than can generate
    compatible binaries.
    Visual Studio 2003 was not found on this system. If you have Cygwin
    installed,
    you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

Well, I've installed mingw32, but, when it runs with: python _gauss_setup.py build -c mingw32

    running build
    running build_ext
    building '_gauss' extension
    creating build
    creating build\temp.win32-2.5
    creating build\temp.win32-2.5\Release
    c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall
    -IC:\Python25\include -IC:\Pytho
    n25\PC -c _gauss.c -o build\temp.win32-2.5\Release\_gauss.o
    -I./Imaging-1.1.6/li
    bImaging
    writing build\temp.win32-2.5\Release\_gauss.def
    creating build\lib.win32-2.5
    c:\mingw\bin\gcc.exe -mno-cygwin -shared -s
    build\temp.win32-2.5\Release\_gauss.
    o build\temp.win32-2.5\Release\_gauss.def
    -L./Imaging-1.1.6/libImaging -LC:\Pyth
    on25\libs -LC:\Python25\PCBuild -lImaging -lpython25 -lmsvcr71 -o
    build\lib.win3
    2-2.5\_gauss.pyd
    c:\mingw\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe:
    cannot fin
    d -lImaging
    collect2: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1

My gauss module utilize pil to draw, and it need Imaging, but I don't why this build don't work....
Any idea???

thx

···

--
/\/\ariano Di Felice
Java PHP Python programmer
with MySQL, PostgreSql, SQLite and Oracle support
Linux Platform Developer
http://www.marianodifelice.it
mariano.difelice@gmail.com
Tel. 0735 703735
Cell +39 339 6407211

Robin Dunn ha scritto:

Mariano Di Felice wrote:

NOW: I must upgrade to python2.5, wxPython2.8 and PIL1.1.6.
When I run the script, it shows me this message:

   running build
   running build_ext
   error: Python was built with Visual Studio 2003;
   extensions must be built with a compiler than can generate
   compatible binaries.
   Visual Studio 2003 was not found on this system. If you have Cygwin
   installed,
   you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

Well, I've installed mingw32, but, when it runs with: python _gauss_setup.py build -c mingw32

   running build
   running build_ext
   building '_gauss' extension
   creating build
   creating build\temp.win32-2.5
   creating build\temp.win32-2.5\Release
   c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall
   -IC:\Python25\include -IC:\Pytho
   n25\PC -c _gauss.c -o build\temp.win32-2.5\Release\_gauss.o
   -I./Imaging-1.1.6/li
   bImaging
   writing build\temp.win32-2.5\Release\_gauss.def
   creating build\lib.win32-2.5
   c:\mingw\bin\gcc.exe -mno-cygwin -shared -s
   build\temp.win32-2.5\Release\_gauss.
   o build\temp.win32-2.5\Release\_gauss.def
   -L./Imaging-1.1.6/libImaging -LC:\Pyth
   on25\libs -LC:\Python25\PCBuild -lImaging -lpython25 -lmsvcr71 -o
   build\lib.win3
   2-2.5\_gauss.pyd
   c:\mingw\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe:
   cannot fin
   d -lImaging
   collect2: ld returned 1 exit status
   error: command 'gcc' failed with exit status 1

My gauss module utilize pil to draw, and it need Imaging, but I don't why this build don't work....

It's saying that it can't find a library for the -lImaging arg. Did you also build PIL with this compiler? Did it produce a ./Imaging-1.1.6/libImaging/libImaging.a file?

NO!!! it doesn't produce this libImaging.a.
I remember that pil 1.1.4 required to enter libImaging directory and type ./configure and make
Here, in PIL 1.1.6 in libImaging directory it's not present...

How can i build this library???

thx

···

--
/\/\ariano Di Felice
Java PHP Python Ruby programmer
with MySQL, PostgreSql, SQLite and Oracle support
Linux Platform Developer
http://www.marianodifelice.it
mariano.difelice@gmail.com
Tel. 0735 703735
Cell +39 339 6407211