Re: OT: tcl/tk GUI app

Στις 18/1/2013 2:36, ο/η Fred James έγραψε:
Georgios Petasis wrote:
if {$dir ne ""} {
# your action here...
Georgios Petasis
Thank you ... at least with that, so far I can display the selected directory in the main window ... that is more than I had.

(for those not interested ... you may easily stop reading here ... thank you)

What is the action, you ask?
(1) enter a search string (exact match, but not case sensitive)
grid [ttk::label .sl -text {Search:}] \
[ttk::entry .se -textvariable search_string] \
- \
-sticky snew -padx 2 -pady 2
grid [ttk::label .dl -text {Dir:}] \
[ttk::entry .de -textvariable search_dir] \
[ttk::button .db -text {...} -command [list select_directory]] \
-sticky snew -padx 2 -pady 2

grid x x [ttk::button .do -text {Search} -command [list do]] \
-sticky snew -padx 2 -pady 2

grid [listbox .list -height 16 -width 80 -listvariable found_files] - - \
-sticky snew -pady 6 -padx 2

grid columnconfigure . 1 -weight 1
grid rowconfigure . 3 -weight 1

(2) select a starting directory
You already have that...
(3) search recursively from there
Look here:
(3.1) search first for a list of files ending in *.odt
Easy, see above
(3.2) search each file on the list (found in 3.1) for the string
set found_files {}
foreach file [::fileutil::findByPattern ...] {
## Do what ever you want with file...
lappend found_files $file
(3.2.1) make a list of matches
done in found_files
(3.2.2) display the match list in a scroll box
done, found_files already linked to the list box.
... or some variation of that.

A much better place to ask this kind of stuff, is the comp.lang.tcl newsgroup.
For GUI stuff, check tkdocs:


I have odt2txt (downloaded and running), and I have a couple of (BASH) shell scripts that complete the set. I put all three in /usr/bin. The set works like this ...
(1) in a terminal window
(1.1) cd to /desired/path
(1.2) enter the following: searchODT string [string [string ... [string]]] (1.2.1) that is, at least 1 and up to 9 space separated arguments (hard coded arbitrary limit) (1.3) searchODT sorts out the string, combining all arguments into one string (1.4) searchODT calls depthODT, which generates the list (file) of *.odt files (1.3.1) search is recursive beginning at the 'pwd' where the original searchODT command was issued
(1.4) searchODT then calls odt2txt for each entry in the list (file)
(1.4.1) the output from odt2txt is grep'd for the string(s) (grep -i)
(1.4.2) matches are put into another file for display
( it is possible to use: more, soffice, kwrite (and I am sure others) for the display. Other than argument count, there is basically no error checking at the moment.

(scripts available, if interested)

The original project was to done to help my spouse, because dolphin (file manager) doesn't seem to be able to search inside OOo documents? And the current version functions well enough. But I though I might be able to use this opportunity to learn some more tcl/tk.

Thank you for your help
Fred James

gtk-list mailing list
gtk-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]