summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-02 06:51:26 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-02 06:51:26 +0000
commit42d2b628dd92f7f2462c2c1eddc08870237a19db (patch)
treeb1cd60e46a54b4c81b65d038855d2255c80ad887 /ext
parent94c68757342a379ae69d239cc7f204bfe4315f96 (diff)
* ext/tk/sample/tkextlib/tile/demo.rb: added repeating buttons demo.
* ext/tk/sample/tkextlib/tile/repeater.tcl: ditto. (new file) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/tk/ChangeLog.tkextlib10
-rw-r--r--ext/tk/sample/tkextlib/tile/demo.rb40
2 files changed, 42 insertions, 8 deletions
diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib
index 85b4cf6191..c16daadb40 100644
--- a/ext/tk/ChangeLog.tkextlib
+++ b/ext/tk/ChangeLog.tkextlib
@@ -1,12 +1,18 @@
2005-08-01 ocean <ocean@ruby-lang.org>
+ * sample/tkextlib/tile/demo.rb: added repeating buttons demo.
+
+ * sample/tkextlib/tile/repeater.tcl: ditto. (new file)
+
+2005-08-01 ocean <ocean@ruby-lang.org>
+
* lib/tkextlib/tile.rb: fixed autoload for Treeview.
* lib/tkextlib/tile/treeview.rb: replaced `ary2tk_list(items)' with
`*items'.
- * sample/tkextlib/tile: added treeview demo. (tile 0.5 or later is
- needed) [ruby-dev:26668]
+ * sample/tkextlib/tile/demo.rb: added treeview demo. (tile 0.5 or
+ later is required) [ruby-dev:26668]
2005-08-01 ocean <ocean@ruby-lang.org>
diff --git a/ext/tk/sample/tkextlib/tile/demo.rb b/ext/tk/sample/tkextlib/tile/demo.rb
index 473e5b4bde..7c58704c56 100644
--- a/ext/tk/sample/tkextlib/tile/demo.rb
+++ b/ext/tk/sample/tkextlib/tile/demo.rb
@@ -10,6 +10,7 @@ Tk::AUTO_PATH.lappend('.', demodir, File.join(demodir, 'themes'))
require 'tkextlib/tile'
Tk.load_tclscript(File.join(demodir, 'toolbutton.tcl'))
+Tk.load_tclscript(File.join(demodir, 'repeater.tcl'))
# This forces an update of the available packages list. It's required
# for package names to find the themes in demos/themes/*.tcl
@@ -307,10 +308,6 @@ def makeNotebook
nb.add(tree, :text=>'Tree')
others = Tk::Tile::TFrame.new(nb)
nb.add(others, :text=>'Others', :underline=>4)
- nb.add(Tk::Tile::TLabel.new(nb, :text=>'Nothing to see here...'),
- :text=>'Stuff', :sticky=>:new)
- nb.add(Tk::Tile::TLabel.new(nb, :text=>'Nothing to see here either.'),
- :text=>'More Stuff', :sticky=>:se)
[nb, client, combo, tree, others]
end
@@ -624,7 +621,11 @@ showDescription.bind('Leave', proc{|w| msg.text('')}, '%W')
"Shows how Tile and standard scrollbars differ when they're sized too large" ],
[ :trackFocus, "Track keyboard focus..." ,
- "Display the name of the widget that currently has focus" ]
+ "Display the name of the widget that currently has focus" ],
+
+ [ :repeatDemo, "Repeating buttons...",
+ "Demonstrates custom classes (see demos/repeater.tcl)" ]
+
].each{|demo_cmd, label, description|
b = Tk::Tile::TButton.new(others, :text=>label,
:command=>proc{ self.__send__(demo_cmd) })
@@ -722,7 +723,6 @@ end
#
# Widget state demo:
#
-
$Widget = TkVariable.new
TkBindTag::ALL.bind('Control-Shift-ButtonPress-1',
@@ -808,4 +808,32 @@ def changeState(st)
end
end
+#
+# Repeating buttons demo:
+#
+def repeatDemo
+ if defined?($repeatDemo) && $repeatDemo.exist?
+ $repeatDemo.deiconify; return
+ end
+ $repeatDemo = TkToplevel.new(:title=>'Repeating button')
+
+ f = Tk::Tile::TFrame.new($repeatDemo)
+ b = Tk::Tile::TButton.new(f, :class=>'Repeater', :text=>'Press and hold')
+ begin
+ p = Tk::Tile::TProgressbar.new(f, :orient=>:horizontal, :maximum=>10)
+ rescue # progressbar is not supported (tile 0.4)
+ p = Tk::Tile::TLabel.new(f, :text=>0)
+ def p.step
+ i = self.text.to_i + 1
+ i = 0 if i >= 10
+ self.text(i.to_s)
+ end
+ end
+ b.command {p.step}
+
+ b.pack(:side=>:left, :expand=>false, :fill=>:none, :padx=>6, :pady=>6)
+ p.pack(:side=>:right, :expand=>true, :fill=>:x, :padx=>6, :pady=>6)
+ f.pack(:expand=>true, :fill=>:both)
+end
+
Tk.mainloop