[wxPython] Font face specification with wxStyledTextCtrl

Hi all,

I've been working on a control for run-time configuration of wxStyledTextCtrl style values. So far just about everything has been working (it's a long way from finished (it still uses styleIDs as names, instead of user-friendly names), but it seems to _work_). I have, however, encountered a problem (or three).

The basic design is that I have a data model of styles (the style.py module), and these styles are applied to a visualisation wxStyledTextCtrl whenever I want to update the values in the editing control (the primary application would just apply them at startup and when exiting from the configuration dialogue). This works fine for foreground and background colours, bold, italic, and underline. When a value changes, I reset the wxStyledTextCtrl's style set, then apply all of the style-sets, then re-colour the text.

The big problem comes with font face specification. I'm using a wxFontEnumerator to get the list of faces (see FontChoice in styleeditor.py). When I set the style's font face attribute, however, the face doesn't change in the window (the face-name _is_ included in the style-configuration string, it just doesn't seem to change anything in the wxStyledTextCtrl).

So, I'm wondering, is there a trick I'm missing?

Second problem:
  For some reason, setting font sizes is very tricky. Individual styles don't seem to like having font sizes larger than the "normal" for the control (when the moon is in certain phases and aquarius is in ascendence), and often I wind up with the entire control taking line-sizes that are the maximum of the current styles.

Third problem:
  The eolfilled parameter seems to have no effect. I was under the impression it would make e.g. unclosed strings show up as including the end of the line. Is there a different effect intended?

You can get the two modules (which require wxPython 2.3.2.1 and a Python that includes xml.dom.minidom, as it uses the colourselect control and mini-dom for parsing) at:

http://members.rogers.com/mcfletch/programming/fontproblem.tar.gz

Any thoughts would be appreciated,
Mike

···

--
_______________________________________
   Mike C. Fletcher
   http://members.rogers.com/mcfletch/

Mike C. Fletcher:

The big problem comes with font face specification. I'm using a
wxFontEnumerator to get the list of faces (see FontChoice in
styleeditor.py). When I set the style's font face attribute, however,
the face doesn't change in the window (the face-name _is_ included in
the style-configuration string, it just doesn't seem to change anything
in the wxStyledTextCtrl).

   Change line 77 of style.py to:
  "font": ('face', str, None),

For some reason, setting font sizes is very tricky. Individual styles
don't seem to like having font sizes larger than the "normal" for the
control (when the moon is in certain phases and aquarius is in
ascendence), and often I wind up with the entire control taking
line-sizes that are the maximum of the current styles.

   All lines are the same height and this is the maximum of the current
styles' heights.

The eolfilled parameter seems to have no effect. I was under the
impression it would make e.g. unclosed strings show up as including the
end of the line. Is there a different effect intended?

   The background colour has to be specified for eolfilled to have an
effect.

   Neil

Doh! <smacks head> I can't believe I missed that. I had the same problem with fore and back (it's why that lookup table exists), and assumed I'd looked it up for font/face... guess I didn't. Thanks.

Line-height: guess I'll just deal with it then.

eolfilled: I still don't see a difference (even with background specified). The background colours in one character beyond the end of the text (as if there were a newline character there), but switching eolfilled on/off doesn't affect it, and it isn't stretching to the end of the line (that is, the right-hand side of the control).

Thanks Neil, much appreciated,
Mike

Neil Hodgson wrote:

Mike C. Fletcher:

The big problem comes with font face specification. I'm using a

...

   Change line 77 of style.py to:
  "font": ('face', str, None),

...

   All lines are the same height and this is the maximum of the current
styles' heights.

The eolfilled parameter seems to have no effect. I was under the
impression it would make e.g. unclosed strings show up as including the
end of the line. Is there a different effect intended?

   The background colour has to be specified for eolfilled to have an
effect.

...

Mike C. Fletcher:

eolfilled: I still don't see a difference (even with background
specified). The background colours in one character beyond the end of
the text (as if there were a newline character there), but switching
eolfilled on/off doesn't affect it, and it isn't stretching to the end
of the line (that is, the right-hand side of the control).

   Change line 82 of style.py to:
  "endoflinefilled":('eol', bool, 0),

Robin: You might want to change 'eolfilled' to 'eol' in the demo
wxStyledTextCtrl_2.

   Neil

Again, thanks. At least this time I can blame Robin :wink: .

Enjoy yourselves,
Mike

Neil Hodgson wrote:

Mike C. Fletcher:

eolfilled: I still don't see a difference (even with background
specified). The background colours in one character beyond the end of

...

   Change line 82 of style.py to:
  "endoflinefilled":('eol', bool, 0),

Robin: You might want to change 'eolfilled' to 'eol' in the demo
wxStyledTextCtrl_2.

...

Robin: You might want to change 'eolfilled' to 'eol' in the demo
wxStyledTextCtrl_2.

Oops, thanks.

···

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