wxTextCtrl question: How to deal with rich-text content

Hi all,

I'm working with wxPython2.1.4.2 on MSwin32.
I have two problems using the wxTextCtrl with the wxTE_RICH option set:

First question(s):

- How can I get the complete content of the control including the style
  attributes set for the individual characters ?

Alternativly:

- How can I get the content of the control in rich text format ?
  The wxTextCtrl.GetValue() method returns simply the raw character data.

Second question:

- The control should allow the user to use different fonts, including greek
  letters from the MSSymbol font.
  When creating an wxFont Object using
    symFont = wxFont(14,wxSWISS,wxNORMAL,wxNORMAL,0,"Symbol",-1)
  and creating an wxTextAttr with it
    symAttr = wxTextAttr(wxColor(0,0,0),wxColor(255,255,255),symFont)
  the
    wxTextCtrl.SetStyle(a,b,symAttr)
   method works well, but wxTextCtrl.SetDefaultStyle(symAttr) refuses to
work,
   i.e. any text entered has not the desired attribute.

Any help would be appreciated.

Thanks in advance.

  Hannes Grund

Hannes Grund wrote:

Hi all,

I'm working with wxPython2.1.4.2 on MSwin32.
I have two problems using the wxTextCtrl with the wxTE_RICH option set:

First question(s):

- How can I get the complete content of the control including the style
  attributes set for the individual characters ?

Alternativly:

- How can I get the content of the control in rich text format ?
  The wxTextCtrl.GetValue() method returns simply the raw character data.

There isn't any way to do that yet.

Second question:

- The control should allow the user to use different fonts, including greek
  letters from the MSSymbol font.
  When creating an wxFont Object using
    symFont = wxFont(14,wxSWISS,wxNORMAL,wxNORMAL,0,"Symbol",-1)
  and creating an wxTextAttr with it
    symAttr = wxTextAttr(wxColor(0,0,0),wxColor(255,255,255),symFont)
  the
    wxTextCtrl.SetStyle(a,b,symAttr)
   method works well, but wxTextCtrl.SetDefaultStyle(symAttr) refuses to
work,
   i.e. any text entered has not the desired attribute.

Are you wanting all the text to be this font, or just the newly typed stuff? For the former just do textCtrl.SetFont(symFont). For the latter perhaps you could set the wxTextAttr as each key is typed?

···

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

Hannes Grund wrote:
> Hi all,
>
> I'm working with wxPython2.1.4.2 on MSwin32.
> I have two problems using the wxTextCtrl with the wxTE_RICH option set:
>
>
> First question(s):
>
> - How can I get the complete content of the control including the style
> attributes set for the individual characters ?
>
> Alternativly:
>
> - How can I get the content of the control in rich text format ?
> The wxTextCtrl.GetValue() method returns simply the raw
character data.

There isn't any way to do that yet.

Even if I access the underlying (MFC ?) object ?
Can this be done in some way via the window handle ?

>
> Second question:
>
> - The control should allow the user to use different fonts,
including greek
> letters from the MSSymbol font.
> When creating an wxFont Object using
> symFont = wxFont(14,wxSWISS,wxNORMAL,wxNORMAL,0,"Symbol",-1)
> and creating an wxTextAttr with it
> symAttr = wxTextAttr(wxColor(0,0,0),wxColor(255,255,255),symFont)
> the
> wxTextCtrl.SetStyle(a,b,symAttr)
> method works well, but wxTextCtrl.SetDefaultStyle(symAttr) refuses to
> work,
> i.e. any text entered has not the desired attribute.
>

Are you wanting all the text to be this font, or just the newly typed
stuff? For the former just do textCtrl.SetFont(symFont). For the
latter perhaps you could set the wxTextAttr as each key is typed?

No, I want any selected text (if any) to be this font (which works well,
using
SetStyle(start,end,symAttr) AND any subsequent entered text to be this font
(which works surprisingly NOT, at least using SetDefaultStyle(symAttr)).
What I furthermore found out is the following:
When constructing the wxFont object from

    e = wxNativeFontInfo()
    e.FromString("0;-19;0;0;0;400;0;0;0;2;3;2;1;18;Symbol")
    symFont.SetNativeFontInfo(e)
    symAttr = wxTextAttr(wxColor(0,0,0),wxColor(255,255,255),symFont)

the above works.
The font-info string was obtained by selecting the Symbol font using a
wxFontDialog and then
reading <wxFont>.GetNativeFontInfoUserDesc().
Does the font info string cotain "more" information than those passed (or
passable) to the
wxFont constructor ?
Is there any place where this (platform depended) string is documented for
MSWIn32 ?

Thanks,

  Hannes.

···

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Hannes Grund wrote:

Hannes Grund wrote:

Hi all,

I'm working with wxPython2.1.4.2 on MSwin32.
I have two problems using the wxTextCtrl with the wxTE_RICH option set:

First question(s):

- How can I get the complete content of the control including the style
attributes set for the individual characters ?

Alternativly:

- How can I get the content of the control in rich text format ?
The wxTextCtrl.GetValue() method returns simply the raw

character data.

There isn't any way to do that yet.

Even if I access the underlying (MFC ?) object ?
Can this be done in some way via the window handle ?

I just meant that there is no way to do it from wx. You can get the window handle with window.GetHandle and then use it with either one of the win32all modules, or with ctypes module.

No, I want any selected text (if any) to be this font (which works well,
using
SetStyle(start,end,symAttr) AND any subsequent entered text to be this font
(which works surprisingly NOT, at least using SetDefaultStyle(symAttr)).
What I furthermore found out is the following:
When constructing the wxFont object from

    e = wxNativeFontInfo()
    e.FromString("0;-19;0;0;0;400;0;0;0;2;3;2;1;18;Symbol")
    symFont.SetNativeFontInfo(e)
    symAttr = wxTextAttr(wxColor(0,0,0),wxColor(255,255,255),symFont)

the above works.
The font-info string was obtained by selecting the Symbol font using a
wxFontDialog and then
reading <wxFont>.GetNativeFontInfoUserDesc().
Does the font info string cotain "more" information than those passed (or
passable) to the
wxFont constructor ?

Probably, I think it is just a streaming of the win32 LOGFONT structure.

Is there any place where this (platform depended) string is documented for
MSWIn32 ?

Not in wx as it is supposed to be a blackbox that you never deal with directly. You can read about LOGFONT in msdn.

···

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