Skip to main content

A data type holding rich text data (textmodel) and a text widget (wxtextview) as demonstration. Textmodel does not depend on a specific gui-toolkit.

Project description


Textmodel is a data type which can hold textstrings together with format information. It is similar to GtkTextBuffer in functionality, but it is completely independent of a gui-toolkit. TextModel is based on a efficient b-tree like structure and is incredibly fast.

Wxtextview is an example widget written for the wx toolkit. It has the functionality of a rich text editor and can handle even very long texts without feeling slow.

There are two demos showing advanced possibilities of textmodel: notebook interface similar to ipython demonstration of typesetting math


Running the demos:

Just cd to the demo directory and execute the scripts. No installation is needed. External dependencies are wxpython (all demos) and matplotlib (notebook). The demos were tested on linux, windows and mac platforms.

$ cd demo/
$ python

Using textmodel:

from textmodel import TextModel

text = TextModel(u'Hello World!')

# highlight the word "World"
text.set_properties(6, 11, bgcolor = 'yellow')

# query the color
print text.get_style(0)['bgcolor'] # --> color of first character
print text.get_style(10)['bgcolor'] # --> color of 10th character

Using the wxtextview-widget:

from textmodel import TextModel
from wxtextview import WXTextView

import wx
app = wx.App()

model = TextModel(u'Hello World!')
model.set_properties(6, 11, fontsize=14)
model.set_properties(6, 11, bgcolor='yellow')

# display the texmodel in a view
frame = wx.Frame(None)
view = WXTextView(frame, -1)
view.model = model

# set cursor and selection
view.index = 5
view.selection = 0, 5

# display the same textmodel in a second view
frame2 = wx.Frame(None)
view2 = WXTextView(frame2, -1)
view2.model = model



See file LICENSE.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for textmodel, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size textmodel-0.3.1.tar.gz (49.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page