Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > New Full Tkinter document editor widget -- suggestions, comments, etc.

Reply
Thread Tools

New Full Tkinter document editor widget -- suggestions, comments, etc.

 
 
Ron Provost
Guest
Posts: n/a
 
      03-25-2008
I've posted a demo (http://tkinter.unpy.net/wiki/StyledEditor). This demo
creates a widget with full "styled editing" capabilities; sort of a
mini-word processor. It runs "as is" on my WinXP machine with Python 2.5.
The demo allows styling of any selected text via toolbars; just select the
text, then select the styling. Also included are buttons to save and
retrieve all content and styling information (works for the small tests I've
tried myself, not guaranteed bug-free).

The actual widget wraps the Text widget to give greater freedom in the
assignment of any single styling attribute to any region. This differs from
the Text widget itself in that the Text widget does not allow you to
individually assign a family, size, weight or slant with tag_config(). That
is, for example, you can't simply apply 'bold' to some region of text.

This demo was written quite quickly (I pounded it out over the weekend) so
I'm sure it's full of bugs. Also in my desire to get something working
quickly its API doesn't really work like a normal widget, so I guess this
serves as more of a proof of concept than full-blown widget but the basic
functionality is there. I'm presenting it here because I thought maybe
others might have thoughts on how to improve it.

API Notes:

applyStyleAttribute( index1, index2, attributeName, attributeValue )

This method is is frontend to the business. attributeName and
attributeValue may be any option accpeted by tag_config() of the Text widget
along with appropriate value. There are also some ''new'' options:

- 'family', attributeValue is a font family name
- 'size', attributeValue is a font point size
- 'weight', attributeValue is one of: 'normal', 'bold'
- 'bold', attributeValue is a boolean (alternative to using 'weight')
- 'slant', attributeValue is one of: 'roman', 'italic'
- 'italic', attributeValue is boolean (alternative to using 'slant')

Several previously existing options have some new values:

'spacing1', 'spacing2' and 'spacing3' may take 'None', 'Half Line', 'One
Line' or 'Two Lines' in addition to any of the values acceptable by
tag_config().

'offset' may take 'normal', 'superscript' or 'subscript' in addition to any
value acceptable by tag_config.

Please download and try-out my demo
(http://tkinter.unpy.net/wiki/StyledEditor). I'm anxious for suggestions
and comments.

Ron Longo

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Tkinter.event.widget: handler gets name instead of widget. Terry Reedy Python 15 07-16-2012 10:32 AM
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch Python 0 07-09-2012 08:39 PM
Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch Python 0 07-08-2012 09:19 PM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-23-2004 02:31 PM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-20-2004 12:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57