[wxPython] immediate image draw?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] immediate image draw?

Bob Klimek-2
Hello All,

Is there a way to force an image (actually a rectangular area of
interest (AOI)) to be drawn immediately?

I'd like to perform a series of filtering operations on an image but I
want the resultant image to be displayed after each operation. Currently
no re-drawing is done until all operations are finished and then the
final result is displayed.

I've tried the following:
1. self.Refresh(false, rect) # calls OnPaint
2. dc.DrawBitmap(img.ConvertToBitmap(), x, y)

but neither forces an immediate draw. Any ideas?

Bob

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] immediate image draw?

Robin Dunn
>
> I've tried the following:
> 1. self.Refresh(false, rect) # calls OnPaint
> 2. dc.DrawBitmap(img.ConvertToBitmap(), x, y)
>
> but neither forces an immediate draw. Any ideas?
>

What kind of dc are you using?  You should be able to create a wxClientDC at
anytime and draw on it and have the results show up immediately.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] immediate image draw?

Bob Klimek-2
Robin Dunn wrote:

> > I've tried the following:
> > 1. self.Refresh(false, rect) # calls OnPaint
> > 2. dc.DrawBitmap(img.ConvertToBitmap(), x, y)
> >
> > but neither forces an immediate draw. Any ideas?
> >
>
> What kind of dc are you using?  You should be able to create a wxClientDC at
> anytime and draw on it and have the results show up immediately.
>

Hello Robin, or anyone,

Just got your e-mail about the family problems so I feel a little guilty
about asking. Hope everything works out well.

I don't know how to explain this problem any other way so I stripped
down my program (way down) to demonstrate this. Its still a bit
long...sorry.

Also I'm using PIL so I hope this doesn't present a problem. I don't
think PIL has anything to do with this problem however.

When you run the program, first (1.) load an image (any tif or bmp
bigger than 250x250 should do). Then (2.) select Aoi-->New-->rectangle.
Then (3.) Aoi-->Track One. You see that it performs an image filtering
operation (threshold) inside the box very fast, in a split second.

However, now if you un-comment the 4 lines under the line "## UNCOMMENT
THESE 4 LINES OUT" (near the bottom of the program) it performs the
filtering operation and draws a small cross inside the box. But now it
takes a few seconds. THIS IS A BIG PROBLEM FOR ME.

If it works as you say then I would expect the result of the image
processing operation (threshold) to show up fast and then after a few
seconds the cross to be drawn. But what happens instead is the display
of the threshold is held up until those 4 lines finish executing.

Can anything be done? A copy of the program is below.
Bob



import Image
import ImageFilter
from wxPython.wx import *
import math

ID_FILE_OPEN = 101
ID_FILE_EXIT  = 103
ID_AOI_RECTANGLE = 1201
ID_AOI_NEWAOI = 1212
ID_TRACK_ONE = 1500

#----------------- Class mtImagePanel
---------------------------------------------

class mtImagePanel(wxPanel):
    def __init__(self, parent, id):
        wxPanel.__init__(self, parent, id)
        self.parent = parent        
        self.image = None
        self.currentAoi = -1
        self.aoiList = []

    def __del__(self):
        self.deleteAllAois()
           
    def OnPaint(self, evt):
        dc = wxPaintDC(self)
        if self.image:
            dc.DrawBitmap(self.image.ConvertToBitmap(), 0,0)
        dc.SetLogicalFunction(wxINVERT)
        color = wxColour()
        brush = wxBrush(color, wxTRANSPARENT)
        dc.SetBrush(brush)
        self.redrawAois(dc)

    # Only RGB image can be displayed because wxImage.SetData requires
RGB
    # input. So 8-bit images are converted to RGB.
    def display(self, pilimage):
        if pilimage.mode == 'L':
            pilimage = pilimage.convert("RGB")
        self.image = wxEmptyImage(pilimage.size[0], pilimage.size[1])
        self.image.SetData(pilimage.tostring('raw','RGB'))
        self.Refresh(true)

    def displayAoi(self, pilimage, r):  # display the AOI (subimage)
        if pilimage.mode == 'L':
            pilimage = pilimage.convert("RGB")
        img = wxEmptyImage(pilimage.size[0], pilimage.size[1])
        img.SetData(pilimage.tostring('raw','RGB'))
        x = r[0]
        y = r[1]
        dc = wxClientDC(self)
        dc.DrawBitmap(img.ConvertToBitmap(), x, y)
       
    # Set up the brush and pen
    def getUpdatedDC(self):
        dc = wxClientDC(self)
        dc.SetLogicalFunction(wxINVERT)
        color = wxColour()
        brush = wxBrush(color, wxTRANSPARENT)
        dc.SetBrush(brush)
        pen = wxPen(color, 2, wxSOLID)
        dc.SetPen(pen)
        return dc

    # Redraws all aoi's -- current aoi with a thick line, all others
will thin line
    def redrawAois(self, dc):
        color = wxColour()
        pen1 = wxPen(color, 1, wxSOLID)
        pen2 = wxPen(color, 2, wxSOLID)
        for aoi in self.aoiList:
            if aoi == self.getCurrentAoi():
                dc.SetPen(pen2)
            else:
                dc.SetPen(pen1)
            aoi.drawAoi(dc)

    def setNewAoi(self, aoi):
        dc = self.getUpdatedDC()
        self.redrawAois(dc)  # undraw aoi's
        self.aoiList.append(aoi)  # append to end of list
        self.currentAoi = self.getAoiListLength() - 1
        self.redrawAois(dc)  # redraw aoi's

    def getAoiListLength(self):
        return len(self.aoiList)

    def getCurrentAoi(self):
        if self.getAoiListLength() > 0:
            return self.aoiList[self.currentAoi]
        else:
            return None

#------------------ Class mtFrame
------------------------------------------------

class mtFrame(wxFrame):
    def __init__(self, parent, ID, title):
        wxFrame.__init__(self, parent, ID, title, wxDefaultPosition,
wxSize(650, 500))
        self.iPanel = mtImagePanel(self, -1)
        self.im = None
        self.imageLoaded = false
        self.currentfile = ""

        # Construct a MenuBar
        self.menuBar = wxMenuBar()
        # Construct "File" menu
        self.menuFile = wxMenu()
        self.open = self.menuFile.Append(ID_FILE_OPEN, "&Open","Open
file")
        EVT_MENU(self, ID_FILE_OPEN, self.OnOpen)
        EVT_UPDATE_UI(self, ID_FILE_OPEN, self.OnOpenUpdate)
        self.menuFile.AppendSeparator()
        self.menuFile.Append(ID_FILE_EXIT, "E&xit", "Terminate the
program")
        EVT_MENU(self, ID_FILE_EXIT,  self.OnExit)
        self.menuBar.Append(self.menuFile, "&File");
        # Construct "Aoi" menu
        self.menuAoi = wxMenu()
        self.submenuAoiNew = wxMenu()
        self.submenuAoiNew.Append(ID_AOI_RECTANGLE, "rectangle", "draw
new rectangle")
        EVT_MENU(self, ID_AOI_RECTANGLE, self.OnNewRectangle)
        self.menuAoi.AppendMenu(ID_AOI_NEWAOI, '&New',
self.submenuAoiNew, 'new aois')        
        self.menuAoi.Append(ID_TRACK_ONE, "&Track One", "")
        EVT_MENU(self, ID_TRACK_ONE,  self.OnTrackOne)
        self.menuBar.Append(self.menuAoi, "&Aoi")
        # Add all the menus to the Menu Bar
        self.SetMenuBar(self.menuBar)

    # Updates image depended menus
    def OnOpenUpdate(self, event):
        self.menuAoi.Enable(ID_AOI_NEWAOI, self.imageLoaded)
        self.menuAoi.Enable(ID_TRACK_ONE, self.imageLoaded)

    def OnTrackOne(self, event):
        if self.iPanel.getAoiListLength() > 0:
            self.trackOne()

    def trackOne(self):
        dc = self.iPanel.getUpdatedDC()
        for aoi in self.iPanel.aoiList:
            aoi.Update(dc)

    def OnNewRectangle(self, event):
        rect = AoiRectangle(self, 30,30,200,200)
        self.iPanel.setNewAoi(rect)

    def OnOpen(self, event):
        fd = wxFileDialog(self, "Open Image", "/home/klimek/Images",
"*.bmp",
                "All files (*.*)|*.*|BMP files (*.bmp)|*.bmp|PNG files
(*.png)|*.png", wxOPEN)
        if fd.ShowModal() == wxID_OK:
            self.currentfile = fd.GetPath()
            self.loadImage(self.currentfile)
            self.iPanel.Refresh(true)
        fd.Destroy()

    def loadImage(self, file):
        if self.fileExists(file):
            try:
                self.im = Image.open(file)
                self.iPanel.display(self.im)
                self.imageLoaded = true
                return true
            except IOError:
                print "can't open the file"
                return false
        else:
            return false

    def fileExists(self, path):   # check if the file exists
        try:
            f = open(path,'r')
            f.close()
            return true
        except IOError:
            return false

    def OnCloseWindow(self, event):
        self.Destroy()

    def OnExit(self, event):
        self.Close(true)

#---------------------- Aoi Class
-----------------------------------------

class Aoi:
    def __init__(self, parent, x1, y1, x2, y2):
        self.parent = parent
        self.x1 = x1
        self.y1 = y1
        self.x2 = x2
        self.y2 = y2

    def Update(self, dc):
        pass
    def drawAoi(self, dc):
        pass

#---------------------------------------------------------------------------

class AoiRectangle(Aoi):
    def __init__(self, parent, x1, y1, x2, y2):
        Aoi.__init__(self, parent, x1, y1, x2, y2)

    def drawAoi(self, dc):
        w = self.x2 - self.x1
        h = self.y2 - self.y1
        dc.DrawRectangle(self.x1, self.y1, w, h)

    def drawCross(self, dc, p):
        x = p[0]
        y = p[1]
        x = x + self.x1
        y = y + self.y1
        dc.DrawLine(x-5, y, x+5, y)
        dc.DrawLine(x, y-5, x, y+5)

    def Update(self, dc):
        r = (self.x1+1, self.y1+1, self.x2-2, self.y2-2)
        aoiImage = self.parent.im.crop(r)
        aoiImage = self.Threshold(aoiImage, 128) # threshold the AOI
        self.parent.im.paste(aoiImage, r)
        self.parent.iPanel.displayAoi(aoiImage, r)

        ## UNCOMMENT THESE 4 LINES OUT
##        pt = self.CalculateSomething()  # this takes a few seconds
##        pen = wxPen(wxNamedColour('RED'))
##        dc.SetPen(pen)
##        self.drawCross(dc, pt)
        #######

    def CalculateSomething(self):  # kill a few seconds and return some
coordinates
        b = 0
        for i in range(0, 1000000):
            b = i
        return (50, 50)

    def Threshold(self, image, value):
        out = image.point(lambda i, v=value: i > v and 255) # 255 if
greater than value            
        return out

#---------------------------------------------------------------------------

class mtApp(wxApp):
    def OnInit(self):
        frame = mtFrame(NULL, -1, "wxRedraw2")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = mtApp(0)
app.MainLoop()






--
---------------------
Robert B. Klimek
NASA Glenn Research Center
[hidden email]
---------------------

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] immediate image draw?

Robin Dunn
>
> If it works as you say then I would expect the result of the image
> processing operation (threshold) to show up fast and then after a few
> seconds the cross to be drawn. But what happens instead is the display
> of the threshold is held up until those 4 lines finish executing.
>
> Can anything be done? A copy of the program is below.

On MSW it does show up right away so I assume you are using wxGTK.  It sounds
like something is buffering up the drawing operations until the current event
handler is done.  You might try calling wxYield before your time-consuming
function and see if that flushes it out.  Let me know if it doesn't and I'll
try to spend some time looking deeper...

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!






_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] immediate image draw?

Bob Klimek-2
Robin Dunn wrote:

>
> >
> > If it works as you say then I would expect the result of the image
> > processing operation (threshold) to show up fast and then after a few
> > seconds the cross to be drawn. But what happens instead is the display
> > of the threshold is held up until those 4 lines finish executing.
> >
> > Can anything be done? A copy of the program is below.
>
> On MSW it does show up right away so I assume you are using wxGTK.  It sounds
> like something is buffering up the drawing operations until the current event
> handler is done.  You might try calling wxYield before your time-consuming
> function and see if that flushes it out.  Let me know if it doesn't and I'll
> try to spend some time looking deeper...

Hello Robin,

The wxYield() did the trick. Thanks very much. And yes, I'm using wxGTK.

This wxYield function seems like a good function to know. Does it work
like the PeekMessage loop in MFC? -- Basically the idea is to sprinkle
this function around time-consuming parts of the code so that the system
can read-off the various messages and event calls and not freeze up, is
that right?

Bob
--
---------------------
Robert B. Klimek
NASA Glenn Research Center
[hidden email]
---------------------

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] immediate image draw?

Robin Dunn
> The wxYield() did the trick. Thanks very much.

Glad to hear it.

> And yes, I'm using wxGTK.
>
> This wxYield function seems like a good function to know. Does it work
> like the PeekMessage loop in MFC? -- Basically the idea is to sprinkle
> this function around time-consuming parts of the code so that the system
> can read-off the various messages and event calls and not freeze up, is
> that right?
>

Yes.  It processes the event loop until there are no more events, then any
pending idle-time tasks, and then returns.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] immediate image draw?

Boulay,Patrick,PARIS
In reply to this post by Bob Klimek-2
Has ne1 succeeded in setting up wxPython on HP9000 HPUX 10.20 platforms ????
tell me your wxGTK/GTK/GDK release numbers ..
thanks
Patrick

> -----Message d'origine-----
> De: Bob Klimek [SMTP:[hidden email]]
> Date: lundi 6 mars 2000 19:25
> À: Robin Dunn; wxPython Post
> Objet: Re: [wxPython] immediate image draw?
>
> Robin Dunn wrote:
> > > I've tried the following:
> > > 1. self.Refresh(false, rect) # calls OnPaint
> > > 2. dc.DrawBitmap(img.ConvertToBitmap(), x, y)
> > >
> > > but neither forces an immediate draw. Any ideas?
> > >
> >
> > What kind of dc are you using?  You should be able to create a
> wxClientDC at
> > anytime and draw on it and have the results show up immediately.
> >
>
> Hello Robin, or anyone,
>
> Just got your e-mail about the family problems so I feel a little guilty
> about asking. Hope everything works out well.
>
> I don't know how to explain this problem any other way so I stripped
> down my program (way down) to demonstrate this. Its still a bit
> long...sorry.
>
> Also I'm using PIL so I hope this doesn't present a problem. I don't
> think PIL has anything to do with this problem however.
>
> When you run the program, first (1.) load an image (any tif or bmp
> bigger than 250x250 should do). Then (2.) select Aoi-->New-->rectangle.
> Then (3.) Aoi-->Track One. You see that it performs an image filtering
> operation (threshold) inside the box very fast, in a split second.
>
> However, now if you un-comment the 4 lines under the line "## UNCOMMENT
> THESE 4 LINES OUT" (near the bottom of the program) it performs the
> filtering operation and draws a small cross inside the box. But now it
> takes a few seconds. THIS IS A BIG PROBLEM FOR ME.
>
> If it works as you say then I would expect the result of the image
> processing operation (threshold) to show up fast and then after a few
> seconds the cross to be drawn. But what happens instead is the display
> of the threshold is held up until those 4 lines finish executing.
>
> Can anything be done? A copy of the program is below.
> Bob
>
>
>
> import Image
> import ImageFilter
> from wxPython.wx import *
> import math
>
> ID_FILE_OPEN = 101
> ID_FILE_EXIT  = 103
> ID_AOI_RECTANGLE = 1201
> ID_AOI_NEWAOI = 1212
> ID_TRACK_ONE = 1500
>
> #----------------- Class mtImagePanel
> ---------------------------------------------
>
> class mtImagePanel(wxPanel):
>     def __init__(self, parent, id):
>         wxPanel.__init__(self, parent, id)
>         self.parent = parent        
>         self.image = None
>         self.currentAoi = -1
>         self.aoiList = []
>
>     def __del__(self):
>         self.deleteAllAois()
>            
>     def OnPaint(self, evt):
>         dc = wxPaintDC(self)
>         if self.image:
>             dc.DrawBitmap(self.image.ConvertToBitmap(), 0,0)
>         dc.SetLogicalFunction(wxINVERT)
>         color = wxColour()
>         brush = wxBrush(color, wxTRANSPARENT)
>         dc.SetBrush(brush)
>         self.redrawAois(dc)
>
>     # Only RGB image can be displayed because wxImage.SetData requires
> RGB
>     # input. So 8-bit images are converted to RGB.
>     def display(self, pilimage):
>         if pilimage.mode == 'L':
>             pilimage = pilimage.convert("RGB")
>         self.image = wxEmptyImage(pilimage.size[0], pilimage.size[1])
>         self.image.SetData(pilimage.tostring('raw','RGB'))
>         self.Refresh(true)
>
>     def displayAoi(self, pilimage, r):  # display the AOI (subimage)
>         if pilimage.mode == 'L':
>             pilimage = pilimage.convert("RGB")
>         img = wxEmptyImage(pilimage.size[0], pilimage.size[1])
>         img.SetData(pilimage.tostring('raw','RGB'))
>         x = r[0]
>         y = r[1]
>         dc = wxClientDC(self)
>         dc.DrawBitmap(img.ConvertToBitmap(), x, y)
>        
>     # Set up the brush and pen
>     def getUpdatedDC(self):
>         dc = wxClientDC(self)
>         dc.SetLogicalFunction(wxINVERT)
>         color = wxColour()
>         brush = wxBrush(color, wxTRANSPARENT)
>         dc.SetBrush(brush)
>         pen = wxPen(color, 2, wxSOLID)
>         dc.SetPen(pen)
>         return dc
>
>     # Redraws all aoi's -- current aoi with a thick line, all others
> will thin line
>     def redrawAois(self, dc):
>         color = wxColour()
>         pen1 = wxPen(color, 1, wxSOLID)
>         pen2 = wxPen(color, 2, wxSOLID)
>         for aoi in self.aoiList:
>             if aoi == self.getCurrentAoi():
>                 dc.SetPen(pen2)
>             else:
>                 dc.SetPen(pen1)
>             aoi.drawAoi(dc)
>
>     def setNewAoi(self, aoi):
>         dc = self.getUpdatedDC()
>         self.redrawAois(dc)  # undraw aoi's
>         self.aoiList.append(aoi)  # append to end of list
>         self.currentAoi = self.getAoiListLength() - 1
>         self.redrawAois(dc)  # redraw aoi's
>
>     def getAoiListLength(self):
>         return len(self.aoiList)
>
>     def getCurrentAoi(self):
>         if self.getAoiListLength() > 0:
>             return self.aoiList[self.currentAoi]
>         else:
>             return None
>
> #------------------ Class mtFrame
> ------------------------------------------------
>
> class mtFrame(wxFrame):
>     def __init__(self, parent, ID, title):
>         wxFrame.__init__(self, parent, ID, title, wxDefaultPosition,
> wxSize(650, 500))
>         self.iPanel = mtImagePanel(self, -1)
>         self.im = None
>         self.imageLoaded = false
>         self.currentfile = ""
>
>         # Construct a MenuBar
>         self.menuBar = wxMenuBar()
>         # Construct "File" menu
>         self.menuFile = wxMenu()
>         self.open = self.menuFile.Append(ID_FILE_OPEN, "&Open","Open
> file")
>         EVT_MENU(self, ID_FILE_OPEN, self.OnOpen)
>         EVT_UPDATE_UI(self, ID_FILE_OPEN, self.OnOpenUpdate)
>         self.menuFile.AppendSeparator()
>         self.menuFile.Append(ID_FILE_EXIT, "E&xit", "Terminate the
> program")
>         EVT_MENU(self, ID_FILE_EXIT,  self.OnExit)
>         self.menuBar.Append(self.menuFile, "&File");
>         # Construct "Aoi" menu
>         self.menuAoi = wxMenu()
>         self.submenuAoiNew = wxMenu()
>         self.submenuAoiNew.Append(ID_AOI_RECTANGLE, "rectangle", "draw
> new rectangle")
>         EVT_MENU(self, ID_AOI_RECTANGLE, self.OnNewRectangle)
>         self.menuAoi.AppendMenu(ID_AOI_NEWAOI, '&New',
> self.submenuAoiNew, 'new aois')        
>         self.menuAoi.Append(ID_TRACK_ONE, "&Track One", "")
>         EVT_MENU(self, ID_TRACK_ONE,  self.OnTrackOne)
>         self.menuBar.Append(self.menuAoi, "&Aoi")
>         # Add all the menus to the Menu Bar
>         self.SetMenuBar(self.menuBar)
>
>     # Updates image depended menus
>     def OnOpenUpdate(self, event):
>         self.menuAoi.Enable(ID_AOI_NEWAOI, self.imageLoaded)
>         self.menuAoi.Enable(ID_TRACK_ONE, self.imageLoaded)
>
>     def OnTrackOne(self, event):
>         if self.iPanel.getAoiListLength() > 0:
>             self.trackOne()
>
>     def trackOne(self):
>         dc = self.iPanel.getUpdatedDC()
>         for aoi in self.iPanel.aoiList:
>             aoi.Update(dc)
>
>     def OnNewRectangle(self, event):
>         rect = AoiRectangle(self, 30,30,200,200)
>         self.iPanel.setNewAoi(rect)
>
>     def OnOpen(self, event):
>         fd = wxFileDialog(self, "Open Image", "/home/klimek/Images",
> "*.bmp",
>                 "All files (*.*)|*.*|BMP files (*.bmp)|*.bmp|PNG files
> (*.png)|*.png", wxOPEN)
>         if fd.ShowModal() == wxID_OK:
>             self.currentfile = fd.GetPath()
>             self.loadImage(self.currentfile)
>             self.iPanel.Refresh(true)
>         fd.Destroy()
>
>     def loadImage(self, file):
>         if self.fileExists(file):
>             try:
>                 self.im = Image.open(file)
>                 self.iPanel.display(self.im)
>                 self.imageLoaded = true
>                 return true
>             except IOError:
>                 print "can't open the file"
>                 return false
>         else:
>             return false
>
>     def fileExists(self, path):   # check if the file exists
>         try:
>             f = open(path,'r')
>             f.close()
>             return true
>         except IOError:
>             return false
>
>     def OnCloseWindow(self, event):
>         self.Destroy()
>
>     def OnExit(self, event):
>         self.Close(true)
>
> #---------------------- Aoi Class
> -----------------------------------------
>
> class Aoi:
>     def __init__(self, parent, x1, y1, x2, y2):
>         self.parent = parent
>         self.x1 = x1
>         self.y1 = y1
>         self.x2 = x2
>         self.y2 = y2
>
>     def Update(self, dc):
>         pass
>     def drawAoi(self, dc):
>         pass
>
> #-------------------------------------------------------------------------
> --
>
> class AoiRectangle(Aoi):
>     def __init__(self, parent, x1, y1, x2, y2):
>         Aoi.__init__(self, parent, x1, y1, x2, y2)
>
>     def drawAoi(self, dc):
>         w = self.x2 - self.x1
>         h = self.y2 - self.y1
>         dc.DrawRectangle(self.x1, self.y1, w, h)
>
>     def drawCross(self, dc, p):
>         x = p[0]
>         y = p[1]
>         x = x + self.x1
>         y = y + self.y1
>         dc.DrawLine(x-5, y, x+5, y)
>         dc.DrawLine(x, y-5, x, y+5)
>
>     def Update(self, dc):
>         r = (self.x1+1, self.y1+1, self.x2-2, self.y2-2)
>         aoiImage = self.parent.im.crop(r)
>         aoiImage = self.Threshold(aoiImage, 128) # threshold the AOI
>         self.parent.im.paste(aoiImage, r)
>         self.parent.iPanel.displayAoi(aoiImage, r)
>
>         ## UNCOMMENT THESE 4 LINES OUT
> ##        pt = self.CalculateSomething()  # this takes a few seconds
> ##        pen = wxPen(wxNamedColour('RED'))
> ##        dc.SetPen(pen)
> ##        self.drawCross(dc, pt)
>         #######
>
>     def CalculateSomething(self):  # kill a few seconds and return some
> coordinates
>         b = 0
>         for i in range(0, 1000000):
>             b = i
>         return (50, 50)
>
>     def Threshold(self, image, value):
>         out = image.point(lambda i, v=value: i > v and 255) # 255 if
> greater than value            
>         return out
>
> #-------------------------------------------------------------------------
> --
>
> class mtApp(wxApp):
>     def OnInit(self):
>         frame = mtFrame(NULL, -1, "wxRedraw2")
>         frame.Show(true)
>         self.SetTopWindow(frame)
>         return true
>
> app = mtApp(0)
> app.MainLoop()
>
>
>
>
>
>
> --
> ---------------------
> Robert B. Klimek
> NASA Glenn Research Center
> [hidden email]
> ---------------------
>
> _______________________________________________
> wxPython-users maillist  -  [hidden email]
> http://starship.python.net/mailman/listinfo/wxpython-users

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users