Posted to tcl by Emiliano at Wed Jan 23 14:34:21 GMT 2008view pretty
package require Tk package require tile ttk::setTheme clam proc add.instance { {title {}} } { global NB state set inst inst[format %04d $state(ID)] set pw [ttk::panedwindow $NB.$inst -orient vertical] # add the upper text set fup [ttk::frame $pw.up -padding 2] set txt [add.text $fup] #the lower text set fdown [ttk::frame $pw.down -padding 2] set peer [add.text $fdown $txt] # we want the lower pane to be hidden grid propagate $fdown 0 #in the case of resize, the upper pane should take all the space $pw add $fup -weight 1 $pw add $fdown -weight 0 if {$title eq ""} { set title "Untitled-$state(ID)" } $NB insert end $pw -text $title set state($inst.txt) $txt set state($inst.peer) $peer set state($inst.filename) {} set state($inst.modified) 0 set state($inst.title) $title incr state(ID) } proc add.text { parent {peerof {}} } { set vs [ttk::scrollbar $parent.vs -orient vertical] set hs [ttk::scrollbar $parent.hs -orient horizontal] if {$peerof eq ""} { set t [text $parent.txt \ -yscrollcommand [list $vs set] \ -xscrollcommand [list $hs set]] } else { set t [$peerof peer create $parent.txt \ -yscrollcommand [list $vs set] \ -xscrollcommand [list $hs set]] } $vs configure -command [list $t yview] $hs configure -command [list $t xview] grid $t $vs -sticky news grid $hs -sticky news grid columnconfigure $parent 0 -weight 1 grid rowconfigure $parent 0 -weight 1 return $t } proc build.gui {} { global NB set NB [ttk::notebook .nb] pack $NB -expand 1 -fill both option add *Text.background white option add *Text.highlightThickness 0 option add *Text.borderWidth 1 option add *Text.selectBorderWidth 0 } proc init {} { global state set state(ID) 0 } init build.gui add.instance bind all <Control-t> add.instance #after pressing ctrl-t, no new tab is shown inmediately #it *shows* after a while or after resizing the main window
Comments
Posted by jenglish at Tue Feb 05 03:39:40 GMT 2008 [text] [code]
Filed as SF bug #1878298; fixed in CVS 2008-01-29