[Image-SIG] that's enough

Chris Mitchell chris.mit7 at gmail.com
Tue Jul 20 07:11:05 CEST 2010


Here is how I do it with wxPython.  You might need to change a few
things to get it to work for your instance since I copied/pasted part
of my image viewer program to try and make a minimal example.
Basically you need to run the simulation then call
self.imageholder.Refresh(), which will execute the code in your
OnPaint, which is linked to ReDraw

class ImageFrame(wx.Frame):
    def __init__(self, parent, image):
        wx.Frame.__init__(self, parent, title="image frame")
        self.image = image
        self.im = Image.open(image)
        self.parent = parent
        self.framenum = 0
        self.imagepanel = wx.Panel(self, -1)
        self.imageholder = wx.StaticBitmap(self.imagepanel, -1,
self.picture, (0,0))
        self.imageholder.Bind(wx.EVT_PAINT, self.OnPaint)

    def OnPaint(self, event):
        self.ReDraw(wx.BufferedPaintDC(self.imageholder))

    def ReDraw(self, dc):
        picture = wx.Image(self.image, wx.BITMAP_TYPE_TIF, self.framenum)
        picture=wx.BitmapFromImage(picture)
        dc.DrawBitmap(picture,0,0)

On Mon, Jul 19, 2010 at 10:33 PM, Jack Uretsky <jlu at hep.anl.gov> wrote:
> Hi Chris-
>        Thabks. That's really not the issue here.  My problem is that I very
>  successfully flash a picture, but then I don't know how to get rid of it to
> flash another one.
>                                Regards,
>                                        Jack (MIT '45, '56)
>
>
> "Trust me.  I have a lot of experience at this."
>                General Custer's unremembered message to his men,
>                just before leading them into the Little Big Horn Valley
>
>
>
>
> On Mon, 19 Jul 2010, Chris Mitchell wrote:
>
>> Hey Jack,
>>
>> Are you trying to model fluorophores?  If you want to model a Poisson
>> process you don't need any special packages, just take the negative
>> log of a uniformly distributed random variable from 0-1.
>> Mathematically, this would be saying: y = r*e(-rt), where y is a
>> uniform random variable, then take the integral and then the inverse
>> (how you turn a uniform distribution into any distribution you want).
>>
>> Chris
>>
>> On Mon, Jul 19, 2010 at 7:18 PM, Jack Uretsky <jlu at hep.anl.gov> wrote:
>>>
>>> Hi Chris-
>>> In answer to your question,
>>> this is a simulation.  The "events" are program generated; I'm trying to
>>> approximate a Poisson process, so the times between event pairs are
>>> exponentially distributed.
>>>                        Regards,
>>>                                Jack
>>>
>>> "Trust me.  I have a lot of experience at this."
>>>                General Custer's unremembered message to his men,
>>>                just before leading them into the Little Big Horn Valley
>>>
>>>
>>>
>>>
>>> On Mon, 19 Jul 2010, Christopher Barker wrote:
>>>
>>>> Jack Uretsky wrote:
>>>>>
>>>>>    I have a sequence of events ocurring in real time.  To each event I
>>>>> display a corresponing .jpg picture.  The number of events may be in
>>>>> the
>>>>> hundreds.  There are eight pictures.
>>>>
>>>> where are these "events" coming from?
>>>>
>>>> In any case, one route is to have a main wxPython application. In its
>>>> OnInit method, start up another thread that runs the code that listens
>>>> for
>>>> events.
>>>>
>>>> In that code, when you get an event, call:
>>>>
>>>> wx.CallAfter(some_func_to_update_image)
>>>>
>>>> In some_func_to_update_image()
>>>>
>>>> You, well, update the image in your wxPython code. I think I already
>>>> posted an example of how to do that.
>>>>
>>>> You put the listening code in a separate thread, so it won't block the
>>>> wxPython MainLoop -- if all you are doing is displaying these images,
>>>> that
>>>> may not be necessary, though you'll have to do something so that the
>>>> user
>>>> can at least interact enough with the GUI enough to quit it.
>>>>
>>>> wx.CallAfter() is a way to deal with the fact that wxPython is not
>>>> thread
>>>> safe, so you can't make GUI calls directly from another thread.
>>>>
>>>> HTH,
>>>>
>>>> -Chris
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Christopher Barker, Ph.D.
>>>> Oceanographer
>>>>
>>>> Emergency Response Division
>>>> NOAA/NOS/OR&R            (206) 526-6959   voice
>>>> 7600 Sand Point Way NE   (206) 526-6329   fax
>>>> Seattle, WA  98115       (206) 526-6317   main reception
>>>>
>>>> Chris.Barker at noaa.gov
>>>> _______________________________________________
>>>> Image-SIG maillist  -  Image-SIG at python.org
>>>> http://mail.python.org/mailman/listinfo/image-sig
>>>>
>>> _______________________________________________
>>> Image-SIG maillist  -  Image-SIG at python.org
>>> http://mail.python.org/mailman/listinfo/image-sig
>>>
>


More information about the Image-SIG mailing list