2003-08-02 05:58:13 -04:00
|
|
|
|
# paned2.rb --
|
|
|
|
|
#
|
|
|
|
|
# This demonstration script creates a toplevel window containing
|
|
|
|
|
# a paned window that separates two windows vertically.
|
|
|
|
|
#
|
|
|
|
|
# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
|
|
|
|
|
|
|
|
|
|
if defined?($paned2_demo) && $paned2_demo
|
|
|
|
|
$paned2_demo.destroy
|
|
|
|
|
$paned2_demo = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
$paned2_demo = TkToplevel.new {|w|
|
|
|
|
|
title("Vertical Paned Window Demonstration")
|
|
|
|
|
iconname("paned2")
|
|
|
|
|
positionWindow(w)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TkLabel.new($paned2_demo,
|
2004-10-11 00:51:21 -04:00
|
|
|
|
:font=>$font, :wraplength=>'4i', :justify=>:left,
|
|
|
|
|
:text=><<EOL).pack(:side=>:top)
|
2003-08-02 05:58:13 -04:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>դ<EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>줿<EFBFBD><EFBFBD><EFBFBD>ĤΥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><EFBFBD>δ֤λ<EFBFBD><EFBFBD>ڤ<EFBFBD><EFBFBD>Ȥϡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĥ<EFBFBD><EFBFBD>ΰ<EFBFBD><EFBFBD>줾<EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><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FBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>褦<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>꿷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Tk <EFBFBD><EFBFBD><EFBFBD>Ȥ߹<EFBFBD><EFBFBD>碌<EFBFBD>ƻ
|
|
|
|
|
<EFBFBD>褦<EFBFBD>ˤ<EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
EOL
|
|
|
|
|
|
|
|
|
|
# The bottom buttons
|
|
|
|
|
TkFrame.new($paned2_demo){|f|
|
|
|
|
|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
|
|
|
|
|
|
2004-05-01 12:09:54 -04:00
|
|
|
|
TkButton.new(f, :text=>'<27>Ĥ<EFBFBD><C4A4><EFBFBD>', :width=>15, :command=>proc{
|
2004-10-11 00:51:21 -04:00
|
|
|
|
$paned2_demo.destroy
|
|
|
|
|
$paned2_demo = nil
|
|
|
|
|
}).pack(:side=>:left, :expand=>true)
|
2003-08-02 05:58:13 -04:00
|
|
|
|
|
|
|
|
|
TkButton.new(f, :text=>'<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>', :width=>15, :command=>proc{
|
2004-10-11 00:51:21 -04:00
|
|
|
|
showCode 'paned2'
|
|
|
|
|
}).pack(:side=>:left, :expand=>true)
|
2003-08-02 05:58:13 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paneList = TkVariable.new # define as normal variable (not array)
|
|
|
|
|
paneList.value = [ # ruby's array --> tcl's list
|
|
|
|
|
'Ruby/Tk <20>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȰ<C3A5><C8B0><EFBFBD>',
|
|
|
|
|
'TkButton',
|
|
|
|
|
'TkCanvas',
|
|
|
|
|
'TkCheckbutton',
|
|
|
|
|
'TkEntry',
|
|
|
|
|
'TkFrame',
|
|
|
|
|
'TkLabel',
|
|
|
|
|
'TkLabelframe',
|
|
|
|
|
'TkListbox',
|
|
|
|
|
'TkMenu',
|
|
|
|
|
'TkMenubutton',
|
|
|
|
|
'TkMessage',
|
|
|
|
|
'TkPanedwindow',
|
|
|
|
|
'TkRadiobutton',
|
|
|
|
|
'TkScale',
|
|
|
|
|
'TkScrollbar',
|
|
|
|
|
'TkSpinbox',
|
|
|
|
|
'TkText',
|
|
|
|
|
'TkToplevel'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# Create the pane itself
|
|
|
|
|
TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
|
|
|
|
|
pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
|
|
|
|
|
|
|
|
|
|
add(TkFrame.new(f){|paned2_top|
|
2004-10-11 00:51:21 -04:00
|
|
|
|
TkListbox.new(paned2_top, :listvariable=>paneList) {
|
|
|
|
|
# Invert the first item to highlight it
|
|
|
|
|
itemconfigure(0, :background=>self.cget(:foreground),
|
|
|
|
|
:foreground=>self.cget(:background) )
|
|
|
|
|
yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right,
|
|
|
|
|
:fill=>:y))
|
|
|
|
|
pack(:fill=>:both, :expand=>true)
|
|
|
|
|
}
|
2003-08-02 05:58:13 -04:00
|
|
|
|
},
|
|
|
|
|
|
2004-07-01 05:38:48 -04:00
|
|
|
|
TkFrame.new(f, :height=>120) {|paned2_bottom|
|
2004-10-11 00:51:21 -04:00
|
|
|
|
# The bottom window is a text widget with scrollbar
|
|
|
|
|
paned2_xscr = TkScrollbar.new(paned2_bottom)
|
|
|
|
|
paned2_yscr = TkScrollbar.new(paned2_bottom)
|
|
|
|
|
paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
|
|
|
|
|
insert('1.0', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD>Τϡ<CEA4>' +
|
|
|
|
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̤Υƥ<CEA5><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤǤ<C8A4><C7A4><EFBFBD>')
|
|
|
|
|
xscrollbar(paned2_xscr)
|
|
|
|
|
yscrollbar(paned2_yscr)
|
|
|
|
|
}
|
|
|
|
|
Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
|
|
|
|
|
Tk.grid(paned2_xscr, :sticky=>'nsew')
|
|
|
|
|
TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
|
|
|
|
|
TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
|
2003-08-02 05:58:13 -04:00
|
|
|
|
} )
|
|
|
|
|
}
|