TIP #243: Supply Find Dialog for the Text Widget


TIP:243
Title:Supply Find Dialog for the Text Widget
Version:$Revision: 1.3 $
Author:Rüdiger Härtel <r_haertel at gmx dot de>
State:Draft
Type:Project
Tcl-Version:8.7
Vote:Pending
Created:Wednesday, 16 March 2005
Keywords:Tk

Abstract

This TIP adds a find dialog to the Tk text widget.

Rationale

In using the text widget it often is a desire to search the input, and the text widget itself provides already all means to search text. However, until now there is no GUI based support, so each application developer needing it has to reinvent much of this particular wheel. Tk should provide a scripted find dialog in its library scripts so that simple applications can be built more easily and to a higher quality. Additionally, a replace dialog is desirable, and it should be developed at the same time.

Reference Implementation

A reference implementation for a find dialog is available at [1].

Example Use

 package require Tk
 namespace import ::msgcat::*
 
 mclocale en
 ::msgcat::mcset	en	LblSearchString		"Search String"
 ::msgcat::mcset	en	LblDirection		"Direction"
 ::msgcat::mcset	en	ChkBtnFindCaseOpt	"Case"
 ::msgcat::mcset	en	ChkBtnFindRegexpOpt	"Regexp"
 ::msgcat::mcset	en	RdoBtnFindDirOpt1	"Forward"
 ::msgcat::mcset	en	RdoBtnFindDirOpt2	"Backward"
 ::msgcat::mcset	en	BtnFind			"  Find  "
 ::msgcat::mcset	en	BtnFindNext		"  Next  "
 ::msgcat::mcset	en	BtnClose		"  Close  "
 
 set b1 .button
 set t1 .t1
 
 button $b1 -text Find -command [list \
        tk_textFind $t1 -searchstring hallo -highlightcolor green \
        -title "Find Dialog"]
 text $t1
 
 grid $b1 -row 0 -column 1
 grid $t1 -row 1 -column 0 -columnspan 2
 
 set fd [open [file join . tk_find.tcl] r]
 set content [read $fd]
 close $fd
 
 $t1 insert 0.0 $content
 set content ""

Copyright

This document is in the public domain.


Powered by Tcl[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows