# text.rb # # This demonstration script creates a text widget that describes # the basic editing functions. # # text (basic facilities) widget demo (called by 'widget') # # toplevel widget if defined?($text_demo) && $text_demo $text_demo.destroy $text_demo = nil end # demo toplevel widget $text_demo = TkToplevel.new {|w| title("Text Demonstration - Basic Facilities") iconname("text") positionWindow(w) } base_frame = TkFrame.new($text_demo).pack(:fill=>:both, :expand=>true) # version check if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0) undo_support = false else undo_support = true end # frame TkFrame.new(base_frame) {|frame| TkButton.new(frame) { text 'Dismiss' command proc{ tmppath = $text_demo $text_demo = nil tmppath.destroy } }.pack('side'=>'left', 'expand'=>'yes') TkButton.new(frame) { text 'Show Code' command proc{showCode 'text'} }.pack('side'=>'left', 'expand'=>'yes') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # text TkText.new(base_frame){|t| relief 'sunken' bd 2 setgrid 1 height 30 if undo_support undo true autoseparators true end TkScrollbar.new(base_frame) {|s| pack('side'=>'right', 'fill'=>'y') command proc{|*args| t.yview(*args)} t.yscrollcommand proc{|first,last| s.set first,last} } pack('expand'=>'yes', 'fill'=>'both') # insert('0.0', <