I need a multi-line text editor over a jpeg image. It doesn't need to be
styled. Can anyone suggest how I can do this short of writing my own editor
and using a DC?
Please forgive me if this is a duplicate post. I sent this when I first
signed up and I never received a copy. (Mybe I'm not supposed to see my own
posts?)
---- original posting ----
I need a multi-line text editor over a jpeg image. It doesn't need to be
styled. Can anyone suggest how I can do this short of writing my own editor
and using a DC?
Mark Hahn wrote:
I need a multi-line text editor over a jpeg image. It doesn't need to be
styled. Can anyone suggest how I can do this short of writing my own editor
and using a DC?
On Windows you can probably do this by catching the EVT_ERASE_BACKGROUND event and drawing the image on the DC provided there, but I doubt it would work on the other platforms.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
I need a multi-line text editor over a jpeg image. It doesn't need to be
styled. Can anyone suggest how I can do this short of writing my own
editor
and using a DC?
On Windows you can probably do this by catching the EVT_ERASE_BACKGROUND
event and drawing the image on the DC provided there, but I doubt it
would work on the other platforms.
Thanks mucho! I am only writing this for Windows, so I gave your suggestion
a try:
class trasparent_text_ctrl(wx.TextCtrl):
def __init__(self, parent, pos, size):
wx.TextCtrl.__init__(self, parent, -1, '', pos, size)
wx.EVT_ERASE_BACKGROUND(self, self.OnErase)
def OnErase(self, event):
event.GetDC().DrawBitmap(bmp, 0, 0)
event.Skip()
I set a breakpoint at event.Skip() and I could clearly see that my bitmap
was drawn, but then later, the textctrl went ahead and drew the border and
white background over my bitmap.
Any more ideas?
Mark Hahn wrote:
I need a multi-line text editor over a jpeg image. It doesn't need to be
styled. Can anyone suggest how I can do this short of writing my owneditor
and using a DC?
On Windows you can probably do this by catching the EVT_ERASE_BACKGROUND
event and drawing the image on the DC provided there, but I doubt it
would work on the other platforms.Thanks mucho! I am only writing this for Windows, so I gave your suggestion
a try:class trasparent_text_ctrl(wx.TextCtrl):
def __init__(self, parent, pos, size):
wx.TextCtrl.__init__(self, parent, -1, '', pos, size)
wx.EVT_ERASE_BACKGROUND(self, self.OnErase)
def OnErase(self, event):
event.GetDC().DrawBitmap(bmp, 0, 0)
event.Skip()I set a breakpoint at event.Skip() and I could clearly see that my bitmap
was drawn, but then later, the textctrl went ahead and drew the border and
white background over my bitmap.Any more ideas?
Don't call event.Skip(). You want to replace the default behaviour for the event, but calling Skip tells the system to keep looking for a handler or let the system do the default if no more handlers are found.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Don't call event.Skip(). You want to replace the default behaviour for
the event, but calling Skip tells the system to keep looking for a
handler or let the system do the default if no more handlers are found.
It worked! Thanks. I thought Skip() meant to skip processing the rest of
the chain. I'm not sure exactly what to think it means now
Mark Hahn wrote:
Don't call event.Skip(). You want to replace the default behaviour for
the event, but calling Skip tells the system to keep looking for a
handler or let the system do the default if no more handlers are found.It worked! Thanks. I thought Skip() meant to skip processing the rest of
the chain. I'm not sure exactly what to think it means now
Yeah, it was a poorly chosen name, but that was before my time so I don't understand the reasons behind it. You can think of it as meaning "Skip the code that sets found-an-event-handler to True."
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Don't call event.Skip(). You want to replace the default behaviour for
the event, but calling Skip tells the system to keep looking for a
handler or let the system do the default if no more handlers are found.It worked! Thanks. I thought Skip() meant to skip processing the rest
of
the chain. I'm not sure exactly what to think it means now
Yeah, it was a poorly chosen name, but that was before my time so I
don't understand the reasons behind it. You can think of it as meaning
"Skip the code that sets found-an-event-handler to True."
Oops... In my excitement I spoke too soon. I stopped at a breakpoint when
it looked like it was working. Whether I have the Skip() or not, after my
bitmap painting is done in my capture of the erase event, the textctrl
paints the background color and the borders without me getting another erase
event. The window and the panes work fine but the text control doesn't.
Oh well, it was worth a try. I've always wanted to write a text editor
(sigh).
Mark Hahn wrote:
Don't call event.Skip(). You want to replace the default behaviour for
the event, but calling Skip tells the system to keep looking for a
handler or let the system do the default if no more handlers are found.It worked! Thanks. I thought Skip() meant to skip processing the rest
of
the chain. I'm not sure exactly what to think it means now
Yeah, it was a poorly chosen name, but that was before my time so I
don't understand the reasons behind it. You can think of it as meaning
"Skip the code that sets found-an-event-handler to True."Oops... In my excitement I spoke too soon. I stopped at a breakpoint when
it looked like it was working. Whether I have the Skip() or not, after my
bitmap painting is done in my capture of the erase event, the textctrl
paints the background color and the borders without me getting another erase
event. The window and the panes work fine but the text control doesn't.
Bummer.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!