Version 0 of A vertical line in a text widget

Updated 2008-01-04 07:52:54 by arjen

Arjen Markus (4 january 2008) Reading the wishlist for Tk 9.0, I stumbled on a request by NEM regarding a combination of the canvas and the text widgets. One idea was to have vertical lines in the text display.

Well, the script below demonstrates how you can do that (in principle at least):

# textw.tcl --
#
place [text .t] -x 0 -y 0
tkwait visibility .t
set height [winfo height .t]
set width  [winfo width  .t]
. configure -width $width -height $height
place [canvas .cv -width 0 -height $height -highlightthickness 0] -x [expr {$width/2}] -y 2
place [canvas .ch -width $width -height 0  -highlightthickness 0] -y [expr {$height/2}] -x 2 

Drawbacks:

  • [place] does not seem to work in a frame
  • I found out I need to resize the containing toplevel window myself
  • You need to compute the position of the canvases yourself in terms of columns or rows

But then: I only needed Tk 8.4 to do this.


Category Example Category TK