Adding text to a line between two shapes

When adding text to a line, a large rectangle is created in the background
of the text with the same color as the canvas. This means that the line
doesn't show when the distance is short between the two connected shapes. It
also overwrites the shapes when getting close enough.

Obvioulsly the background color of the text should be transparent. Is there
any way to get around this problem?

Did you understand the problem at all? :slight_smile:

Cheers,
Thomas

Thomas Aanensen wrote:

When adding text to a line, a large rectangle is created in the background
of the text with the same color as the canvas. This means that the line
doesn't show when the distance is short between the two connected shapes. It
also overwrites the shapes when getting close enough.

Obvioulsly the background color of the text should be transparent. Is there
any way to get around this problem?

For OGL I don't know. If you are drawing the text yourself then yes, you can call wxDC.SetBackgroundMode.

路路路

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

For OGL I don't know. If you are drawing the text yourself then yes,
you can call wxDC.SetBackgroundMode.

Is there anyone working on OGL anymore? Are they available for questions?

Anyway, I got it working, although I don't really understand why!!!
Here's how I did it, if someone is interested:

1. dc = wxClientDC(canvas)
2. line.GetRegions()[0].SetFormatMode(4)
3. line.FormatText(dc, iRefName, 0)
4. line.AddText(iRefName)

The line has three text regions
2. First I changed the format mode for the centre region (0). I set it to 4,
although this is not documented, so I don't know what it means (got it from
a source code on the net).
3. Then I had to call FormatText. But the documentation is wrong again; The
method takes three arguments; a dc, the text be shown, and the region number
(0) to format.
4. By now everything should work fine. But it donesn't. For some reason the
text is shown twice!By coincidence I found out that if I added the text
again one of the texts dissappear. Now I got it the way I wanted it!

It would be great if someone could explain this to me, althoug I'm happy
enough that it works :slight_smile:

Cheers,
Thomas

Thomas Aanensen wrote:

For OGL I don't know. If you are drawing the text yourself then yes,
you can call wxDC.SetBackgroundMode.

Is there anyone working on OGL anymore?

No, although there may be a Python clone of it being contributed soon.

路路路

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!