[Tkinter-discuss] Text, Tree & Tkinter. Ugh!

Ron Provost ron.longo at cox.net
Fri Mar 14 02:09:47 CET 2008


Hello,

Don't know if I'll get much response to this but I figured this is about the best place to try.

I have an application I've been developing for some time which is for organizing large amounts of information and publishing it to the web.  This application is written 100% in Python.  (Below are images of the application and the generated web page).  It's not fancy, but it works.

My issue is with the Text widget and styling my text/web pages.  At first glance, the text widget appears amazing.  It seems to be able to do everything I want it to to be able to develop a reasonaly decent looking document and web page with text styling and image insertion.  However, I've just not been able to get my mind around how to use it as such.  Consequently, I've resorted to a "mini language" (shown in the image) which I must translate into HTML to format my document.  It's really a disappointing aspect of an otherwise nice application.  Comparing the document to the web page jpgs you can see that I"m using something of the form [[ x ]]:unordered to transform 'x' into a level 2 header followed by an unordered list with one element (preceded by '@@').  I have quite a few of these kinds of things for generating all sorts of HTML code.  But I hate them.  I want to be able to remove this 'directives' and be able to view images and styles directly in my document.

I have played around with the Text widget separately and developed a few 'sample' editing applications but I've never been able to capture the functionality of what I need.  Pictured also is a control I wrote for an application which allows me to define text styles and assign them to sections of text that's selected in my text widget.  The problem with this sample app is that in order to avoid the complexity of layered styles whenever a section of text is assigned a new style all previous styles (tags) on that section are first deleted.  Layering of tags in itself doesn't bother me but then you have to get into special cases for fonts (family, size, weight and slant) which can't layer, but have to be specified at once. So, if you want a button to select just bold on your GUI, you have to start to play games to work around this.  Also, I have not been able to figure out how to change the style of text being typed.  Seems like I have to type text first, then go back, select it and assign a style.  Then there's the who issue of lists and tables which I need but am not really sure how to implement in the control.

For anyone curious, my tree is generated using the Tix Tree widget.  The elements in the tree are actually entry widgets so that I can edit them inplace.  I've implemented full editing capabilities of the tree with drag-and-drop to allow reorganizing.  The tree control is very simple to use and those I've shown it to love it and describe it as intuitive.  There's only one minor problem with the Tree control involving clicking on the +/- indicator.  You need to click quickly to open or close the branch, if your click and release of the mouse button is too slow, the the branch state toggles twice putting you back in your original state.  Annoying, not sure I can fix it since it's behavior of the control.

If anyone is interested in examining the application I would be more than willing to zip the source code and email it to them.  It's not pretty as it's been through about a thousand revisions.

Note of interest:  The outline displayed in the GUI and web page are for my research area, Logic.  I have several other outlines in the works including a Tkinter one that's quite mature.

Thanks for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: untitled.JPG
Type: image/jpeg
Size: 104713 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0003.jpeg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: web_resize.JPG
Type: image/jpeg
Size: 108394 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0004.jpeg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: control.JPG
Type: image/jpeg
Size: 69411 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20080313/7774897f/attachment-0005.jpeg 


More information about the Tkinter-discuss mailing list