summaryrefslogtreecommitdiff
path: root/ext/tk/sample/demos-en/textpeer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/sample/demos-en/textpeer.rb')
-rw-r--r--ext/tk/sample/demos-en/textpeer.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/tk/sample/demos-en/textpeer.rb b/ext/tk/sample/demos-en/textpeer.rb
index d98ef170b4..c25ce15e5c 100644
--- a/ext/tk/sample/demos-en/textpeer.rb
+++ b/ext/tk/sample/demos-en/textpeer.rb
@@ -15,10 +15,12 @@ $textpeer_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($textpeer_demo).pack(:fill=>:both, :expand=>true)
+
count = [0]
## Define a widget that we peer from; it won't ever actually be shown though
-first = TkText.new($textpeer_demo, :widgetname=>"text#{count[0] += 1}")
+first = TkText.new(base_frame, :widgetname=>"text#{count[0] += 1}")
first.insert :end,"This is a coupled pair of text widgets; they are peers to "
first.insert :end,"each other. They have the same underlying data model, but "
first.insert :end,"can show different locations, have different current edit "
@@ -28,6 +30,8 @@ first.insert :end,"the Make Peer button beside the text widget to clone, and "
first.insert :end,"delete a particular peer widget using the Delete Peer "
first.insert :end,"button."
+Tk.update_idletasks ## for 'first' widget
+
## Procedures to make and kill clones; most of this is just so that the demo
## looks nice...
def makeClone(count, win, txt)
@@ -52,12 +56,12 @@ def killClone(win, cnt)
end
## Now set up the GUI
-makeClone(count, $textpeer_demo, first)
-makeClone(count, $textpeer_demo, first)
+makeClone(count, base_frame, first)
+makeClone(count, base_frame, first)
first.destroy
## See Code / Dismiss buttons
-TkFrame.new($textpeer_demo){|f|
+TkFrame.new(base_frame){|f|
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
$textpeer_demo.destroy
$textpeer_demo = nil
@@ -69,4 +73,4 @@ TkFrame.new($textpeer_demo){|f|
TkGrid.configure(f, '-', '-', :sticky=>'ew', :row=>5000)
}
-TkGrid.columnconfigure($textpeer_demo, 0, :weight=>1)
+TkGrid.columnconfigure(base_frame, 0, :weight=>1)