Tk Library Source Code

Check-in [e494e6a49b]
Login

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

Overview
Comment: * ../../examples/scrollutil/*.tcl: Several improvements.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e494e6a49b8945a3e1109af7ad2433ad9f29b7ff5f1ea326c495b887c4982a75
User & Date: csaba 2020-02-05 18:13:05.159
Context
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
18:12
* doc/ScrolledText.png: Added. check-in: cfd796f297 user: csaba tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to examples/scrollutil/BwScrollableFrmDemo1.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the use of the Scrollutil package in connection with the BWidget
# ScrollableFrame widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================

package require Tk 8.5
package require BWidget
Widget::theme yes
package require scrollutil_tile
source styleUtil.tcl

wm title . "European Capitals Quiz"










<







1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the use of the Scrollutil package in connection with the BWidget
# ScrollableFrame widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================


package require BWidget
Widget::theme yes
package require scrollutil_tile
source styleUtil.tcl

wm title . "European Capitals Quiz"

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {$ttk::currentTheme in {aqua vista xpnative}} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0







|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0
Changes to examples/scrollutil/ScrolledFrmDemo1.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the use of the Scrollutil package in connection with the
# iwidgets::scrolledframe widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================

package require Tk 8.5
if {[catch {package require iwidgets} result1] != 0 &&
    [catch {package require Iwidgets} result2] != 0} {
    error "$result1; $result2"
}
source scrolledwidgetPatch.itk			;# adds ttk::scrollbar widgets
package require scrollutil
source styleUtil.tcl

wm title . "European Capitals Quiz"

set bg [ttk::style lookup TFrame -background]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $tk_patchLevel "8.6.10"] < 0} {









<





|







1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the use of the Scrollutil package in connection with the
# iwidgets::scrolledframe widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================


if {[catch {package require iwidgets} result1] != 0 &&
    [catch {package require Iwidgets} result2] != 0} {
    error "$result1; $result2"
}
source scrolledwidgetPatch.itk			;# adds ttk::scrollbar widgets
package require scrollutil_tile
source styleUtil.tcl

wm title . "European Capitals Quiz"

set bg [ttk::style lookup TFrame -background]
if {$ttk::currentTheme eq "aqua" &&
    [package vcompare $tk_patchLevel "8.6.10"] < 0} {
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {$ttk::currentTheme in {aqua vista xpnative}} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0







|







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0
Changes to examples/scrollutil/ScrolledTablelist1.tcl.
1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the traditional scrollbar management in connection with a
# tablelist widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================


package require tablelist_tile 6.3
source styleUtil.tcl

wm title . "Scrolled Tablelist"

#
# Create the tablelist and the scrollbars as children









>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the traditional scrollbar management in connection with a
# tablelist widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================

package require Tk 8.5
package require tablelist_tile 6.3
source styleUtil.tcl

wm title . "Scrolled Tablelist"

#
# Create the tablelist and the scrollbars as children
78
79
80
81
82
83
84
85
86
set b [ttk::button $f.b -text "Close" -command exit]
pack $b -side bottom -pady {0 10}

#
# Manage the frame
#
pack $frm -expand yes -fill both -padx 10 -pady 10

pack $f -expand yes -fill both







<
|
79
80
81
82
83
84
85

86
set b [ttk::button $f.b -text "Close" -command exit]
pack $b -side bottom -pady {0 10}

#
# Manage the frame
#
pack $frm -expand yes -fill both -padx 10 -pady 10

pack $f   -expand yes -fill both
Changes to examples/scrollutil/ScrolledTablelist2.tcl.
1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
#!/usr/bin/env wish

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


package require tablelist_tile 6.5
package require scrollutil_tile
source styleUtil.tcl

wm title . "Scrolled Tablelist"

#









>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env wish

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

package require Tk 8.5
package require tablelist_tile 6.5
package require scrollutil_tile
source styleUtil.tcl

wm title . "Scrolled Tablelist"

#
59
60
61
62
63
64
65
66
67
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







<
|
60
61
62
63
64
65
66

67
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
Changes to examples/scrollutil/SuScrollableFrmDemo1.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the use of the Scrollutil package in connection with the
# scrollutil::scrollableframe widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================

package require Tk 8.5
package require scrollutil_tile
source styleUtil.tcl

wm title . "European Capitals Quiz"

#
# Create a scrollableframe within a scrollarea









<







1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
#!/usr/bin/env wish

#==============================================================================
# Demonstrates the use of the Scrollutil package in connection with the
# scrollutil::scrollableframe widget.
#
# Copyright (c) 2019-2020  Csaba Nemethi (E-mail: [email protected])
#==============================================================================


package require scrollutil_tile
source styleUtil.tcl

wm title . "European Capitals Quiz"

#
# Create a scrollableframe within a scrollarea
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {$ttk::currentTheme in {aqua vista xpnative}} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0







|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

foreach country $countryList capital $capitalList {
    set capitalArr($country) $capital
}

set capitalList [lsort $capitalList]

if {[lsearch -exact {aqua vista xpnative} $ttk::currentTheme] >= 0} {
    set topPadY 2
} else {
    set topPadY 5
}
set padY [list $topPadY 0]

set row 0
Changes to examples/scrollutil/SyncListboxes.tcl.
16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
# Create two ttk::label widgets within a ttk::frame
#
set f  [ttk::frame .f]
set tf [ttk::frame $f.tf]
set l1 [ttk::label $tf.l1 -text "Countries"]
set l2 [ttk::label $tf.l2 -text "Capitals"]
grid $l1 $l2
grid columnconfigure $tf all -weight 1 -uniform AllCols


#
# Create a scrollsync widget within a scrollarea
#
set sa [scrollutil::scrollarea $f.sa]
set ss [scrollutil::scrollsync $sa.ss]
$sa setwidget $ss







|
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Create two ttk::label widgets within a ttk::frame
#
set f  [ttk::frame .f]
set tf [ttk::frame $f.tf]
set l1 [ttk::label $tf.l1 -text "Countries"]
set l2 [ttk::label $tf.l2 -text "Capitals"]
grid $l1 $l2
grid columnconfigure $tf 0 -weight 1 -uniform AllCols
grid columnconfigure $tf 1 -weight 1 -uniform AllCols

#
# Create a scrollsync widget within a scrollarea
#
set sa [scrollutil::scrollarea $f.sa]
set ss [scrollutil::scrollsync $sa.ss]
$sa setwidget $ss
64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
set itemCount [$lb1 size]
for {set idx 1} {$idx < $itemCount} {incr idx 2} {
    $lb1 itemconfigure $idx -background #f0f0f0
    $lb2 itemconfigure $idx -background #f0f0f0
}

grid $lb1 $lb2 -sticky news -padx {0 2}
grid rowconfigure    $ss 0   -weight 1
grid columnconfigure $ss all -weight 1


#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}







|
|
>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
set itemCount [$lb1 size]
for {set idx 1} {$idx < $itemCount} {incr idx 2} {
    $lb1 itemconfigure $idx -background #f0f0f0
    $lb2 itemconfigure $idx -background #f0f0f0
}

grid $lb1 $lb2 -sticky news -padx {0 2}
grid rowconfigure    $ss 0 -weight 1
grid columnconfigure $ss 0 -weight 1
grid columnconfigure $ss 1 -weight 1

#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}
Changes to examples/scrollutil/SyncTablelists.tcl.
18
19
20
21
22
23
24
25


26
27
28
29
30
31
32
#
set f  [ttk::frame .f]
set tf [ttk::frame $f.tf]
set l1 [ttk::label $tf.l1 -text "Left Table"]
set l2 [ttk::label $tf.l2 -text "Middle Table"]
set l3 [ttk::label $tf.l3 -text "Right Table"]
grid $l1 $l2 $l3
grid columnconfigure $tf all -weight 1 -uniform AllCols



#
# Create a scrollsync widget within a scrollarea
#
set sa [scrollutil::scrollarea $f.sa]
set ss [scrollutil::scrollsync $sa.ss]
$sa setwidget $ss







|
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#
set f  [ttk::frame .f]
set tf [ttk::frame $f.tf]
set l1 [ttk::label $tf.l1 -text "Left Table"]
set l2 [ttk::label $tf.l2 -text "Middle Table"]
set l3 [ttk::label $tf.l3 -text "Right Table"]
grid $l1 $l2 $l3
grid columnconfigure $tf 0 -weight 1 -uniform AllCols
grid columnconfigure $tf 1 -weight 1 -uniform AllCols
grid columnconfigure $tf 2 -weight 1 -uniform AllCols

#
# Create a scrollsync widget within a scrollarea
#
set sa [scrollutil::scrollarea $f.sa]
set ss [scrollutil::scrollsync $sa.ss]
$sa setwidget $ss
45
46
47
48
49
50
51
52
53


54
55
56
57
58
59
60
    for {set i 0} {$i < 100} {incr i} {
	$tbl insert end [list "cell $i,0" "cell $i,1"]
    }
}
$ss setwidgets [list $tbl1 $tbl2 $tbl3]

grid $tbl1 $tbl2 $tbl3 -sticky news -padx {0 2}
grid rowconfigure    $ss 0   -weight 1
grid columnconfigure $ss all -weight 1



#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}







|
|
>
>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    for {set i 0} {$i < 100} {incr i} {
	$tbl insert end [list "cell $i,0" "cell $i,1"]
    }
}
$ss setwidgets [list $tbl1 $tbl2 $tbl3]

grid $tbl1 $tbl2 $tbl3 -sticky news -padx {0 2}
grid rowconfigure    $ss 0 -weight 1
grid columnconfigure $ss 0 -weight 1
grid columnconfigure $ss 1 -weight 1
grid columnconfigure $ss 2 -weight 1

#
# Create a ttk::button widget
#
set b [ttk::button $f.b -text "Close" -command exit]

pack $b  -side bottom -pady {0 10}
Changes to examples/scrollutil/styleUtil.tcl.
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
}

#
# TCombobox
#
# Make sure the combobox will show whether it has the focus
#
if {$ttk::currentTheme in {alt clam default}} {
    ttk::style map TCombobox \
	-fieldbackground [list {readonly focus} #4a6984] \
	-foreground      [list {readonly focus} #ffffff]

    option add *TCombobox*Listbox.selectBackground  #4a6984
    option add *TCombobox*Listbox.selectForeground  #ffffff
}







|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
}

#
# TCombobox
#
# Make sure the combobox will show whether it has the focus
#
if {[lsearch -exact {alt clam default} $ttk::currentTheme] >= 0} {
    ttk::style map TCombobox \
	-fieldbackground [list {readonly focus} #4a6984] \
	-foreground      [list {readonly focus} #ffffff]

    option add *TCombobox*Listbox.selectBackground  #4a6984
    option add *TCombobox*Listbox.selectForeground  #ffffff
}
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

#
# createToolbutton
#
# Creates a toolbutton widget which appears raised when it has the focus.
#
proc createToolbutton {w args} {
    ttk::button $w -style Small.Toolbutton {*}$args

    if {$ttk::currentTheme in {vista xpnative}} {
	bindtags $w [linsert [bindtags $w] 1 Toolbtn]
    }

    return $w
}

#
# "Toolbtn" bindings for the themes "vista" and "xpnative"
#
bind Toolbtn <FocusIn>		{ %W state  active }
bind Toolbtn <FocusOut>		{ %W state !active }
bind Toolbtn <Leave>		{ %W instate focus break }
bind Toolbtn <Button1-Leave>	{ %W state !pressed }







|

|













64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

#
# createToolbutton
#
# Creates a toolbutton widget which appears raised when it has the focus.
#
proc createToolbutton {w args} {
    eval ttk::button $w -style Small.Toolbutton $args

    if {[lsearch -exact {vista xpnative} $ttk::currentTheme] >= 0} {
	bindtags $w [linsert [bindtags $w] 1 Toolbtn]
    }

    return $w
}

#
# "Toolbtn" bindings for the themes "vista" and "xpnative"
#
bind Toolbtn <FocusIn>		{ %W state  active }
bind Toolbtn <FocusOut>		{ %W state !active }
bind Toolbtn <Leave>		{ %W instate focus break }
bind Toolbtn <Button1-Leave>	{ %W state !pressed }