📄 extfileselectionbox.itk
字号:
[file join $cwd .*] [file join $cwd *]]] { if {[file isdirectory $i]} { set insert "[file tail $i]" $itk_component(dirs) insert end "$insert" } } } else { set mask [file tail [$itk_component(filter) get]] foreach file [uplevel #0 $itk_option(-dirsearchcommand) $_pwd $mask] { $itk_component(dirs) insert end $file } } if {[$itk_component(dirs) size]} { $itk_component(dirs) selection clear 0 end $itk_component(dirs) selection set 0 }}# ------------------------------------------------------------------# PRIVATE METHOD: _setFileList## Clear the file list and dependent on whether the user has defined# their own search procedure or not fill the list with their results# or those of a 'glob'. If the files list has no contents, then set# the files list to the 'nomatchstring'. Clear all selections.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_setFileList {} { $itk_component(files) clear set mask [file tail [$itk_component(filter) get]] if {$itk_option(-filesearchcommand) == {}} { if {$mask == "*"} { set files [lsort [glob -nocomplain \ [file join $_pwd .*] [file join $_pwd *]]] } else { set files [lsort [glob -nocomplain [file join $_pwd $mask]]] } foreach i $files { if {($itk_option(-filetype) == "regular" && \ ! [file isdirectory $i]) || \ ($itk_option(-filetype) == "directory" && \ [file isdirectory $i]) || \ ($itk_option(-filetype) == "any")} { set insert "[file tail $i]" $itk_component(files) insert end "$insert" } } } else { foreach file [uplevel #0 $itk_option(-filesearchcommand) $_pwd $mask] { $itk_component(files) insert end $file } } if {[$itk_component(files) size] == 0} { if {$itk_option(-nomatchstring) != {}} { $itk_component(files) insert end $itk_option(-nomatchstring) } } $itk_component(files) selection clear 0 end}# ------------------------------------------------------------------# PRIVATE METHOD: _selectDir## For a selection in the directory list, set the filter and possibly# the selection entry based on the fileson option.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_selectDir {} { _setFilter if {$itk_option(-fileson)} {} { _setSelection } if {$itk_option(-selectdircommand) != {}} { uplevel #0 $itk_option(-selectdircommand) }}# ------------------------------------------------------------------# PRIVATE METHOD: _dblSelectDir## For a double click event in the directory list, select the# directory, set the default to the selection, and update both the# file and directory lists.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_dblSelectDir {} { filter}# ------------------------------------------------------------------# PRIVATE METHOD: _selectFile## The user has selected a file. Put the current selection in the# file list in the selection entry widget.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_selectFile {} { _setSelection if {$itk_option(-selectfilecommand) != {}} { uplevel #0 $itk_option(-selectfilecommand) }}# ------------------------------------------------------------------# PRIVATE METHOD: _selectSelection## The user has pressed Return in the selection entry widget. Call# the defined selection command if it exists.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_selectSelection {} { if {$itk_option(-selectioncommand) != {}} { uplevel #0 $itk_option(-selectioncommand) }}# ------------------------------------------------------------------# PRIVATE METHOD: _selectFilter## The user has pressed Return in the filter entry widget. Call the# defined selection command if it exists, otherwise just filter.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_selectFilter {} { if {$itk_option(-filtercommand) != {}} { uplevel #0 $itk_option(-filtercommand) } else { filter }}# ------------------------------------------------------------------# PRIVATE METHOD: _packComponents## Pack the selection, items, and child site widgets based on options.# Using the -in option of pack, put the childsite around the frame# in the hull for n, s, e, and w positions. Make sure and raise # the child site since using the 'in' option may obscure the site.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_packComponents {{when "later"}} { if {$when == "later"} { if {$_packToken == ""} { set _packToken [after idle [code $this _packComponents now]] } return } elseif {$when != "now"} { error "bad option \"$when\": should be now or later" } set _packToken "" # # Forget about any previous placements via the grid and # reset all the possible minsizes and weights for all # the rows and columns. # foreach component {childsite listpane filter selection} { grid forget $itk_component($component) } for {set row 0} {$row < 6} {incr row} { grid rowconfigure $_interior $row -minsize 0 -weight 0 } for {set col 0} {$col < 3} {incr col} { grid columnconfigure $_interior $col -minsize 0 -weight 0 } # # Place all the components based on the childsite poisition # option. # switch $itk_option(-childsitepos) { n { _nPos } w { _wPos } s { _sPos } e { _ePos } top { _topPos } bottom { _bottomPos } default { error "bad childsitepos option \"$itk_option(-childsitepos)\":\ should be n, e, s, w, top, or bottom" } }}# ------------------------------------------------------------------# PRIVATE METHOD: _nPos## Position the childsite to the north and all the other components# appropriately based on the individual "on" options.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_nPos {} { grid $itk_component(childsite) -row 0 -column 0 \ -columnspan 1 -rowspan 1 -sticky nsew -padx 5 if {$itk_option(-filteron)} { grid $itk_component(filter) -row 1 -column 0 \ -columnspan 1 -sticky ew -padx 5 grid rowconfigure $_interior 2 -minsize 7 } grid $itk_component(listpane) -row 3 -column 0 \ -columnspan 1 -sticky nsew grid rowconfigure $_interior 3 -weight 1 if {$itk_option(-selectionon)} { grid rowconfigure $_interior 4 -minsize 7 grid $itk_component(selection) -row 5 -column 0 \ -columnspan 1 -sticky ew -padx 5 } grid columnconfigure $_interior 0 -weight 1}# ------------------------------------------------------------------# PRIVATE METHOD: _sPos## Position the childsite to the south and all the other components# appropriately based on the individual "on" options.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_sPos {} { if {$itk_option(-filteron)} { grid $itk_component(filter) -row 0 -column 0 \ -columnspan 1 -sticky ew -padx 5 grid rowconfigure $_interior 1 -minsize 7 } grid $itk_component(listpane) -row 2 -column 0 \ -columnspan 1 -sticky nsew grid rowconfigure $_interior 2 -weight 1 if {$itk_option(-selectionon)} { grid rowconfigure $_interior 3 -minsize 7 grid $itk_component(selection) -row 4 -column 0 \ -columnspan 1 -sticky ew -padx 5 } grid $itk_component(childsite) -row 5 -column 0 \ -columnspan 1 -rowspan 1 -sticky nsew -padx 5 grid columnconfigure $_interior 0 -weight 1}# ------------------------------------------------------------------# PRIVATE METHOD: _ePos## Position the childsite to the east and all the other components# appropriately based on the individual "on" options.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_ePos {} { if {$itk_option(-filteron)} { grid $itk_component(filter) -row 0 -column 0 \ -columnspan 1 -sticky ew -padx 5 grid rowconfigure $_interior 1 -minsize 7 } grid $itk_component(listpane) -row 2 -column 0 \ -columnspan 1 -sticky nsew grid rowconfigure $_interior 2 -weight 1 if {$itk_option(-selectionon)} { grid rowconfigure $_interior 3 -minsize 7 grid $itk_component(selection) -row 4 -column 0 \ -columnspan 1 -sticky ew -padx 5 } grid $itk_component(childsite) -row 0 -column 1 \ -rowspan 5 -columnspan 1 -sticky nsew grid columnconfigure $_interior 0 -weight 1}# ------------------------------------------------------------------# PRIVATE METHOD: _wPos## Position the childsite to the west and all the other components# appropriately based on the individual "on" options.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_wPos {} { grid $itk_component(childsite) -row 0 -column 0 \ -rowspan 5 -columnspan 1 -sticky nsew if {$itk_option(-filteron)} { grid $itk_component(filter) -row 0 -column 1 \ -columnspan 1 -sticky ew -padx 5 grid rowconfigure $_interior 1 -minsize 7 } grid $itk_component(listpane) -row 2 -column 1 \ -columnspan 1 -sticky nsew grid rowconfigure $_interior 2 -weight 1 if {$itk_option(-selectionon)} { grid rowconfigure $_interior 3 -minsize 7 grid $itk_component(selection) -row 4 -column 1 \ -columnspan 1 -sticky ew -padx 5 } grid columnconfigure $_interior 1 -weight 1}# ------------------------------------------------------------------# PRIVATE METHOD: _topPos## Position the childsite below the filter but above the lists and # all the other components appropriately based on the individual # "on" options.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_topPos {} { if {$itk_option(-filteron)} { grid $itk_component(filter) -row 0 -column 0 \ -columnspan 1 -sticky ew -padx 5 } grid $itk_component(childsite) -row 1 -column 0 \ -columnspan 1 -rowspan 1 -sticky nsew -padx 5 grid $itk_component(listpane) -row 2 -column 0 -sticky nsew grid rowconfigure $_interior 2 -weight 1 if {$itk_option(-selectionon)} { grid rowconfigure $_interior 3 -minsize 7 grid $itk_component(selection) -row 4 -column 0 \ -columnspan 1 -sticky ew -padx 5 } grid columnconfigure $_interior 0 -weight 1}# ------------------------------------------------------------------# PRIVATE METHOD: _bottomPos## Position the childsite below the lists and above the selection# and all the other components appropriately based on the individual # "on" options.# ------------------------------------------------------------------body iwidgets::Extfileselectionbox::_bottomPos {} { if {$itk_option(-filteron)} { grid $itk_component(filter) -row 0 -column 0 \ -columnspan 1 -sticky ew -padx 5 grid rowconfigure $_interior 1 -minsize 7 } grid $itk_component(listpane) -row 2 -column 0 -sticky nsew grid rowconfigure $_interior 2 -weight 1 grid $itk_component(childsite) -row 3 -column 0 \ -columnspan 1 -rowspan 1 -sticky nsew -padx 5 if {$itk_option(-selectionon)} { grid $itk_component(selection) -row 4 -column 0 \ -columnspan 1 -sticky ew -padx 5 } grid columnconfigure $_interior 0 -weight 1}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -