Tk Library Source Code

Check-in [2b1ce120ca]
Login
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: * ../../examples/scrollutil/ScrolledText.tcl: Added.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2b1ce120caf1f9798866f0a161a0ec82cdee73558a38f62f93c44d3b136ba027
User & Date: csaba 2020-02-05 18:14:24
Context
2020-02-06
14:08
* doc/scrollutil.html: Minor improvements. check-in: e686a78bf1 user: csaba tags: trunk
2020-02-05
18:14
* ../../examples/scrollutil/ScrolledText.tcl: Added. check-in: 2b1ce120ca user: csaba tags: trunk
18:13
* ../../examples/scrollutil/*.tcl: Several improvements. check-in: e494e6a49b user: csaba tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added examples/scrollutil/ScrolledText.tcl.








































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the use of the scrollutil::scrollarea widget in connection with
# a text widget.
#
# Copyright (c) 2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================

package require scrollutil_tile
source styleUtil.tcl

wm title . "Scrolled Text"

#
# Create a text widget within a scrollarea
#
set f  [ttk::frame .f]
set sa [scrollutil::scrollarea $f.sa -lockinterval 10]
set txt [text $sa.txt -font TkFixedFont -width 49 -height 12 \
	 -spacing1 2 -spacing3 2 -wrap none]
$sa setwidget $txt

#
# Populate the text widget and set the background color of line #25 to red
#
for {set i 1} {$i <= 30} {incr i} {
    set j [expr {2*$i}]
    $txt insert end [string repeat X $j]\n
}
$txt delete 30.end
$txt tag configure bgRed -background red
$txt tag add bgRed 25.0 25.end

#
# Create a ttk::button widget outside the scrollarea
#
set b [ttk::button $f.b -text "Close" -command exit]
pack $b -side bottom -pady {0 10}

#
# Manage the scrollarea
#
pack $sa -expand yes -fill both -padx 10 -pady 10
pack $f  -expand yes -fill both

#
# Adjust the vertical view in the text window
# so that line #25 becomes the bottom line
#
tkwait visibility $txt
after 100 [list $txt yview 14.0]