I'm trying to draw line to an existing image, the problem is that the image doesn't update/refresh itself.
In the example there's one button, but when pressing the button it changes the image but the image doesn't show up, and if I move other windows over my application window it will then refresh my application window and reveals the image.
so what I'm trying to do is animating (moving) a line over existing image
also, I don't want to load image everytime I draw on to it, need to make a copy of the loaded image somehow?
problems are commented in the example code
[code=python]
import wx
class MyFrame(wx.Fram e):
def __init__(self):
self.frame1 = wx.Frame(None, title="test", id=-1, size=(700, 500))
self.panel1 = wx.Panel(self.f rame1)
Button1 = wx.Button(self. panel1, -1, "update photo", (150,420))
Button1.Bind(wx .EVT_BUTTON, self.update_pic )
self.statbmp = wx.StaticBitmap (self.panel1, id=-1, pos=(500,250), size=(150,150))
self.image = wx.Bitmap("phot o.bmp")
canvas_dc = wx.MemoryDC(sel f.image)
canvas_dc.DrawB itmap(self.imag e, 0, 0)
canvas_dc.DrawL ine(x1=75, y1=97, x2=12, y2=31)
self.statbmp.Se tBitmap(self.im age)
self.frame1.Sho w(True)
def update_pic(self , event):
self.image = wx.Bitmap("phot o.bmp") # I don't want load this from Harddisk everytime, how to load this from memory
canvas_dc = wx.MemoryDC(sel f.image)
canvas_dc.DrawB itmap(self.imag e, 0, 0)
canvas_dc.DrawL ine(x1=75, y1=97, x2=22, y2=31)
self.statbmp.Se tBitmap(self.im age) #Image don't get updated/refreshed(?), I see only white blank space
app = wx.PySimpleApp( )
f = MyFrame()
app.MainLoop()
[/code]
In the example there's one button, but when pressing the button it changes the image but the image doesn't show up, and if I move other windows over my application window it will then refresh my application window and reveals the image.
so what I'm trying to do is animating (moving) a line over existing image
also, I don't want to load image everytime I draw on to it, need to make a copy of the loaded image somehow?
problems are commented in the example code
[code=python]
import wx
class MyFrame(wx.Fram e):
def __init__(self):
self.frame1 = wx.Frame(None, title="test", id=-1, size=(700, 500))
self.panel1 = wx.Panel(self.f rame1)
Button1 = wx.Button(self. panel1, -1, "update photo", (150,420))
Button1.Bind(wx .EVT_BUTTON, self.update_pic )
self.statbmp = wx.StaticBitmap (self.panel1, id=-1, pos=(500,250), size=(150,150))
self.image = wx.Bitmap("phot o.bmp")
canvas_dc = wx.MemoryDC(sel f.image)
canvas_dc.DrawB itmap(self.imag e, 0, 0)
canvas_dc.DrawL ine(x1=75, y1=97, x2=12, y2=31)
self.statbmp.Se tBitmap(self.im age)
self.frame1.Sho w(True)
def update_pic(self , event):
self.image = wx.Bitmap("phot o.bmp") # I don't want load this from Harddisk everytime, how to load this from memory
canvas_dc = wx.MemoryDC(sel f.image)
canvas_dc.DrawB itmap(self.imag e, 0, 0)
canvas_dc.DrawL ine(x1=75, y1=97, x2=22, y2=31)
self.statbmp.Se tBitmap(self.im age) #Image don't get updated/refreshed(?), I see only white blank space
app = wx.PySimpleApp( )
f = MyFrame()
app.MainLoop()
[/code]