suggestion about richtextctrl

Hi Andrea,

In the ANN: RibbonBar thread, you wrote:

The trouble is, I haven't got any new ideas for new widgets. I am actually
playing with a pure-Python version of a Mac-like Dock (or BubbleBar,
or FishEye menu or whatever you like), but it's just an eye-catching
small thing. I am always open to suggestions :smiley:

I have a suggestion, though it is a rather large project to do.
Before I mention it, thanks again for the RibbonBar and the newest
work on GUI2Exe, they both are great additions.

The suggestion: A fully (mostly) functional RichTextCtrl (RTC).

I only mention this one because you have taken things that are written
in C++ and "translated" them to pure Python (like AUI). This seems like
a big class that may not be anywhere as able to be redone in Python, but
I really don't know. The current wxRichTextCtrl has been around for about
three years and started life with a list of important features that were still
missing. One of the most important of those is living up to its name: being
able to read and save actual rich text. Right now if you copy formatted text
from the web or from a Word or OpenOffice document, and paste it into the
RTC, you lose all the formatting, and just get plain text pasted in. Likewise,
if you have a nice block of formatted text, with bolds and italics and such,
and copy it into the clipboard and past it into Word, you again lose all the
formatting. The only way to sort of get it into Word or OO is to save it as
HTML, then load it as HTML, but then to go from that to a .doc file or just
a .rtf file is not really possible. For those who want to be able to write
something within their Python app and use it elsewhere, this is a deal
breaker. It's a shame, since .NET apps get this sort of thing
automatically, AFAIK and users would be really put off to not have
"standard" word processing-like behavior in a rich text control. Text
areas really should integrate seamlessly with the web and with word
processing programs.

I had wanted to have something to serve as a small low-featured "word
pad" in Python, for use in a planned app that I was hoping to do, and
was pleased when RTC came out, but it never seemed to get updated.
I'd written Julian Smart, its author, and he was very nice about
it and had hoped someone might come through with the code to add rft
(not to mention the other key features like bullets and justified text, a few
bugs worked out, and some other things) but just isn't able to get to the
updates and I assume they will never happen. Apparently going to RTF
is pretty tricky.

I write you about this off-list because I didn't want to pester the
issue/Julian
again publicly. I don't know C++ and so have no hope of being helpful on this
one, but I thought I'd at least run this by you. I'm actually
surprised that three
years have gone by and there hasn't been enough developer interest to see this
through to a truly functional control.

My other interest in wxPython is more support for gradients on panels in
terms of allowing controls to allow the gradient to show through on Windows.
I now replace all staticTextCtrls with drawn-on text, but might eventually try
to make generic checkboxes and radiobuttons for the same purpose.

Thanks again for all your awesome contributions to wxPython! :smiley:
Che

Well, I think the reason .NET apps get it "for free" is because the
new versions of MS Office are now written in .NET. I just looked up
the spec and it looks kind of ugly: Rich Text Format (RTF) Specification, version 1.6 | Microsoft Learn

I'm sure Tim R. will have some interesting input since he seems to
know a lot about low-level Windows stuff.

···

On Oct 19, 12:37 pm, C M <cmpyt...@gmail.com> wrote:

Hi Andrea,

In the ANN: RibbonBar thread, you wrote:

> The trouble is, I haven't got any new ideas for new widgets. I am actually
> playing with a pure-Python version of a Mac-like Dock (or BubbleBar,
> or FishEye menu or whatever you like), but it's just an eye-catching
> small thing. I am always open to suggestions :smiley:

I have a suggestion, though it is a rather large project to do.
Before I mention it, thanks again for the RibbonBar and the newest
work on GUI2Exe, they both are great additions.

The suggestion: A fully (mostly) functional RichTextCtrl (RTC).

I only mention this one because you have taken things that are written
in C++ and "translated" them to pure Python (like AUI). This seems like
a big class that may not be anywhere as able to be redone in Python, but
I really don't know. The current wxRichTextCtrl has been around for about
three years and started life with a list of important features that were still
missing. One of the most important of those is living up to its name: being
able to read and save actual rich text. Right now if you copy formatted text
from the web or from a Word or OpenOffice document, and paste it into the
RTC, you lose all the formatting, and just get plain text pasted in. Likewise,
if you have a nice block of formatted text, with bolds and italics and such,
and copy it into the clipboard and past it into Word, you again lose all the
formatting. The only way to sort of get it into Word or OO is to save it as
HTML, then load it as HTML, but then to go from that to a .doc file or just
a .rtf file is not really possible. For those who want to be able to write
something within their Python app and use it elsewhere, this is a deal
breaker. It's a shame, since .NET apps get this sort of thing
automatically, AFAIK and users would be really put off to not have
"standard" word processing-like behavior in a rich text control. Text
areas really should integrate seamlessly with the web and with word
processing programs.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hi Che,

2009/10/19 C M:

Hi Andrea,

In the ANN: RibbonBar thread, you wrote:

The trouble is, I haven't got any new ideas for new widgets. I am actually
playing with a pure-Python version of a Mac-like Dock (or BubbleBar,
or FishEye menu or whatever you like), but it's just an eye-catching
small thing. I am always open to suggestions :smiley:

I have a suggestion, though it is a rather large project to do.
Before I mention it, thanks again for the RibbonBar and the newest
work on GUI2Exe, they both are great additions.

The suggestion: A fully (mostly) functional RichTextCtrl (RTC).

I only mention this one because you have taken things that are written
in C++ and "translated" them to pure Python (like AUI). This seems like
a big class that may not be anywhere as able to be redone in Python, but
I really don't know. The current wxRichTextCtrl has been around for about
three years and started life with a list of important features that were still
missing. One of the most important of those is living up to its name: being
able to read and save actual rich text. Right now if you copy formatted text
from the web or from a Word or OpenOffice document, and paste it into the
RTC, you lose all the formatting, and just get plain text pasted in. Likewise,
if you have a nice block of formatted text, with bolds and italics and such,
and copy it into the clipboard and past it into Word, you again lose all the
formatting. The only way to sort of get it into Word or OO is to save it as
HTML, then load it as HTML, but then to go from that to a .doc file or just
a .rtf file is not really possible. For those who want to be able to write
something within their Python app and use it elsewhere, this is a deal
breaker. It's a shame, since .NET apps get this sort of thing
automatically, AFAIK and users would be really put off to not have
"standard" word processing-like behavior in a rich text control. Text
areas really should integrate seamlessly with the web and with word
processing programs.

I had wanted to have something to serve as a small low-featured "word
pad" in Python, for use in a planned app that I was hoping to do, and
was pleased when RTC came out, but it never seemed to get updated.
I'd written Julian Smart, its author, and he was very nice about
it and had hoped someone might come through with the code to add rft
(not to mention the other key features like bullets and justified text, a few
bugs worked out, and some other things) but just isn't able to get to the
updates and I assume they will never happen. Apparently going to RTF
is pretty tricky.

I write you about this off-list because I didn't want to pester the
issue/Julian
again publicly. I don't know C++ and so have no hope of being helpful on this
one, but I thought I'd at least run this by you. I'm actually
surprised that three
years have gone by and there hasn't been enough developer interest to see this
through to a truly functional control.

My other interest in wxPython is more support for gradients on panels in
terms of allowing controls to allow the gradient to show through on Windows.
I now replace all staticTextCtrls with drawn-on text, but might eventually try
to make generic checkboxes and radiobuttons for the same purpose.

Thanks again for all your awesome contributions to wxPython! :smiley:

You know, I once started the conversion of RichTextCtrl from C++ to
Python. This was about a year ago. Then I stopped, for 4 almost
independent reasons:

- I know next to nothing about RTF formats, and the task of
implementing it in Python may be way over my head as far as I know.
However, noting that I know nothing about it, it may be simpler than I
thought;
- Some of the classes/methods used in the C++ source code of
RichTextCtrl are unavailable in Python (i.e., wxScrollHelper): these
will require re-implementations in Python (assuming this is possible);
- I used RichTextCtrl in a single app and then never again, as I
didn't feel the need to use it;
- Rendering speed/for loops/function calls are usually much more
expensive in Python than C++: so, even if the wrapped RichTextCtrl
seems fast enough, the pure-Python translation could be a dog.

So, even if a pure-Python translation of RichTextCtrl might not prove
that complicated (the C++ source is very nicely documented and very
easily readable), I am not sure it's really worth the trouble.
However, I would really welcome others' suggestions regarding the 4
points I made above: if I could get some help from some
RTF-knowledgeable wxPython developers to implement the RTF copy and
paste formats, then I would definitely take into account your
proposal.

Thank you for your suggestions.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

Hi,

The suggestion: A fully (mostly) functional RichTextCtrl (RTC).

<snip>

I had wanted to have something to serve as a small low-featured "word
pad" in Python, for use in a planned app that I was hoping to do, and
was pleased when RTC came out, but it never seemed to get updated.
I'd written Julian Smart, its author, and he was very nice about
it and had hoped someone might come through with the code to add rft
(not to mention the other key features like bullets and justified text, a few
bugs worked out, and some other things) but just isn't able to get to the
updates and I assume they will never happen. Apparently going to RTF
is pretty tricky.

In order for a RichTextCtrl to truly be a RichTextCtrl it needs to
support text files that use RTF markup.

RTF is an open standard so its specifications can be readily found,
and while it is slightly cryptic its still workable. I have written a
few simple rtf markup generators in the past for various purposes (one
is available in Editra), and I think that writing a full RichText
editor control purely in python would likely have some fairly
significant performance issues.

Writing a control that can parse and render a static version of an rtf
document would probably be fairly easy to depending upon how much of
the rtf standards features you would want to support.

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?). Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

I write you about this off-list because I didn't want to pester the
issue/Julian
again publicly. I don't know C++ and so have no hope of being helpful on this

whoops :wink: looks like you may not have meant to send this email to the list.

Cody

···

On Mon, Oct 19, 2009 at 12:37 PM, C M <cmpython@gmail.com> wrote:

I expect that it will be. Rendering a lot of text with different styles, etc. can be very complex. Before I started working on the wxStyledTextCtrl I toyed with porting Scintilla to Python and it was quite slow.

···

On 10/19/09 11:18 AM, Andrea Gavana wrote:

- Rendering speed/for loops/function calls are usually much more
expensive in Python than C++: so, even if the wrapped RichTextCtrl
seems fast enough, the pure-Python translation could be a dog.

--
Robin Dunn
Software Craftsman

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?).

It does, and also access to the internal objects used to represent the document. Although I'm not sure if there is enough wrapped yet to allow custom document objects to be created in Python.

Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

It would probably just require making a new class derived from RichTextFileHandler that could deal with the RTF format. Unfortunately there isn't a virtualized PyRichTextFileHandler class yet that would allow that to be done from Python.

···

On 10/19/09 11:20 AM, Cody Precord wrote:

--
Robin Dunn
Software Craftsman

Yow! :open_mouth: Little too fast there (I was surprised to see non-Andreas responding
to it!). Perhaps though it is good to get some of this insight from
the other list
members on ways to get at the functionality that is *almost* there (maybe?).

Che

···

On Mon, Oct 19, 2009 at 2:20 PM, Cody Precord <codyprecord@gmail.com> wrote:

Hi,

On Mon, Oct 19, 2009 at 12:37 PM, C M <cmpython@gmail.com> wrote:

The suggestion: A fully (mostly) functional RichTextCtrl (RTC).

<snip>

I had wanted to have something to serve as a small low-featured "word
pad" in Python, for use in a planned app that I was hoping to do, and
was pleased when RTC came out, but it never seemed to get updated.
I'd written Julian Smart, its author, and he was very nice about
it and had hoped someone might come through with the code to add rft
(not to mention the other key features like bullets and justified text, a few
bugs worked out, and some other things) but just isn't able to get to the
updates and I assume they will never happen. Apparently going to RTF
is pretty tricky.

In order for a RichTextCtrl to truly be a RichTextCtrl it needs to
support text files that use RTF markup.

RTF is an open standard so its specifications can be readily found,
and while it is slightly cryptic its still workable. I have written a
few simple rtf markup generators in the past for various purposes (one
is available in Editra), and I think that writing a full RichText
editor control purely in python would likely have some fairly
significant performance issues.

Writing a control that can parse and render a static version of an rtf
document would probably be fairly easy to depending upon how much of
the rtf standards features you would want to support.

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?). Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

I write you about this off-list because I didn't want to pester the
issue/Julian
again publicly. I don't know C++ and so have no hope of being helpful on this

whoops :wink: looks like you may not have meant to send this email to the list.

Thanks for the input, Robin. May I ask what does "virtualized" means
here? What would need to happen in order for this approach to move
forward?

Thanks,
Che

···

On Mon, Oct 19, 2009 at 2:39 PM, Robin Dunn <robin@alldunn.com> wrote:

On 10/19/09 11:20 AM, Cody Precord wrote:

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?).

It does, and also access to the internal objects used to represent the
document. Although I'm not sure if there is enough wrapped yet to allow
custom document objects to be created in Python.

Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

It would probably just require making a new class derived from
RichTextFileHandler that could deal with the RTF format. Unfortunately
there isn't a virtualized PyRichTextFileHandler class yet that would
allow that to be done from Python.

Hello,

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?).

It does, and also access to the internal objects used to represent the
document. Although I'm not sure if there is enough wrapped yet to allow
custom document objects to be created in Python.

Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

It would probably just require making a new class derived from
RichTextFileHandler that could deal with the RTF format. Unfortunately
there isn't a virtualized PyRichTextFileHandler class yet that would
allow that to be done from Python.

Thanks for the input, Robin. May I ask what does "virtualized" means
here?

If something is virtual and you override it in a subclass, the
subclasses method will be called even when calling the method inside a
base classes method implementation.

In python everything is virtual, so this is a detail you don't need to
think about much, but in c++ you must specify what is virtual and what
is not. In wxPython the PyFoo classes expose the virtual methods to be
overridable in Python code, for example see all the DoFoo methods
wx.PyPanel that are not available in wx.Panel)

i.e) Python

class A:
    def fun1(self):
        print "HELLO A"
    def main(self):
        fun1()

class B(A):
    def fun1(self):
        print "HELLO B"

obj = B()
obj.main()

In this case "HELLO B" will be printed even though the 'main' method
is implemented by the baseclass 'A'. This happens because 'fun1' is
'virtualized'.

In C++

class A
{
    void fun1(void) { cout << "HELLO A"; }
    void main(void) { fun1();}
}

class B : public A
{
    void fun1(void) { cout << "HELLO B"; }
}

B obj = B();
obj.main();

This time "HELLO A" will be printed since 'fun1' was not declared as
virtual. So to get the same result as in the python example 'fun1'
would need to have been declared as 'virtual void fun1(void)'.

Cody

···

On Mon, Oct 19, 2009 at 3:33 PM, C M <cmpython@gmail.com> wrote:

On Mon, Oct 19, 2009 at 2:39 PM, Robin Dunn <robin@alldunn.com> wrote:

On 10/19/09 11:20 AM, Cody Precord wrote:

Hi Che,

2009/10/19 C M:

Hi Andrea,

In the ANN: RibbonBar thread, you wrote:

The trouble is, I haven't got any new ideas for new widgets. I am actually
playing with a pure-Python version of a Mac-like Dock (or BubbleBar,
or FishEye menu or whatever you like), but it's just an eye-catching
small thing. I am always open to suggestions :smiley:

I have a suggestion, though it is a rather large project to do.
Before I mention it, thanks again for the RibbonBar and the newest
work on GUI2Exe, they both are great additions.

The suggestion: A fully (mostly) functional RichTextCtrl (RTC).

I only mention this one because you have taken things that are written
in C++ and "translated" them to pure Python (like AUI). This seems like
a big class that may not be anywhere as able to be redone in Python, but
I really don't know. The current wxRichTextCtrl has been around for about
three years and started life with a list of important features that were still
missing. One of the most important of those is living up to its name: being
able to read and save actual rich text. Right now if you copy formatted text
from the web or from a Word or OpenOffice document, and paste it into the
RTC, you lose all the formatting, and just get plain text pasted in. Likewise,
if you have a nice block of formatted text, with bolds and italics and such,
and copy it into the clipboard and past it into Word, you again lose all the
formatting. The only way to sort of get it into Word or OO is to save it as
HTML, then load it as HTML, but then to go from that to a .doc file or just
a .rtf file is not really possible. For those who want to be able to write
something within their Python app and use it elsewhere, this is a deal
breaker. It's a shame, since .NET apps get this sort of thing
automatically, AFAIK and users would be really put off to not have
"standard" word processing-like behavior in a rich text control. Text
areas really should integrate seamlessly with the web and with word
processing programs.

I had wanted to have something to serve as a small low-featured "word
pad" in Python, for use in a planned app that I was hoping to do, and
was pleased when RTC came out, but it never seemed to get updated.
I'd written Julian Smart, its author, and he was very nice about
it and had hoped someone might come through with the code to add rft
(not to mention the other key features like bullets and justified text, a few
bugs worked out, and some other things) but just isn't able to get to the
updates and I assume they will never happen. Apparently going to RTF
is pretty tricky.

I write you about this off-list because I didn't want to pester the
issue/Julian
again publicly. I don't know C++ and so have no hope of being helpful on this
one, but I thought I'd at least run this by you. I'm actually
surprised that three
years have gone by and there hasn't been enough developer interest to see this
through to a truly functional control.

My other interest in wxPython is more support for gradients on panels in
terms of allowing controls to allow the gradient to show through on Windows.
I now replace all staticTextCtrls with drawn-on text, but might eventually try
to make generic checkboxes and radiobuttons for the same purpose.

Thanks again for all your awesome contributions to wxPython! :smiley:

You know, I once started the conversion of RichTextCtrl from C++ to
Python. This was about a year ago.

That you tried it doesn't surprise me. :smiley:

Then I stopped, for 4 almost

independent reasons:

- I know next to nothing about RTF formats, and the task of
implementing it in Python may be way over my head as far as I know.
However, noting that I know nothing about it, it may be simpler than I
thought;
- Some of the classes/methods used in the C++ source code of
RichTextCtrl are unavailable in Python (i.e., wxScrollHelper): these
will require re-implementations in Python (assuming this is possible);
- I used RichTextCtrl in a single app and then never again, as I
didn't feel the need to use it;
- Rendering speed/for loops/function calls are usually much more
expensive in Python than C++: so, even if the wrapped RichTextCtrl
seems fast enough, the pure-Python translation could be a dog.

So, even if a pure-Python translation of RichTextCtrl might not prove
that complicated (the C++ source is very nicely documented and very
easily readable), I am not sure it's really worth the trouble.
However, I would really welcome others' suggestions regarding the 4
points I made above: if I could get some help from some
RTF-knowledgeable wxPython developers to implement the RTF copy and
paste formats, then I would definitely take into account your
proposal.

Thank you for considering it and your previous efforts. Perhaps something
will come out of this thread that can allow a an appropriate solution for
wxPython.

···

On Mon, Oct 19, 2009 at 2:18 PM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Probably the best thing that could happen would be for somebody to adopt the RichTextCtrl wrappers. I don't really have any need for it myself and so it is hard for me to be motivated to work on it when there are so many other things that are grabbing my attention. In addition making a virtualized version of RichTextFileHandler there are many supporting classes that have not been wrapped yet.

If somebody is interested in doing this then s/he would need to be able to build and debug wxWidgets and wxPython on at least one platform (2 or all 3 would be even better,) know enough C++ to not get too lost in the code and be able to learn how the SWIG wrappers work. Patches can be sent to me and after a couple successful cycles of patches being applied then write access to the SVN repository can be granted.

···

On 10/19/09 1:33 PM, C M wrote:

On Mon, Oct 19, 2009 at 2:39 PM, Robin Dunn<robin@alldunn.com> wrote:

On 10/19/09 11:20 AM, Cody Precord wrote:

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?).

It does, and also access to the internal objects used to represent the
document. Although I'm not sure if there is enough wrapped yet to allow
custom document objects to be created in Python.

Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

It would probably just require making a new class derived from
RichTextFileHandler that could deal with the RTF format. Unfortunately
there isn't a virtualized PyRichTextFileHandler class yet that would
allow that to be done from Python.

Thanks for the input, Robin. May I ask what does "virtualized" means
here? What would need to happen in order for this approach to move
forward?

--
Robin Dunn
Software Craftsman

There is some more info about it here in the wiki:

http://wiki.wxpython.org/OverridingMethods

···

On 10/19/09 2:04 PM, Cody Precord wrote:

Hello,

On Mon, Oct 19, 2009 at 3:33 PM, C M<cmpython@gmail.com> wrote:

On Mon, Oct 19, 2009 at 2:39 PM, Robin Dunn<robin@alldunn.com> wrote:

On 10/19/09 11:20 AM, Cody Precord wrote:

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?).

It does, and also access to the internal objects used to represent the
document. Although I'm not sure if there is enough wrapped yet to allow
custom document objects to be created in Python.

Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

It would probably just require making a new class derived from
RichTextFileHandler that could deal with the RTF format. Unfortunately
there isn't a virtualized PyRichTextFileHandler class yet that would
allow that to be done from Python.

Thanks for the input, Robin. May I ask what does "virtualized" means
here?

If something is virtual and you override it in a subclass, the
subclasses method will be called even when calling the method inside a
base classes method implementation.

In python everything is virtual, so this is a detail you don't need to
think about much, but in c++ you must specify what is virtual and what
is not. In wxPython the PyFoo classes expose the virtual methods to be
overridable in Python code, for example see all the DoFoo methods
wx.PyPanel that are not available in wx.Panel)

--
Robin Dunn
Software Craftsman

Thank you for the thorough explanation, Cody.

Che

···

On Mon, Oct 19, 2009 at 5:04 PM, Cody Precord <codyprecord@gmail.com> wrote:

Hello,

On Mon, Oct 19, 2009 at 3:33 PM, C M <cmpython@gmail.com> wrote:

On Mon, Oct 19, 2009 at 2:39 PM, Robin Dunn <robin@alldunn.com> wrote:

On 10/19/09 11:20 AM, Cody Precord wrote:

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?).

It does, and also access to the internal objects used to represent the
document. Although I'm not sure if there is enough wrapped yet to allow
custom document objects to be created in Python.

Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

It would probably just require making a new class derived from
RichTextFileHandler that could deal with the RTF format. Unfortunately
there isn't a virtualized PyRichTextFileHandler class yet that would
allow that to be done from Python.

Thanks for the input, Robin. May I ask what does "virtualized" means
here?

If something is virtual and you override it in a subclass, the
subclasses method will be called even when calling the method inside a
base classes method implementation.

In python everything is virtual, so this is a detail you don't need to
think about much, but in c++ you must specify what is virtual and what
is not. In wxPython the PyFoo classes expose the virtual methods to be
overridable in Python code, for example see all the DoFoo methods
wx.PyPanel that are not available in wx.Panel)

i.e) Python

class A:
def fun1(self):
print "HELLO A"
def main(self):
fun1()

class B(A):
def fun1(self):
print "HELLO B"

obj = B()
obj.main()

In this case "HELLO B" will be printed even though the 'main' method
is implemented by the baseclass 'A'. This happens because 'fun1' is
'virtualized'.

In C++

class A
{
void fun1(void) { cout << "HELLO A"; }
void main(void) { fun1();}
}

class B : public A
{
void fun1(void) { cout << "HELLO B"; }
}

B obj = B();
obj.main();

This time "HELLO A" will be printed since 'fun1' was not declared as
virtual. So to get the same result as in the python example 'fun1'
would need to have been declared as 'virtual void fun1(void)'.

Cody

Thanks for describing the way forward. Unfortunately I started with Python
and don't know C++ at all, so I myself can't help on this, though if I did want
to learn C++, this might be something to motivate me and to have a target
to work toward.

Che

···

On Mon, Oct 19, 2009 at 6:47 PM, Robin Dunn <robin@alldunn.com> wrote:

On 10/19/09 1:33 PM, C M wrote:

On Mon, Oct 19, 2009 at 2:39 PM, Robin Dunn<robin@alldunn.com> wrote:

On 10/19/09 11:20 AM, Cody Precord wrote:

An easier approach would be if the existing control had accessors to
all its styling information (does it have this already?).

It does, and also access to the internal objects used to represent the
document. Although I'm not sure if there is enough wrapped yet to allow
custom document objects to be created in Python.

Then you
could simply have some import/export methods that do the proper
conversions. i.e) on import parse the rtf and set the controls
internal styling information and states, on export convert the
controls internal information to an rtf string.

It would probably just require making a new class derived from
RichTextFileHandler that could deal with the RTF format. Unfortunately
there isn't a virtualized PyRichTextFileHandler class yet that would
allow that to be done from Python.

Thanks for the input, Robin. May I ask what does "virtualized" means
here? What would need to happen in order for this approach to move
forward?

Probably the best thing that could happen would be for somebody to adopt
the RichTextCtrl wrappers. I don't really have any need for it myself
and so it is hard for me to be motivated to work on it when there are so
many other things that are grabbing my attention. In addition making a
virtualized version of RichTextFileHandler there are many supporting
classes that have not been wrapped yet.

If somebody is interested in doing this then s/he would need to be able
to build and debug wxWidgets and wxPython on at least one platform (2 or
all 3 would be even better,) know enough C++ to not get too lost in the
code and be able to learn how the SWIG wrappers work. Patches can be
sent to me and after a couple successful cycles of patches being applied
then write access to the SVN repository can be granted.

--
Robin Dunn
Software Craftsman
http://wxPython.org