Hi everyone,
I would like to announce a text widget which I wrote. It allows editing multiline styled text and does everything you might expect from text editor widget. However it has some interesting features:
-
all drawing operations are coded in python (therefore porting to a different gui-toolkit is possible)
-
it has no external dependencies other than wxpython
-
there is a strict separation between model and view
-
text can be nested (think of a text that contains a table and the table itself contains text)
Most important, the widget can be extended by introducing new text objects. So if you have a complicated typesetting problem, have a look at it.
The text widget comes with a couple of demos, most notably a demo of typesetting mathematics and notebook interface for python.
You can download it from https://pypi.python.org/pypi/textmodel
Feedback and bug reports are welcome.
Chris
Nice Demos.
Noticed the highlighting is sluggish if there is a good bit of text involved.
From first glance, All I would suggest is a major speedup in the rendering process.
At its current speed, it doesnt come close to STC even basically, which presents lockup of the gui until everything is rendered.
Otherwise, nice widget features overall. Like the notebook demo concept and the math rendering capability.
···
On Friday, January 3, 2014 2:46:13 PM UTC-6, Christof wrote:
Hi everyone,
I would like to announce a text widget which I wrote. It allows editing multiline styled text and does everything you might expect from text editor widget. However it has some interesting features:
- all drawing operations are coded in python (therefore porting to a different gui-toolkit is possible)
- it has no external dependencies other than wxpython
- there is a strict separation between model and view
- text can be nested (think of a text that contains a table and the table itself contains text)
Most important, the widget can be extended by introducing new text objects. So if you have a complicated typesetting problem, have a look at it.
The text widget comes with a couple of demos, most notably a demo of typesetting mathematics and notebook interface for python.
You can download it from https://pypi.python.org/pypi/textmodel
Feedback and bug reports are welcome.
Chris
Thanks. I did not observe slowness of rendering, yet. However drag scolling is very slow, because the algorithm for translating a click position to an index is quite bad. I am going to change that.
···
Am Samstag, 4. Januar 2014 00:11:43 UTC+1 schrieb Metallicow:
On Friday, January 3, 2014 2:46:13 PM UTC-6, Christof wrote:
Hi everyone,
I would like to announce a text widget which I wrote. It allows editing multiline styled text and does everything you might expect from text editor widget. However it has some interesting features:
Nice Demos.
Noticed the highlighting is sluggish if there is a good bit of text involved.
From first glance, All I would suggest is a major speedup in the rendering process.
At its current speed, it doesnt come close to STC even basically, which presents lockup of the gui until everything is rendered.
Otherwise, nice widget features overall. Like the notebook demo concept and the math rendering capability.
Thanks. I did not observe slowness of rendering, yet. However drag scolling is very slow, because the algorithm for translating a click position to an index is quite bad. I am going to change that.
Yeah, that drag scrolling is part of that.
Also the demos background colour should match to make it look pretty.
Ex Attached pic: the difference between default white text background and say the gray(panel default)
Also
demo doubleclick tracebacks:
···
On Saturday, January 4, 2014 1:59:49 AM UTC-6, Christof wrote:
Traceback (most recent call last):
File “…\wxtextview\wxtextview.py”, line 207, in on_leftup
self.ReleaseMouse()
File “C:\Python27\lib\site-packages\wx-2.9.5-msw\wx_core.py”, line 10649, in ReleaseMouse
return core.Window_ReleaseMouse(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion “ms_winCaptureCurrent == this” failed at …..\src\common\wincmn.cpp(3250) in wxWindowBase::ReleaseMouse(): attempt to release mouse, but this window hasn’t captured it
- all drawing operations are coded in python (therefore porting to a
different gui-toolkit is possible)
- it has no external dependencies other than wxpython
- there is a strict separation between model and view
- text can be nested (think of a text that contains a table and the table
itself contains text)
Most important, the widget can be extended by introducing new text
objects. So if you have a complicated typesetting problem, have a look at
it.
The text widget comes with a couple of demos, most notably a demo of
typesetting mathematics and notebook interface for python.
very cool. I haven't tried it yet, but a suggestion:
typesetting is very, very hard to do well. the TeX system does it MUCH
better than most. So you may want to look at the TeX implementation that
comes with Matplotlib -- it's pure python, so may plug in well to your
system. At this point, it only does math, but that's the harder problem,
and it could probably be fairly easily extended to support general
paragraph/page formatting as well.
Just a thought.
-Chris
···
You can download it from textmodel · PyPI
Feedback and bug reports are welcome.
Chris
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
Christopher Barker, PhD
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
OK, here are screenshots :-).
···
Am Samstag, 4. Januar 2014 08:42:36 UTC+1 schrieb DevPlayer:
Have screen shots?
Hi Chris,
a text editor with TeX like typesetting would be really cool. I am quite sure that this would be possible and also I guess that matplotlib code could be reused. However, in the moment I would be more than happy to get all the bugs out of the existing code.
···
Am Samstag, 4. Januar 2014 20:44:37 UTC+1 schrieb Christopher Barker:
typesetting is very, very hard to do well. the TeX system does it MUCH better than most. So you may want to look at the TeX implementation that comes with Matplotlib – it’s pure python, so may plug in well to your system. At this point, it only does math, but that’s the harder problem, and it could probably be fairly easily extended to support general paragraph/page formatting as well.
Wow! This is such a hard problem and you did it in a lot less code than I would have thought possible.
I found it fast enough for typing regardless of the length of the document, but as mentioned earlier the highlighting and dragging is pretty slow. A quick profile shows that the number of calls to measure_gtk seems to be related to the length of the text, regardless of the number of lines on screen.
My feature request would be to tying in to Pygments for source code highlighting. 
Great effort!
Rob
···
On Sat, Jan 4, 2014 at 3:10 PM, Christof christof.ecker@googlemail.com wrote:
Am Samstag, 4. Januar 2014 20:44:37 UTC+1 schrieb Christopher Barker:
typesetting is very, very hard to do well. the TeX system does it MUCH better than most. So you may want to look at the TeX implementation that comes with Matplotlib – it’s pure python, so may plug in well to your system. At this point, it only does math, but that’s the harder problem, and it could probably be fairly easily extended to support general paragraph/page formatting as well.
Hi Chris,
a text editor with TeX like typesetting would be really cool. I am quite sure that this would be possible and also I guess that matplotlib code could be reused. However, in the moment I would be more than happy to get all the bugs out of the existing code.
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
ok, I will think about pygments :-).
The slow dragging is fixed now (and also the other things reported by metallicow). Thanks.
···
Am Dienstag, 7. Januar 2014 19:11:12 UTC+1 schrieb Rob McMullen:
Wow! This is such a hard problem and you did it in a lot less code than I would have thought possible.
I found it fast enough for typing regardless of the length of the document, but as mentioned earlier the highlighting and dragging is pretty slow. A quick profile shows that the number of calls to measure_gtk seems to be related to the length of the text, regardless of the number of lines on screen.
My feature request would be to tying in to Pygments for source code highlighting. 
Great effort!
Rob
On Sat, Jan 4, 2014 at 3:10 PM, Christof christo...@googlemail.com wrote:
Am Samstag, 4. Januar 2014 20:44:37 UTC+1 schrieb Christopher Barker:
typesetting is very, very hard to do well. the TeX system does it MUCH better than most. So you may want to look at the TeX implementation that comes with Matplotlib – it’s pure python, so may plug in well to your system. At this point, it only does math, but that’s the harder problem, and it could probably be fairly easily extended to support general paragraph/page formatting as well.
Hi Chris,
a text editor with TeX like typesetting would be really cool. I am quite sure that this would be possible and also I guess that matplotlib code could be reused. However, in the moment I would be more than happy to get all the bugs out of the existing code.
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
ok, I will think about pygments :-).

The slow dragging is fixed now (and also the other things reported by
metallicow). Thanks.
Nice, scrolling while extending the selection is very fast now.
I was trying to create an example to play around with a large amount of
text so I hacked demo2.py (attached here). I'm getting a recursion error.
What's the correct way to add text programmatically? Are there any other
size limits to the code?
Do you have this on github or someplace? I'd be happy to open tickets
against the code if I find issues. I'm very curious to experiment. Once
upon a time I wrote a large editor in python using the STC and am thinking
about updating it for wxPython 3.0. Your code makes me wonder if I can
replace the STC with this.
Rob
···
On Tue, Jan 7, 2014 at 1:00 PM, Christof <christof.ecker@googlemail.com>wrote:
Woops. Attached here.
Rob
demo-large.py (940 Bytes)
···
On Tue, Jan 7, 2014 at 2:56 PM, Rob McMullen rob.mcmullen@gmail.com wrote:
On Tue, Jan 7, 2014 at 1:00 PM, Christof christof.ecker@googlemail.com wrote:
ok, I will think about pygments :-).

The slow dragging is fixed now (and also the other things reported by metallicow). Thanks.
Nice, scrolling while extending the selection is very fast now.
I
was trying to create an example to play around with a large amount of text so I hacked demo2.py (attached here). I’m getting a recursion error. What’s the correct way to add text programmatically? Are there any other size limits to the code?
Do you have this on
github or someplace? I’d be happy to open tickets against the code if I
find issues. I’m very curious to experiment. Once upon a time I wrote a
large editor in python using the STC and am thinking about updating it for wxPython 3.0. Your code makes me wonder if I can replace the STC with this.
Rob
Very good!
There is still a very small bit of lag noticeable for the stuff that’s visible on-screen. But it’s not really that obvious unless compared side to side with a python STC.
This just might be the difference between python/c++ speed. who knows…
The dragging/scrolling seems fast enough.
Curious how fast the demo3 would be with updating the syntax highlighting OnChar…
At first, I thought the double clicking was screwed up again because it wasn’t highlighting the whole word.
But then I noticed I had a slight movement while doing it.
I then noticed that you can change the selection length by dragging the caret! Nice little difference.
Also, a quick glance through the code… It is not Py3 compatible ATM(0.2.2).
Work on fixing it up so it works on Py2 and Py3 and clean the code afterward.
imports, print(‘With parenthesis’), raise stuff, trim trailing space, etc…
This shouldn’t be too much work as you really did this in a minimal amount of code(nice).
You might have some differences with the token stuff.
Also, maybe translate the comments to English also… looks(German?) only for the most part…
Good Job!
···
On Tuesday, January 7, 2014 3:00:14 PM UTC-6, Christof wrote:
ok, I will think about pygments :-).
The slow dragging is fixed now (and also the other things reported by metallicow). Thanks.
The example looks right. Texmodel uses some heuristics to maintain an optimized data tree. In your case the tree is very inefficient and as a result it gets slow and at some point python even raises a recursion exception. I will try to fix that.
A quick solution would be to concat the text before inserting in the model:
text = “”
for i in range(1000):
text += "Copy #%d: " % i
text += instructions
model.insert(len(model), TextModel(text))
I created a github repository: https://github.com/chrisecker/textmodel/issues
···
Am Dienstag, 7. Januar 2014 23:56:35 UTC+1 schrieb Rob McMullen:
On Tue, Jan 7, 2014 at 1:00 PM, Christof christo...@googlemail.com wrote:
ok, I will think about pygments :-).

The slow dragging is fixed now (and also the other things reported by metallicow). Thanks.
Nice, scrolling while extending the selection is very fast now.
I
was trying to create an example to play around with a large amount of text so I hacked demo2.py (attached here). I’m getting a recursion error. What’s the correct way to add text programmatically? Are there any other size limits to the code?
Do you have this on
github or someplace? I’d be happy to open tickets against the code if I
find issues. I’m very curious to experiment. Once upon a time I wrote a
large editor in python using the STC and am thinking about updating it for wxPython 3.0. Your code makes me wonder if I can replace the STC with this.
Rob
Ummm, was you gonna upload the source code there as well so pull requests can be done for fixes and issues.
Just coming back to looking at this and there are some issues with Phoenix and PY2/PY3.
Doing a pull request is the easiest way for me and since you made a github page, this would only make sense.
The pull request will automatically make an issue for you also that you can review.
···
On Wednesday, January 8, 2014 1:37:43 AM UTC-6, Christof wrote:
I created a github repository: https://github.com/chrisecker/textmodel/issues