Tk Source Code

Artifact [f2071f5d]
Login

Artifact f2071f5d38455d7a784a04edac571f03709f2961:

Attachment "yview2.tcl" to ticket [1566949f] added by mbroeken 2006-09-28 17:30:12.
package require Tk
console show
set text [text .text -yscrollcommand [list .yscroll set]]
set yscroll [scrollbar .yscroll -command [list $text yview]]
grid $text -row 0 -column 0 -sticky nesw
grid $yscroll -row 0 -column 1 -sticky ns
grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1
set content [string repeat {originally from "Tool Command Language", but nonetheless conventionally rendered as "Tcl" rather than "TCL"; and pronounced like "tickle") is a scripting language created by John Ousterhout. Originally "born out of frustration" according to the author with programmers devising their own (poor quality) languages intended to be embedded into applications, Tcl quickly gained wide acceptance on its own and is generally thought to be easy to learn, but powerful in competent hands. It is most commonly used for rapid prototyping, scripted applications, GUIs and testing. Tcl is also used for CGI scripting.

Nepal is a landlocked Himalayan country in South Asia, bordered by the People's Republic of China to the north and by India to the south, east and west. More than 80% of Nepalese follow Hinduism. For a small territory, the Nepali landscape is uncommonly diverse, ranging from the humid Terai in the south to the lofty Himalayas in the north. It is notable that within a very small width the elevation of Nepal increases from the plain terrain to the tallest Himalayas leading to great variegation. Nepal boasts eight of the world's ten highest mountains, including Mount Everest on the border with Tibet in the People's Republic of China. Kathmandu is the capital and largest city. The other main cities include Biratnagar, Bhairahawa, Birgunj, Janakpur, Pokhara, Nepalgunj, and Mahendranagar. After a long and rich history, during which the region splintered and coalesced under a variety of absolute rulers, Nepal became a constitutional monarchy in 1990. However, the monarchy retained many important and ill-defined powers. This arrangement was marked by increasing instability, both in the parliament and, since 1996, in large swathes of the country that have been fought over by Maoist insurgents.} 10]
$text insert 1.0 $content

proc test {{change false}} {
	global content text
	set fraction [lindex [$text yview] 0]
	puts "offscreen: $fraction"
	set old [$text get 1.0 end]
	if {$change} {
		$text delete 1.0 end
		$text insert 1.0 $content
	}
	$text yview moveto $fraction
	puts "offscreen: [lindex [$text yview] 0]"
	if {[expr {$old eq [$text get 1.0 end]}]} {
		puts "text stayed the same"
	} else {
		puts "text has changed"
	}
}