2005-04-09 05:27:54 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
|
|
|
# Demo for 'tile' package.
|
|
|
|
#
|
|
|
|
require 'tk'
|
|
|
|
|
|
|
|
demodir = File.dirname($0)
|
2005-11-25 02:05:22 -05:00
|
|
|
themesdir = File.join(demodir, 'themes')
|
|
|
|
Tk::AUTO_PATH.lappend('.', demodir, themesdir)
|
|
|
|
|
|
|
|
Dir.foreach(themesdir){|name|
|
|
|
|
next if name == '.' || name == '..'
|
|
|
|
dir = File.join(themesdir, name)
|
|
|
|
Tk::AUTO_PATH.lappend(dir) if File.directory?(dir)
|
|
|
|
}
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
require 'tkextlib/tile'
|
|
|
|
|
2005-08-04 00:16:27 -04:00
|
|
|
def version?(ver)
|
|
|
|
TkPackage.vcompare(Tk::Tile.package_version, ver) >= 0
|
|
|
|
end
|
|
|
|
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
# define Tcl/Tk procedures for compatibility
|
|
|
|
Tk::Tile.__define_LoadImages_proc_for_compatibility__!
|
|
|
|
Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
|
|
|
|
|
* ext/tk/tcltklib.c: SEGV when tcltk-stubs is enabled.
* ext/tk/tcltklib.c: avoid error on a shared object.
* ext/tk/extconf.rb: support --with-tcltkversion
* ext/tk/README.tcltklib: add document about --with-tcltkversion
* ext/tk/lib/tk.rb, ext/tk/lib/multi-tk.rb, ext/tk/lib/remote-tk.rb:
not work on $SAFE==4
* ext/tk/lib/multi-tk.rb: Object#methods returns Symbols on Ruby1.9.
* ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the
procedure which called at end of the timer.
* ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb:
support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options.
* ext/tk/lib/*: treat __IGNORE_UNKNOWN_CONFIGURE_OPTION__
* ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb,
ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb,
ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix.
* ext/tk/lib/tk/text.rb: typo. call a wrong method.
* ext/tk/lib/tk/itemconfig.rb: ditto.
* ext/tk/lib/tk.rb, ext/tk/lib/tk/itemconfig.rb,
ext/tk/lib/tk/canvas.rb: support alias names of option keys.
* ext/tk/lib/tk/grid.rb: lack of module-method definitions.
* ext/tk/lib/tk/pack.rb, ext/tk/lib/tk/grid.rb: increase supported
parameter patterns of configure method.
* ext/tk/lib/tk.rb: add TkWindow#grid_anchor, grid_column, grid_row.
* ext/tk/lib/tk/wm.rb: methods of Tk::Wm_for_General module cannot
pass the given block to methods of Tk::Wm module.
* ext/tk/lib/tk/wm.rb: Wm#overrideredirect overwrites arguemnt to
an invalid value.
* ext/tk/lib/tk.rb: fix memory (object) leak bug.
* ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: fix memory leak.
* ext/tk/sample/demos-jp/aniwave.rb, ext/tk/sample/demos-en/aniwave.rb:
bug fix.
* ext/tk/lib/tkextlib/blt/component.rb,
ext/tk/lib/tkextlib/tile/tentry.rb,
ext/tk/lib/tkextlib/tile/treeview.rb: ditto.
* ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget,
ext/tk/sample/demos-jp/style.rb, ext/tk/sample/demos-en/style.rb,
ext/tk/sample/demos-jp/bind.rb, ext/tk/sample/demos-en/bind.rb:
bug fix.
* ext/tk/sample/ttk_wrapper.rb: ditto.
* ext/tk/sample/ttk_wrapper.rb: support "if __FILE__ == $0" idiom.
* ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode.
* ext/tk/lib/tkextlib/tile.rb, ext/tk/lib/tkextlib/tile/style.rb,
ext/tk/sample/ttk_wrapper.rb: improve treating and control themes.
add Tk::Tile.themes and Tk::Tile.set_theme(theme).
* ext/tk/lib/tkextlib/tile.rb: lack of autoload definitions.
* ext/tk/lib/tkextlib/tile/tnotebook.rb: cannot use kanji (not UTF-8)
characters for headings.
* ext/tk/lib/tkextlib/tkDND/shape.rb: wrong package name.
* ext/tk/tkutil/tkutil.c: improve handling callback-subst-keys.
Now, support longnam-keys (e.g. '%CTT' on tkdnd-2.0; however, still
not support tkdnd-2.0 on tkextlib), and symbols of parameters (e.g.
:widget=>'%W', :keycode=>'%k', '%x'=>:x, '%X'=>:root_x, and so on;
those are attributes of event object). It means that Ruby/Tk accepts
not only "widget.bind(ev, '%W', '%k', ...){|w, k, ...| ... }", but
also "widget.bind(ev, :widget, :keycode, ...){|w, k, ...| ... }".
It is potentially incompatible, when user passes symbols to the
arguments of the callback block (the block receives the symbols as
strings). I think that is very rare case (probably, used by Ruby/Tk
experts only). When causes such trouble, please give strings instead
of such symbol parameters (e.g. call Symbol#to_s method).
* ext/tk/lib/tk/event.rb, ext/tk/lib/tk/validation.rb,
ext/tk/lib/tkextlib/blt/treeview.rb,
ext/tk/lib/tkextlib/winico/winico.rb: ditto.
* ext/tk/tkutil/tkutil.c: strings are available on subst_tables on
TkUtil::CallbackSubst class (it is useful on Ruby 1.9).
* ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tkextlib/iwidgets/hierarchy.rb,
ext/tk/lib/tkextlib/iwidgets/spinner.rb,
ext/tk/lib/tkextlib/iwidgets/entryfield.rb,
ext/tk/lib/tkextlib/iwidgets/calendar.rb,
ext/tk/lib/tkextlib/blt/dragdrop.rb,
ext/tk/lib/tkextlib/tkDND/tkdnd.rb,
ext/tk/lib/tkextlib/treectrl/tktreectrl.rb,
ext/tk/lib/tkextlib/tktable/tktable.rb: disable code piece became
unnecessary by reason of the changes of ext/tk/tkutil/tkutil.c.
* ext/tk/lib/tk.rb, ext/tk/lib/multi-tk.rb: change strategy to define
the constant WITH_ENCODING.
* ext/tk/lib/tk.rb: fix bug on Tk::Encoding.tk_encoding_names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-10 16:59:10 -04:00
|
|
|
unless Tk::Tile::Style.theme_names.include?('step')
|
|
|
|
Tk::Tile::Style.theme_create('step')
|
|
|
|
end
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
|
2005-04-09 05:27:54 -04:00
|
|
|
Tk.load_tclscript(File.join(demodir, 'toolbutton.tcl'))
|
2005-08-02 02:51:26 -04:00
|
|
|
Tk.load_tclscript(File.join(demodir, 'repeater.tcl'))
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
# This forces an update of the available packages list. It's required
|
|
|
|
# for package names to find the themes in demos/themes/*.tcl
|
2005-08-02 17:05:17 -04:00
|
|
|
## Tk.tk_call(TkPackage.unknown_proc, 'Tcl', TkPackage.provide('Tcl'))
|
|
|
|
## --> This doesn't work.
|
|
|
|
## Because, unknown_proc may be "command + some arguments".
|
|
|
|
Tk.ip_eval("#{TkPackage.unknown_proc} Tcl #{TkPackage.provide('Tcl')}")
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
TkRoot.new{
|
|
|
|
title 'Tile demo'
|
|
|
|
iconname 'Tile demo'
|
|
|
|
}
|
|
|
|
|
|
|
|
# The descriptive names of the builtin themes.
|
|
|
|
$THEMELIST = [
|
2005-11-25 02:05:22 -05:00
|
|
|
['default', 'Default'],
|
|
|
|
['classic', 'Classic'],
|
2005-04-09 05:27:54 -04:00
|
|
|
['alt', 'Revitalized'],
|
|
|
|
['winnative', 'Windows native'],
|
|
|
|
['xpnative', 'XP Native'],
|
|
|
|
['aqua', 'Aqua'],
|
|
|
|
]
|
|
|
|
|
|
|
|
$V = TkVariable.new_hash(:THEME => 'default',
|
|
|
|
:COMPOUND => 'top',
|
|
|
|
:CONSOLE => false,
|
|
|
|
:MENURADIO1 => 'One',
|
2005-08-04 00:16:27 -04:00
|
|
|
:MENUCHECK1 => true,
|
|
|
|
:PBMODE => 'determinate',
|
|
|
|
:SELECTED => true,
|
|
|
|
:CHOICE => 2)
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
# Add in any available loadable themes.
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
TkPackage.names.find_all{|n| n =~ /^(tile|ttk)::theme::/}.each{|pkg|
|
2005-04-09 05:27:54 -04:00
|
|
|
name = pkg.split('::')[-1]
|
|
|
|
unless $THEMELIST.assoc(name)
|
|
|
|
$THEMELIST << [name, Tk.tk_call('string', 'totitle', name)]
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add theme definition written by ruby
|
|
|
|
$RUBY_THEMELIST = []
|
|
|
|
begin
|
|
|
|
load(File.join(demodir, 'themes', 'kroc.rb'), true)
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
rescue => e
|
|
|
|
raise e
|
2005-04-09 05:27:54 -04:00
|
|
|
$RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', false]
|
|
|
|
else
|
|
|
|
$RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', true]
|
|
|
|
end
|
|
|
|
|
|
|
|
def makeThemeControl(parent)
|
2005-08-04 00:48:13 -04:00
|
|
|
c = Tk::Tile::Labelframe.new(parent, :text=>'Theme')
|
2005-04-09 05:27:54 -04:00
|
|
|
$THEMELIST.each{|theme, name|
|
2005-08-04 00:48:13 -04:00
|
|
|
b = Tk::Tile::Radiobutton.new(c, :text=>name, :value=>theme,
|
2005-08-04 00:54:08 -04:00
|
|
|
:variable=>$V.ref(:THEME),
|
|
|
|
:command=>proc{setTheme(theme)})
|
2005-04-09 05:27:54 -04:00
|
|
|
b.grid(:sticky=>:ew)
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
unless (TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
|
|
|
|
b.ttk_state(:disabled)
|
2005-04-09 05:27:54 -04:00
|
|
|
end
|
|
|
|
}
|
|
|
|
$RUBY_THEMELIST.each{|theme, name, available|
|
2005-08-04 00:48:13 -04:00
|
|
|
b = Tk::Tile::Radiobutton.new(c, :text=>name, :value=>theme,
|
2005-08-04 00:54:08 -04:00
|
|
|
:variable=>$V.ref(:THEME),
|
|
|
|
:command=>proc{setTheme(theme)})
|
2005-04-09 05:27:54 -04:00
|
|
|
b.grid(:sticky=>:ew)
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
b.ttk_state(:disabled) unless available
|
2005-04-09 05:27:54 -04:00
|
|
|
}
|
|
|
|
c
|
|
|
|
end
|
|
|
|
|
|
|
|
def makeThemeMenu(parent)
|
|
|
|
m = TkMenu.new(parent)
|
|
|
|
$THEMELIST.each{|theme, name|
|
|
|
|
m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME),
|
|
|
|
:value=>theme, :command=>proc{setTheme(theme)})
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
unless (TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
|
2005-04-09 05:27:54 -04:00
|
|
|
m.entryconfigure(:end, :state=>:disabled)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
$RUBY_THEMELIST.each{|theme, name, available|
|
|
|
|
m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME),
|
|
|
|
:value=>theme, :command=>proc{setTheme(theme)})
|
|
|
|
m.entryconfigure(:end, :state=>:disabled) unless available
|
|
|
|
}
|
|
|
|
m
|
|
|
|
end
|
|
|
|
|
|
|
|
def setTheme(theme)
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
if (pkg = TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
|
|
|
|
unless Tk::Tile::Style.theme_names.find{|n| n == theme}
|
|
|
|
TkPackage.require(pkg)
|
|
|
|
end
|
2005-04-09 05:27:54 -04:00
|
|
|
end
|
|
|
|
Tk::Tile::Style.theme_use(theme)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Load icons...
|
|
|
|
#
|
|
|
|
$BUTTONS = ['open', 'new', 'save']
|
|
|
|
$CHECKBOXES = ['bold', 'italic']
|
|
|
|
$ICON = {}
|
|
|
|
|
|
|
|
def loadIcons(file)
|
|
|
|
Tk.load_tclscript(file)
|
|
|
|
img_data = TkVarAccess.new('ImgData')
|
|
|
|
img_data.keys.each{|icon|
|
|
|
|
$ICON[icon] = TkPhotoImage.new(:data=>img_data[icon])
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
loadIcons(File.join(demodir, 'iconlib.tcl'))
|
|
|
|
|
|
|
|
#
|
|
|
|
# Utilities:
|
|
|
|
#
|
|
|
|
def foreachWidget(wins, cmd)
|
|
|
|
wins.each{|w|
|
|
|
|
cmd.call(w)
|
|
|
|
foreachWidget(w.winfo_children, cmd)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
# sbstub
|
|
|
|
# Used as the :command option for a scrollbar,
|
|
|
|
# updates the scrollbar's position.
|
|
|
|
#
|
|
|
|
def sbstub(sb, cmd, num, units = 'units')
|
2005-06-05 10:03:41 -04:00
|
|
|
num = TkComm.number(num)
|
2005-04-09 05:27:54 -04:00
|
|
|
case cmd.to_s
|
|
|
|
when 'moveto'
|
|
|
|
sb.set(num, num+0.5)
|
|
|
|
|
|
|
|
when 'scroll'
|
|
|
|
if units.to_s == 'pages'
|
|
|
|
delta = 0.2
|
|
|
|
else
|
|
|
|
delta = 0.05
|
|
|
|
end
|
|
|
|
current = sb.get
|
|
|
|
sb.set(current[0] + delta * num, current[1] + delta * num)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# ... for debugging:
|
|
|
|
TkBindTag::ALL.bind('ButtonPress-3', proc{|w| $W = w}, '%W')
|
|
|
|
TkBindTag::ALL.bind('Control-ButtonPress-3', proc{|w| w.set_focus}, '%W')
|
|
|
|
|
|
|
|
def showHelp()
|
|
|
|
Tk.messageBox(:message=>'No help yet...')
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# See toolbutton.tcl.
|
|
|
|
TkOption.add('*Toolbar.relief', :groove)
|
|
|
|
TkOption.add('*Toolbar.borderWidth', 2)
|
|
|
|
|
|
|
|
TkOption.add('*Toolbar.Button.Pad', 2)
|
|
|
|
|
|
|
|
$ROOT = Tk.root
|
|
|
|
$BASE = $ROOT
|
|
|
|
Tk.destroy(*($ROOT.winfo_children))
|
|
|
|
|
|
|
|
$TOOLBARS = []
|
|
|
|
|
|
|
|
#
|
|
|
|
# Toolbar button standard vs. tile comparison:
|
|
|
|
#
|
|
|
|
def makeToolbars
|
|
|
|
#
|
|
|
|
# Tile toolbar:
|
|
|
|
#
|
2005-08-04 00:48:13 -04:00
|
|
|
tb = Tk::Tile::Frame.new($BASE, :class=>'Toolbar')
|
2005-04-09 05:27:54 -04:00
|
|
|
$TOOLBARS << tb
|
|
|
|
i = 0
|
|
|
|
$BUTTONS.each{|icon|
|
|
|
|
i += 1
|
2005-08-04 00:48:13 -04:00
|
|
|
Tk::Tile::Button.new(tb, :text=>icon, :image=>$ICON[icon],
|
2005-08-04 00:54:08 -04:00
|
|
|
:compound=>$V[:COMPOUND],
|
|
|
|
:style=>:Toolbutton).grid(:row=>0, :column=>i,
|
|
|
|
:sticky=>:news)
|
2005-04-09 05:27:54 -04:00
|
|
|
}
|
|
|
|
$CHECKBOXES.each{|icon|
|
|
|
|
i += 1
|
2005-08-04 00:48:13 -04:00
|
|
|
Tk::Tile::Checkbutton.new(tb, :text=>icon, :image=>$ICON[icon],
|
2005-08-04 00:54:08 -04:00
|
|
|
:variable=>$V.ref(icon),
|
|
|
|
:compound=>$V[:COMPOUND],
|
|
|
|
:style=>:Toolbutton).grid(:row=>0, :column=>i,
|
|
|
|
:sticky=>:news)
|
2005-04-09 05:27:54 -04:00
|
|
|
}
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
mb = Tk::Tile::Menubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'],
|
2005-08-04 00:54:08 -04:00
|
|
|
:compound=>$V[:COMPOUND])
|
2005-04-09 05:27:54 -04:00
|
|
|
mb.configure(:menu=>makeCompoundMenu(mb))
|
|
|
|
i += 1
|
|
|
|
mb.grid(:row=>0, :column=>i, :sticky=>:news)
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
tb.grid_columnconfigure(i, :weight=>1)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Standard toolbar:
|
|
|
|
#
|
|
|
|
tb = TkFrame.new($BASE, :class=>'Toolbar')
|
|
|
|
$TOOLBARS << tb
|
|
|
|
i = 0
|
|
|
|
$BUTTONS.each{|icon|
|
|
|
|
i += 1
|
|
|
|
TkButton.new(tb, :text=>icon, :image=>$ICON[icon],
|
|
|
|
:compound=>$V[:COMPOUND], :relief=>:flat,
|
|
|
|
:overrelief=>:raised).grid(:row=>0, :column=>i,
|
|
|
|
:sticky=>:news)
|
|
|
|
}
|
|
|
|
$CHECKBOXES.each{|icon|
|
|
|
|
i += 1
|
|
|
|
TkCheckbutton.new(tb, :text=>icon, :image=>$ICON[icon],
|
|
|
|
:variable=>$V.ref(icon), :compound=>$V[:COMPOUND],
|
|
|
|
:indicatoron=>false, :selectcolor=>'', :relief=>:flat,
|
|
|
|
:overrelief=>:raised).grid(:row=>0, :column=>i,
|
|
|
|
:sticky=>:news)
|
|
|
|
}
|
|
|
|
|
|
|
|
mb = TkMenubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'],
|
|
|
|
:compound=>$V[:COMPOUND])
|
|
|
|
mb.configure(:menu=>makeCompoundMenu(mb))
|
|
|
|
i += 1
|
|
|
|
mb.grid(:row=>0, :column=>i, :sticky=>:news)
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
tb.grid_columnconfigure(i, :weight=>1)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Toolbar :compound control:
|
|
|
|
#
|
|
|
|
def makeCompoundMenu(mb)
|
|
|
|
menu = TkMenu.new(mb)
|
|
|
|
%w(text image none top bottom left right center).each{|str|
|
|
|
|
menu.add(:radiobutton, :label=>Tk.tk_call('string', 'totitle', str),
|
|
|
|
:variable=>$V.ref(:COMPOUND), :value=>str,
|
|
|
|
:command=>proc{ changeToolbars() })
|
|
|
|
}
|
|
|
|
menu
|
|
|
|
end
|
|
|
|
|
|
|
|
makeToolbars()
|
|
|
|
|
|
|
|
## CONTROLS
|
2005-08-04 00:48:13 -04:00
|
|
|
control = Tk::Tile::Frame.new($BASE)
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Overall theme control:
|
|
|
|
#
|
|
|
|
makeThemeControl(control).grid(:sticky=>:news, :padx=>6, :ipadx=>6)
|
|
|
|
control.grid_rowconfigure(99, :weight=>1)
|
|
|
|
|
|
|
|
def changeToolbars
|
|
|
|
foreachWidget($TOOLBARS,
|
|
|
|
proc{|w|
|
|
|
|
begin
|
|
|
|
w.compound($V[:COMPOUND])
|
|
|
|
rescue
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
def scrolledWidget(parent, klass, themed, *args)
|
|
|
|
if themed
|
2005-08-04 00:48:13 -04:00
|
|
|
f = Tk::Tile::Frame.new(parent)
|
2005-04-09 05:27:54 -04:00
|
|
|
t = klass.new(f, *args)
|
2005-08-04 00:48:13 -04:00
|
|
|
vs = Tk::Tile::Scrollbar.new(f)
|
|
|
|
hs = Tk::Tile::Scrollbar.new(f)
|
2005-04-09 05:27:54 -04:00
|
|
|
else
|
|
|
|
f = TkFrame.new(parent)
|
|
|
|
t = klass.new(f, *args)
|
|
|
|
vs = TkScrollbar.new(f)
|
|
|
|
hs = TkScrollbar.new(f)
|
|
|
|
end
|
|
|
|
t.yscrollbar(vs)
|
|
|
|
t.xscrollbar(hs)
|
|
|
|
|
|
|
|
TkGrid.configure(t, vs, :sticky=>:news)
|
|
|
|
TkGrid.configure(hs, 'x', :sticky=>:news)
|
|
|
|
TkGrid.rowconfigure(f, 0, :weight=>1)
|
|
|
|
TkGrid.columnconfigure(f, 0, :weight=>1)
|
|
|
|
|
|
|
|
[f, t]
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Notebook demonstration:
|
|
|
|
#
|
|
|
|
def makeNotebook
|
2005-08-04 00:48:13 -04:00
|
|
|
nb = Tk::Tile::Notebook.new($BASE, :padding=>6)
|
2005-04-09 05:27:54 -04:00
|
|
|
nb.enable_traversal
|
2005-08-04 00:48:13 -04:00
|
|
|
client = Tk::Tile::Frame.new(nb)
|
2005-04-09 05:27:54 -04:00
|
|
|
nb.add(client, :text=>'Demo', :underline=>0)
|
|
|
|
nb.select(client)
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
scales = Tk::Tile::Frame.new(nb)
|
2005-08-04 00:16:27 -04:00
|
|
|
nb.add(scales, :text=>'Scales')
|
2005-08-04 00:48:13 -04:00
|
|
|
combo = Tk::Tile::Frame.new(nb)
|
2005-08-01 02:35:15 -04:00
|
|
|
nb.add(combo, :text=>'Combobox', :underline=>7)
|
2005-08-04 00:48:13 -04:00
|
|
|
tree = Tk::Tile::Frame.new(nb)
|
2005-08-01 06:25:51 -04:00
|
|
|
nb.add(tree, :text=>'Tree')
|
2005-08-04 00:48:13 -04:00
|
|
|
others = Tk::Tile::Frame.new(nb)
|
2005-04-09 05:27:54 -04:00
|
|
|
nb.add(others, :text=>'Others', :underline=>4)
|
|
|
|
|
2005-08-04 00:16:27 -04:00
|
|
|
[nb, client, scales, combo, tree, others]
|
2005-04-09 05:27:54 -04:00
|
|
|
end
|
|
|
|
|
2005-08-04 00:16:27 -04:00
|
|
|
nb, client, scales, combo, tree, others = makeNotebook()
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Side-by side check, radio, and menu button comparison:
|
|
|
|
#
|
|
|
|
def fillMenu(menu)
|
|
|
|
%w(above below left right flush).each{|dir|
|
|
|
|
menu.add(:command, :label=>Tk.tk_call('string', 'totitle', dir),
|
|
|
|
:command=>proc{ menu.winfo_parent.direction(dir) })
|
|
|
|
}
|
|
|
|
menu.add(:cascade, :label=>'Submenu', :menu=>(submenu = TkMenu.new(menu)))
|
|
|
|
submenu.add(:command, :label=>'Subcommand 1')
|
|
|
|
submenu.add(:command, :label=>'Subcommand 2')
|
|
|
|
submenu.add(:command, :label=>'Subcommand 3')
|
|
|
|
|
|
|
|
menu.add(:separator)
|
|
|
|
menu.add(:command, :label=>'Quit', :command=>proc{Tk.root.destroy})
|
|
|
|
end
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
l = Tk::Tile::Labelframe.new(client, :text=>'Themed', :padding=>6)
|
2005-04-09 05:27:54 -04:00
|
|
|
r = TkLabelframe.new(client, :text=>'Standard', :padx=>6, :pady=>6)
|
|
|
|
|
|
|
|
## Styled frame
|
2005-08-04 00:48:13 -04:00
|
|
|
cb = Tk::Tile::Checkbutton.new(l, :text=>'Checkbutton',
|
2005-08-04 00:54:08 -04:00
|
|
|
:variable=>$V.ref(:SELECTED), :underline=>2)
|
2005-08-04 00:48:13 -04:00
|
|
|
rb1 = Tk::Tile::Radiobutton.new(l, :text=>'One', :variable=>$V.ref(:CHOICE),
|
2005-08-04 00:54:08 -04:00
|
|
|
:value=>1, :underline=>0)
|
2005-08-04 00:48:13 -04:00
|
|
|
rb2 = Tk::Tile::Radiobutton.new(l, :text=>'Two', :variable=>$V.ref(:CHOICE),
|
2005-08-04 00:54:08 -04:00
|
|
|
:value=>2)
|
2005-08-04 00:48:13 -04:00
|
|
|
rb3 = Tk::Tile::Radiobutton.new(l, :text=>'Three',
|
2005-08-04 00:54:08 -04:00
|
|
|
:variable=>$V.ref(:CHOICE),
|
|
|
|
:value=>3, :underline=>0)
|
2005-08-04 00:48:13 -04:00
|
|
|
btn = Tk::Tile::Button.new(l, :text=>'Button', :underline=>0)
|
2005-04-09 05:27:54 -04:00
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
mb = Tk::Tile::Menubutton.new(l, :text=>'Menubutton', :underline=>2)
|
2005-11-25 02:05:22 -05:00
|
|
|
m = TkMenu.new(mb)
|
|
|
|
mb.menu(m)
|
|
|
|
fillMenu(m)
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
$entryText = TkVariable.new('Entry widget')
|
2005-08-04 00:48:13 -04:00
|
|
|
e = Tk::Tile::Entry.new(l, :textvariable=>$entryText)
|
2005-04-09 05:27:54 -04:00
|
|
|
e.selection_range(6, :end)
|
|
|
|
|
|
|
|
ltext_f, ltext = scrolledWidget(l, TkText, true,
|
|
|
|
:width=>12, :height=>5, :wrap=>:none)
|
|
|
|
# NOTE TO MAINTAINERS:
|
|
|
|
# The checkbuttons are -sticky ew / -expand x on purpose:
|
|
|
|
# it demonstrates one of the differences between TCheckbuttons
|
|
|
|
# and standard checkbuttons.
|
|
|
|
#
|
|
|
|
Tk.grid(cb, :sticky=>:ew)
|
|
|
|
Tk.grid(rb1, :sticky=>:ew)
|
|
|
|
Tk.grid(rb2, :sticky=>:ew)
|
|
|
|
Tk.grid(rb3, :sticky=>:ew)
|
|
|
|
Tk.grid(btn, :sticky=>:ew, :padx=>2, :pady=>2)
|
|
|
|
Tk.grid(mb, :sticky=>:ew, :padx=>2, :pady=>2)
|
|
|
|
Tk.grid(e, :sticky=>:ew, :padx=>2, :pady=>2)
|
|
|
|
Tk.grid(ltext_f, :sticky=>:news)
|
|
|
|
|
|
|
|
TkGrid.columnconfigure(l, 0, :weight=>1)
|
|
|
|
TkGrid.rowconfigure(l, 7, :weight=>1) # text widget (grid is a PITA)
|
|
|
|
|
|
|
|
## Orig frame
|
|
|
|
cb = TkCheckbutton.new(r, :text=>'Checkbutton', :variable=>$V.ref(:SELECTED))
|
|
|
|
rb1 = TkRadiobutton.new(r, :text=>'One',
|
|
|
|
:variable=>$V.ref(:CHOICE), :value=>1)
|
|
|
|
rb2 = TkRadiobutton.new(r, :text=>'Two', :variable=>$V.ref(:CHOICE),
|
|
|
|
:value=>2, :underline=>1)
|
|
|
|
rb3 = TkRadiobutton.new(r, :text=>'Three',
|
|
|
|
:variable=>$V.ref(:CHOICE), :value=>3)
|
|
|
|
btn = TkButton.new(r, :text=>'Button')
|
|
|
|
|
|
|
|
mb = TkMenubutton.new(r, :text=>'Menubutton', :underline=>3, :takefocus=>true)
|
|
|
|
m = TkMenu.new(mb)
|
|
|
|
mb.menu(m)
|
|
|
|
$V[:rmbIndicatoron] = mb.indicatoron
|
|
|
|
m.add(:checkbutton, :label=>'Indicator?', #'
|
|
|
|
:variable=>$V.ref(:rmbIndicatoron),
|
2005-07-26 21:57:14 -04:00
|
|
|
:command=>proc{mb.indicatoron($V[:rmbIndicatoron])})
|
2005-04-09 05:27:54 -04:00
|
|
|
m.add(:separator)
|
|
|
|
fillMenu(m)
|
|
|
|
|
|
|
|
e = TkEntry.new(r, :textvariable=>$entryText)
|
|
|
|
|
|
|
|
rtext_f, rtext = scrolledWidget(r, TkText, false,
|
|
|
|
:width=>12, :height=>5, :wrap=>:none)
|
|
|
|
|
|
|
|
Tk.grid(cb, :sticky=>:ew)
|
|
|
|
Tk.grid(rb1, :sticky=>:ew)
|
|
|
|
Tk.grid(rb2, :sticky=>:ew)
|
|
|
|
Tk.grid(rb3, :sticky=>:ew)
|
|
|
|
Tk.grid(btn, :sticky=>:ew, :padx=>2, :pady=>2)
|
|
|
|
Tk.grid(mb, :sticky=>:ew, :padx=>2, :pady=>2)
|
|
|
|
Tk.grid(e, :sticky=>:ew, :padx=>2, :pady=>2)
|
|
|
|
Tk.grid(rtext_f, :sticky=>:news)
|
|
|
|
|
|
|
|
TkGrid.columnconfigure(l, 0, :weight=>1)
|
|
|
|
TkGrid.rowconfigure(l, 7, :weight=>1) # text widget (grid is a PITA)
|
|
|
|
|
|
|
|
Tk.grid(l, r, :sticky=>:news, :padx=>6, :pady=>6)
|
|
|
|
TkGrid.rowconfigure(client, 0, :weight=>1)
|
|
|
|
TkGrid.columnconfigure(client, [0, 1], :weight=>1)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add some text to the text boxes:
|
|
|
|
#
|
|
|
|
msgs = [
|
|
|
|
"The cat crept into the crypt, crapped and crept out again",
|
|
|
|
"Peter Piper picked a peck of pickled peppers",
|
|
|
|
"How much wood would a woodchuck chuck if a woodchuck could chuck wood",
|
|
|
|
"He thrusts his fists against the posts and still insists he sees the ghosts",
|
|
|
|
"Who put the bomb in the bom-b-bom-b-bom,",
|
|
|
|
"Is this your sister's sixth zither, sir?",
|
|
|
|
"Who put the ram in the ramalamadingdong?",
|
|
|
|
"I am not the pheasant plucker, I'm the pheasant plucker's mate."
|
|
|
|
]
|
|
|
|
|
|
|
|
nmsgs = msgs.size
|
|
|
|
(0...50).each{|n|
|
|
|
|
msg = msgs[n % nmsgs]
|
|
|
|
ltext.insert(:end, "#{n}: #{msg}\n")
|
|
|
|
rtext.insert(:end, "#{n}: #{msg}\n")
|
|
|
|
}
|
2005-08-04 00:16:27 -04:00
|
|
|
#
|
|
|
|
# Scales and sliders pane:
|
|
|
|
#
|
2005-08-04 00:48:13 -04:00
|
|
|
l = Tk::Tile::Labelframe.new(scales, :text=>'Themed', :padding=>6)
|
2005-08-04 00:16:27 -04:00
|
|
|
r = TkLabelframe.new(scales, :text=>'Standard', :padx=>6, :pady=>6)
|
|
|
|
|
|
|
|
if version?('0.6')
|
|
|
|
|
|
|
|
# thremed frame
|
2005-08-04 00:48:13 -04:00
|
|
|
scale = Tk::Tile::Scale.new(l, :orient=>:horizontal, :from=>0, :to=>100,
|
2005-08-04 00:16:27 -04:00
|
|
|
:variable=>$V.ref(:SCALE))
|
2005-08-04 00:48:13 -04:00
|
|
|
vscale = Tk::Tile::Scale.new(l, :orient=>:vertical, :from=>0, :to=>100,
|
2005-08-04 00:16:27 -04:00
|
|
|
:variable=>$V.ref(:VSCALE))
|
2005-08-04 00:48:13 -04:00
|
|
|
progress = Tk::Tile::Progressbar.new(l, :orient=>:horizontal, :maximum=>100)
|
|
|
|
vprogress = Tk::Tile::Progressbar.new(l, :orient=>:vertical, :maximum=>100)
|
2005-08-04 00:16:27 -04:00
|
|
|
|
|
|
|
if true
|
|
|
|
def progress.inverted(w, value)
|
2005-11-25 02:05:22 -05:00
|
|
|
if w.mode == 'indeterminate'
|
|
|
|
w.value(value)
|
|
|
|
else
|
|
|
|
w.value(w.maximum - value)
|
|
|
|
end
|
2005-08-04 00:16:27 -04:00
|
|
|
end
|
|
|
|
scale.command {|value| progress.value(value)}
|
|
|
|
vscale.command {|value| progress.inverted(vprogress, value) }
|
|
|
|
else
|
|
|
|
# This would also work, but the Tk scale widgets
|
|
|
|
# in the right hand pane cause some interference when
|
|
|
|
# in autoincrement/indeterminate mode.
|
|
|
|
#
|
|
|
|
progress.variable $V.ref(:SCALE)
|
|
|
|
vprogress.variable $V.ref(:VSCALE)
|
|
|
|
end
|
|
|
|
|
|
|
|
scale.set(50)
|
|
|
|
vscale.set(50)
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
lmode = Tk::Tile::Label.new(l, :text=>'Progress bar mode')
|
|
|
|
pbmode0 = Tk::Tile::Radiobutton.new(l, :variable=>$V.ref(:PBMODE),
|
2005-08-04 00:16:27 -04:00
|
|
|
:text=>'determinate', :value=>'determinate',
|
|
|
|
:command=>proc{pbMode(progress, vprogress)})
|
2005-08-04 00:48:13 -04:00
|
|
|
pbmode1 = Tk::Tile::Radiobutton.new(l, :variable=>$V.ref(:PBMODE),
|
2005-08-04 00:16:27 -04:00
|
|
|
:text=>'indeterminate', :value=>'indeterminate',
|
|
|
|
:command=>proc{pbMode(progress, vprogress)})
|
|
|
|
def pbMode(progress, vprogress)
|
2005-11-25 02:05:22 -05:00
|
|
|
if vprogress.mode != $V[:PBMODE]
|
|
|
|
vprogress.value(vprogress.maximum - vprogress.value)
|
|
|
|
end
|
|
|
|
|
2005-08-04 00:16:27 -04:00
|
|
|
progress.mode $V[:PBMODE]
|
|
|
|
vprogress.mode $V[:PBMODE]
|
|
|
|
end
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
start = Tk::Tile::Button.new(l, :text=>"Start",
|
2005-08-04 00:16:27 -04:00
|
|
|
:command=>proc{pbStart(progress, vprogress)})
|
|
|
|
def pbStart(progress, vprogress)
|
2005-11-25 02:05:22 -05:00
|
|
|
# $V[:PBMODE] = 'indeterminate'
|
|
|
|
pbMode(progress, vprogress)
|
2005-08-04 00:16:27 -04:00
|
|
|
progress.start 10
|
|
|
|
vprogress.start
|
|
|
|
end
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
stop = Tk::Tile::Button.new(l, :text=>'Stop',
|
2005-08-04 00:16:27 -04:00
|
|
|
:command=>proc{pbStop(progress, vprogress)})
|
|
|
|
def pbStop(progress, vprogress)
|
|
|
|
progress.stop
|
|
|
|
vprogress.stop
|
|
|
|
end
|
|
|
|
|
|
|
|
Tk.grid(scale, :columnspan=>2, :sticky=>'ew')
|
|
|
|
Tk.grid(progress, :columnspan=>2, :sticky=>'ew')
|
|
|
|
Tk.grid(vscale, vprogress, :sticky=>'nws')
|
|
|
|
|
|
|
|
Tk.grid(lmode, :sticky=>'we', :columnspan=>2)
|
|
|
|
Tk.grid(pbmode0, :sticky=>'we', :columnspan=>2)
|
|
|
|
Tk.grid(pbmode1, :sticky=>'we', :columnspan=>2)
|
|
|
|
Tk.grid(start, :sticky=>'we', :columnspan=>2)
|
|
|
|
Tk.grid(stop, :sticky=>'we', :columnspan=>2)
|
|
|
|
|
|
|
|
l.grid_columnconfigure(0, :weight=>1)
|
|
|
|
l.grid_columnconfigure(1, :weight=>1)
|
|
|
|
l.grid_rowconfigure(99, :weight=>1)
|
|
|
|
|
|
|
|
# standard frame
|
|
|
|
TkScale.new(r, :orient=>:horizontal, :from=>0, :to=>100,
|
|
|
|
:variable=>$V.ref(:SCALE)).grid(:sticky=>'news')
|
|
|
|
TkScale.new(r, :orient=>:vertical, :from=>0, :to=>100,
|
|
|
|
:variable=>$V.ref(:VSCALE)).grid(:sticky=>'nws')
|
|
|
|
|
|
|
|
r.grid_columnconfigure(0, :weight=>1)
|
|
|
|
r.grid_columnconfigure(1, :weight=>1)
|
|
|
|
r.grid_rowconfigure(99, :weight=>1)
|
|
|
|
|
|
|
|
else # tile 0.5 or earlier
|
|
|
|
|
|
|
|
# themed frame
|
2005-08-04 00:48:13 -04:00
|
|
|
scale = Tk::Tile::Scale.new(l, :variable=>$V.ref(:SCALE),
|
2005-08-04 00:16:27 -04:00
|
|
|
:orient=>:horizontal, :from=>0, :to=>100)
|
2005-08-04 00:48:13 -04:00
|
|
|
vscale = Tk::Tile::Scale.new(l, :variable=>$V.ref(:VSCALE),
|
2005-08-04 00:16:27 -04:00
|
|
|
:orient=>:vertical, :from=>-25, :to=>25)
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
progress = Tk::Tile::Progress.new(l,
|
2005-08-04 00:16:27 -04:00
|
|
|
:orient=>:horizontal, :from=>0, :to=>100)
|
2005-08-04 00:48:13 -04:00
|
|
|
vprogress = Tk::Tile::Progress.new(l,
|
2005-08-04 00:16:27 -04:00
|
|
|
:orient=>:vertical, :from=>-25, :to=>25)
|
|
|
|
|
|
|
|
if true
|
|
|
|
scale.command{|value| progress.set(value)}
|
|
|
|
vscale.command{|value| vprogress.set(value)}
|
|
|
|
else # this would also work. (via TkVariable#trace)
|
2005-08-05 23:44:00 -04:00
|
|
|
v1 = scale.variable
|
|
|
|
v2 = vscale.variable
|
2005-08-04 00:16:27 -04:00
|
|
|
v1.trace('w', proc{ progress.set(v1.value) })
|
|
|
|
v2.trace('w', proc{ vprogress.set(v2.value) })
|
|
|
|
end
|
|
|
|
|
|
|
|
Tk.grid(scale, :columnspan=>2, :sticky=>:ew)
|
|
|
|
Tk.grid(progress, :columnspan=>2, :sticky=>:ew)
|
|
|
|
Tk.grid(vscale, vprogress, :sticky=>:nws)
|
|
|
|
TkGrid.columnconfigure(l, 0, :weight=>1)
|
|
|
|
TkGrid.columnconfigure(l, 1, :weight=>1)
|
|
|
|
|
|
|
|
# standard frame
|
|
|
|
TkScale.new(r, :variable=>$V.ref(:SCALE),
|
|
|
|
:orient=>:horizontal, :from=>0, :to=>100).grid(:sticky=>'news')
|
|
|
|
TkScale.new(r, :variable=>$V.ref(:VSCALE),
|
|
|
|
:orient=>:vertical, :from=>-25, :to=>25).grid(:sticky=>'nws')
|
|
|
|
|
|
|
|
TkGrid.columnconfigure(r, 0, :weight=>1)
|
|
|
|
TkGrid.columnconfigure(r, 1, :weight=>1)
|
|
|
|
end
|
|
|
|
|
|
|
|
# layout frames
|
|
|
|
Tk.grid(l, r, :sticky=>'nwes', :padx=>6, :pady=>6)
|
|
|
|
scales.grid_columnconfigure(0, :weight=>1)
|
|
|
|
scales.grid_columnconfigure(1, :weight=>1)
|
|
|
|
scales.grid_rowconfigure(0, :weight=>1)
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Command box:
|
|
|
|
#
|
2005-08-04 00:48:13 -04:00
|
|
|
cmd = Tk::Tile::Frame.new($BASE)
|
|
|
|
b_close = Tk::Tile::Button.new(cmd, :text=>'Close',
|
2005-08-04 00:54:08 -04:00
|
|
|
:underline=>0, :default=>:normal,
|
|
|
|
:command=>proc{Tk.root.destroy})
|
2005-08-04 00:48:13 -04:00
|
|
|
b_help = Tk::Tile::Button.new(cmd, :text=>'Help', :underline=>0,
|
2005-08-04 00:54:08 -04:00
|
|
|
:default=>:normal, :command=>proc{showHelp()})
|
2005-04-09 05:27:54 -04:00
|
|
|
Tk.grid('x', b_close, b_help, :pady=>[6, 4], :padx=>4)
|
|
|
|
TkGrid.columnconfigure(cmd, 0, :weight=>1)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Set up accelerators:
|
|
|
|
#
|
|
|
|
$ROOT.bind('KeyPress-Escape', proc{Tk.event_generate(b_close, '<Invoke>')})
|
|
|
|
$ROOT.bind('<Help>', proc{Tk.event_generate(b_help, '<Invoke>')})
|
|
|
|
Tk::Tile::KeyNav.enableMnemonics($ROOT)
|
|
|
|
Tk::Tile::KeyNav.defaultButton(b_help)
|
|
|
|
|
|
|
|
Tk.grid($TOOLBARS[0], '-', :sticky=>:ew)
|
|
|
|
Tk.grid($TOOLBARS[1], '-', :sticky=>:ew)
|
|
|
|
Tk.grid(control, nb, :sticky=>:news)
|
|
|
|
Tk.grid(cmd, '-', :sticky=>:ew)
|
|
|
|
TkGrid.columnconfigure($ROOT, 1, :weight=>1)
|
|
|
|
TkGrid.rowconfigure($ROOT, 2, :weight=>1)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add a menu
|
|
|
|
#
|
|
|
|
menu = TkMenu.new($BASE)
|
|
|
|
$ROOT.menu(menu)
|
|
|
|
m_file = TkMenu.new(menu, :tearoff=>0)
|
|
|
|
menu.add(:cascade, :label=>'File', :underline=>0, :menu=>m_file)
|
|
|
|
m_file.add(:command, :label=>'Open', :underline=>0,
|
|
|
|
:compound=>:left, :image=>$ICON['open'])
|
|
|
|
m_file.add(:command, :label=>'Save', :underline=>0,
|
|
|
|
:compound=>:left, :image=>$ICON['save'])
|
|
|
|
m_file.add(:separator)
|
|
|
|
m_f_test = TkMenu.new(menu, :tearoff=>0)
|
|
|
|
m_file.add(:cascade, :label=>'Test submenu', :underline=>0, :menu=>m_f_test)
|
|
|
|
m_file.add(:checkbutton, :label=>'Text check', :underline=>5,
|
|
|
|
:variable=>$V.ref(:MENUCHECK1))
|
|
|
|
m_file.insert(:end, :separator)
|
|
|
|
|
|
|
|
if Tk.windowingsystem != 'x11'
|
2005-06-06 00:47:43 -04:00
|
|
|
TkConsole.create
|
2005-04-09 05:27:54 -04:00
|
|
|
m_file.insert(:end, :checkbutton, :label=>'Console', :underline=>5,
|
|
|
|
:variable=>$V.ref(:CONSOLE), :command=>proc{toggle_console()})
|
|
|
|
def toggle_console
|
|
|
|
if TkComm.bool($V[:CONSOLE])
|
|
|
|
TkConsole.show
|
|
|
|
else
|
|
|
|
TkConsole.hide
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
m_file.add(:command, :label=>'Exit', :underline=>1,
|
|
|
|
:command=>proc{Tk.event_generate(b_close, '<Invoke>')})
|
|
|
|
|
|
|
|
%w(One Two Three Four).each{|lbl|
|
|
|
|
m_f_test.add(:radiobutton, :label=>lbl, :variable=>$V.ref(:MENURADIO1))
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add Theme menu.
|
|
|
|
#
|
|
|
|
menu.add(:cascade, :label=>'Theme', :underline=>3,
|
|
|
|
:menu=>makeThemeMenu(menu))
|
|
|
|
|
|
|
|
setTheme($V[:THEME])
|
|
|
|
|
2005-08-01 02:35:15 -04:00
|
|
|
#
|
|
|
|
# Combobox demo pane:
|
|
|
|
#
|
|
|
|
values = %w(list abc def ghi jkl mno pqr stu vwx yz)
|
|
|
|
2.times {|i|
|
2005-08-04 00:48:13 -04:00
|
|
|
cb = Tk::Tile::Combobox.new(
|
2005-08-01 02:35:15 -04:00
|
|
|
combo, :values=>values, :textvariable=>$V.ref(:COMBO))
|
|
|
|
cb.pack(:side=>:top, :padx=>2, :pady=>2, :expand=>false, :fill=>:x)
|
|
|
|
if i == 1
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
cb.ttk_state :readonly
|
2005-08-01 02:35:15 -04:00
|
|
|
begin
|
|
|
|
cb.current = 3 # ignore if unsupported (tile0.4)
|
|
|
|
rescue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2005-08-01 06:25:51 -04:00
|
|
|
#
|
|
|
|
# Treeview widget demo pane:
|
|
|
|
#
|
2005-08-04 00:16:27 -04:00
|
|
|
if version?('0.5')
|
2005-08-01 06:25:51 -04:00
|
|
|
|
|
|
|
treeview = nil # avoid 'undefined' error
|
2005-08-04 00:48:13 -04:00
|
|
|
scrollbar = Tk::Tile::Scrollbar.new(tree,
|
2005-08-01 06:25:51 -04:00
|
|
|
:command=>proc{|*args| treeview.yview(*args)})
|
|
|
|
treeview = Tk::Tile::Treeview.new(tree, :columns=>%w(Class), :padding=>4,
|
|
|
|
:yscrollcommand=>proc{|*args| scrollbar.set(*args)})
|
|
|
|
|
|
|
|
Tk.grid(treeview, scrollbar, :sticky=>'news')
|
|
|
|
tree.grid_columnconfigure(0, :weight=>1)
|
|
|
|
tree.grid_rowconfigure(0, :weight=>1)
|
|
|
|
tree.grid_propagate(0)
|
|
|
|
|
|
|
|
# Add initial tree node:
|
|
|
|
# Later nodes will be added in <<TreeviewOpen>> binding.
|
|
|
|
treeview.insert('', 0, :id=>'.', :text=>'Main Window', :open=>false,
|
|
|
|
:values=>[TkWinfo.classname('.')])
|
2005-08-02 17:05:17 -04:00
|
|
|
treeview.headingconfigure('#0', :text=>'Widget')
|
|
|
|
treeview.headingconfigure('Class', :text=>'Class')
|
2005-08-01 06:25:51 -04:00
|
|
|
treeview.bind('<TreeviewOpen>', proc{fillTree(treeview)})
|
|
|
|
|
|
|
|
def fillTree(treeview)
|
|
|
|
id = treeview.focus_item
|
|
|
|
unless TkWinfo.exist?(id)
|
|
|
|
treeview.delete(id)
|
|
|
|
end
|
|
|
|
# Replace tree item children with current list of child windows.
|
|
|
|
treeview.delete(treeview.children(id))
|
|
|
|
for child in TkWinfo.children(id)
|
|
|
|
treeview.insert(id, :end, :id=>child, :text=>TkWinfo.appname(child),
|
|
|
|
:open=>false, :values=>[TkWinfo.classname(child)])
|
|
|
|
unless TkWinfo.children(child).empty?
|
|
|
|
# insert dummy child to show [+] indicator
|
|
|
|
treeview.insert(child, :end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
2005-08-04 00:48:13 -04:00
|
|
|
Tk::Tile::Label.new(tree,
|
2005-08-01 06:25:51 -04:00
|
|
|
:text=>'Treeview is supported on tile 0.5 or later...').pack
|
|
|
|
end
|
|
|
|
|
2005-04-09 05:27:54 -04:00
|
|
|
#
|
|
|
|
# Other demos:
|
|
|
|
#
|
|
|
|
$Timers = {:StateMonitor=>nil, :FocusMonitor=>nil}
|
|
|
|
|
2005-12-11 09:59:49 -05:00
|
|
|
begin
|
|
|
|
msg = Tk::Tile::Label.new(others, :justify=>:left, :wraplength=>300)
|
|
|
|
rescue
|
|
|
|
msg = TkMessage.new(others, :aspect=>200)
|
|
|
|
end
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
$Desc = {}
|
|
|
|
|
|
|
|
showDescription = TkBindTag.new
|
|
|
|
showDescription.bind('Enter', proc{|w| msg.text($Desc[w.path])}, '%W')
|
|
|
|
showDescription.bind('Leave', proc{|w| msg.text('')}, '%W')
|
|
|
|
|
|
|
|
[
|
|
|
|
[ :trackStates, "Widget states...",
|
|
|
|
"Display/modify widget state bits" ],
|
|
|
|
|
|
|
|
[ :scrollbarResizeDemo, "Scrollbar resize behavior...",
|
|
|
|
"Shows how Tile and standard scrollbars differ when they're sized too large" ],
|
|
|
|
|
|
|
|
[ :trackFocus, "Track keyboard focus..." ,
|
2005-08-02 02:51:26 -04:00
|
|
|
"Display the name of the widget that currently has focus" ],
|
|
|
|
|
|
|
|
[ :repeatDemo, "Repeating buttons...",
|
|
|
|
"Demonstrates custom classes (see demos/repeater.tcl)" ]
|
|
|
|
|
2005-04-09 05:27:54 -04:00
|
|
|
].each{|demo_cmd, label, description|
|
2005-08-04 00:48:13 -04:00
|
|
|
b = Tk::Tile::Button.new(others, :text=>label,
|
2005-08-04 00:54:08 -04:00
|
|
|
:command=>proc{ self.__send__(demo_cmd) })
|
2005-04-09 05:27:54 -04:00
|
|
|
$Desc[b.path] = description
|
|
|
|
b.bindtags <<= showDescription
|
|
|
|
|
|
|
|
b.pack(:side=>:top, :expand=>false, :fill=>:x, :padx=>6, :pady=>6)
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.pack(:side=>:bottom, :expand=>true, :fill=>:both)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Scrollbar resize demo:
|
|
|
|
#
|
|
|
|
$scrollbars = nil
|
|
|
|
|
|
|
|
def scrollbarResizeDemo
|
|
|
|
if $scrollbars
|
|
|
|
begin
|
|
|
|
$scrollbars.destroy
|
|
|
|
rescue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
$scrollbars = TkToplevel.new(:title=>'Scrollbars', :geometry=>'200x200')
|
|
|
|
f = TkFrame.new($scrollbars, :height=>200)
|
2005-08-04 00:48:13 -04:00
|
|
|
tsb = Tk::Tile::Scrollbar.new(f, :command=>proc{|*args| sbstub(tsb, *args)})
|
2005-04-09 05:27:54 -04:00
|
|
|
sb = TkScrollbar.new(f, :command=>proc{|*args| sbstub(sb, *args)})
|
|
|
|
Tk.grid(tsb, sb, :sticky=>:news)
|
|
|
|
|
|
|
|
sb.set(0, 0.5) # prevent backwards-compatibility mode for old SB
|
|
|
|
|
|
|
|
f.grid_columnconfigure(0, :weight=>1)
|
|
|
|
f.grid_columnconfigure(1, :weight=>1)
|
|
|
|
f.grid_rowconfigure(0, :weight=>1)
|
|
|
|
|
|
|
|
f.pack(:expand=>true, :fill=>:both)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Track focus demo:
|
|
|
|
#
|
|
|
|
$FocusInf = TkVariable.new_hash
|
|
|
|
$focus = nil
|
|
|
|
|
|
|
|
def trackFocus
|
|
|
|
if $focus
|
|
|
|
begin
|
|
|
|
$focus.destroy
|
|
|
|
rescue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
$focus = TkToplevel.new(:title=>'Keyboard focus')
|
|
|
|
i = 0
|
|
|
|
[
|
|
|
|
["Focus widget:", :Widget],
|
|
|
|
["Class:", :WidgetClass],
|
|
|
|
["Next:", :WidgetNext],
|
|
|
|
["Grab:", :Grab],
|
|
|
|
["Status:", :GrabStatus]
|
|
|
|
].each{|label, var_index|
|
2005-08-04 00:48:13 -04:00
|
|
|
Tk.grid(Tk::Tile::Label.new($focus, :text=>label, :anchor=>:e),
|
|
|
|
Tk::Tile::Label.new($focus,
|
2005-08-04 00:54:08 -04:00
|
|
|
:textvariable=>$FocusInf.ref(var_index),
|
|
|
|
:width=>40, :anchor=>:w, :relief=>:groove),
|
2005-04-09 05:27:54 -04:00
|
|
|
:sticky=>:ew)
|
|
|
|
i += 1
|
|
|
|
}
|
|
|
|
$focus.grid_columnconfigure(1, :weight=>1)
|
|
|
|
$focus.grid_rowconfigure(i, :weight=>1)
|
|
|
|
|
|
|
|
$focus.bind('Destroy', proc{Tk.after_cancel($Timers[:FocusMonitor])})
|
|
|
|
focusMonitor
|
|
|
|
end
|
|
|
|
|
|
|
|
def focusMonitor
|
|
|
|
$FocusInf[:Widget] = focus_win = Tk.focus
|
|
|
|
if focus_win
|
|
|
|
$FocusInf[:WidgetClass] = focus_win.winfo_classname
|
|
|
|
$FocusInf[:WidgetNext] = Tk.focus_next(focus_win)
|
|
|
|
else
|
|
|
|
$FocusInf[:WidgetClass] = $FocusInf[:WidgetNext] = ''
|
|
|
|
end
|
|
|
|
|
|
|
|
$FocusInf[:Grab] = grab_wins = Tk.current_grabs
|
|
|
|
unless grab_wins.empty?
|
|
|
|
$FocusInf[:GrabStatus] = grab_wins[0].grab_status
|
|
|
|
else
|
|
|
|
$FocusInf[:GrabStatus] = ''
|
|
|
|
end
|
|
|
|
|
|
|
|
$Timers[:FocusMonitor] = Tk.after(200, proc{ focusMonitor() })
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Widget state demo:
|
|
|
|
#
|
|
|
|
$Widget = TkVariable.new
|
|
|
|
|
|
|
|
TkBindTag::ALL.bind('Control-Shift-ButtonPress-1',
|
|
|
|
proc{|w|
|
|
|
|
$Widget.value = w
|
|
|
|
updateStates()
|
|
|
|
Tk.callback_break
|
|
|
|
}, '%W')
|
|
|
|
$states_list = %w(active disabled focus pressed selected
|
|
|
|
background indeterminate invalid default)
|
|
|
|
$states_btns = {}
|
|
|
|
$states = nil
|
|
|
|
|
|
|
|
$State = TkVariable.new_hash
|
|
|
|
|
|
|
|
def trackStates
|
|
|
|
if $states
|
|
|
|
begin
|
|
|
|
$state.destroy
|
|
|
|
rescue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
$states = TkToplevel.new(:title=>'Widget states')
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
l_inf = Tk::Tile::Label.new($states, :text=>"Press Control-Shift-Button-1 on any widget")
|
2005-04-09 05:27:54 -04:00
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
l_lw = Tk::Tile::Label.new($states, :text=>'Widget:',
|
2005-08-04 00:54:08 -04:00
|
|
|
:anchor=>:e, :relief=>:groove)
|
2005-08-04 00:48:13 -04:00
|
|
|
l_w = Tk::Tile::Label.new($states, :textvariable=>$Widget,
|
2005-08-04 00:54:08 -04:00
|
|
|
:anchor=>:w, :relief=>:groove)
|
2005-04-09 05:27:54 -04:00
|
|
|
|
|
|
|
Tk.grid(l_inf, '-', :sticky=>:ew, :padx=>6, :pady=>6)
|
|
|
|
Tk.grid(l_lw, l_w, :sticky=>:ew)
|
|
|
|
|
|
|
|
$states_list.each{|st|
|
2005-08-04 00:48:13 -04:00
|
|
|
cb = Tk::Tile::Checkbutton.new($states, :text=>st,
|
2005-08-04 00:54:08 -04:00
|
|
|
:variable=>$State.ref(st),
|
|
|
|
:command=>proc{ changeState(st) })
|
2005-04-09 05:27:54 -04:00
|
|
|
$states_btns[st] = cb
|
|
|
|
Tk.grid('x', cb, :sticky=>:nsew)
|
|
|
|
}
|
|
|
|
|
|
|
|
$states.grid_columnconfigure(1, :weight=>1)
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
f_cmd = Tk::Tile::Frame.new($states)
|
2005-04-09 05:27:54 -04:00
|
|
|
Tk.grid('x', f_cmd, :sticky=>:nse)
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
b_close = Tk::Tile::Button.new(f_cmd, :text=>'Close',
|
2005-08-04 00:54:08 -04:00
|
|
|
:command=>proc{ $states.destroy })
|
2005-04-09 05:27:54 -04:00
|
|
|
Tk.grid('x', b_close, :padx=>4, :pady=>[6,4])
|
|
|
|
f_cmd.grid_columnconfigure(0, :weight=>1)
|
|
|
|
|
|
|
|
$states.bind('KeyPress-Escape', proc{Tk.event_generate(b_close, '<Invoke>')})
|
|
|
|
|
|
|
|
$states.bind('Destroy', proc{Tk.after_cancel($Timers[:StateMonitor])})
|
|
|
|
stateMonitor()
|
|
|
|
end
|
|
|
|
|
|
|
|
def stateMonitor
|
|
|
|
updateStates() if $Widget.value != ''
|
|
|
|
$Timers[:StateMonitor] = Tk.after(200, proc{ stateMonitor() })
|
|
|
|
end
|
|
|
|
|
|
|
|
def updateStates
|
|
|
|
$states_list.each{|st|
|
|
|
|
begin
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
$State[st] = $Widget.window.ttk_instate(st)
|
2005-04-09 05:27:54 -04:00
|
|
|
rescue
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
$states_btns[st].ttk_state('disabled')
|
2005-04-09 05:27:54 -04:00
|
|
|
else
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
$states_btns[st].ttk_state('!disabled')
|
2005-04-09 05:27:54 -04:00
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def changeState(st)
|
|
|
|
if $Widget.value != ''
|
|
|
|
if $State.bool_element(st)
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
$Widget.window.ttk_state(st)
|
2005-04-09 05:27:54 -04:00
|
|
|
else
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
$Widget.window.ttk_state("!#{st}")
|
2005-04-09 05:27:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-08-02 02:51:26 -04:00
|
|
|
#
|
|
|
|
# Repeating buttons demo:
|
|
|
|
#
|
|
|
|
def repeatDemo
|
|
|
|
if defined?($repeatDemo) && $repeatDemo.exist?
|
|
|
|
$repeatDemo.deiconify; return
|
|
|
|
end
|
|
|
|
$repeatDemo = TkToplevel.new(:title=>'Repeating button')
|
|
|
|
|
2005-08-04 00:48:13 -04:00
|
|
|
f = Tk::Tile::Frame.new($repeatDemo)
|
|
|
|
b = Tk::Tile::Button.new(f, :class=>'Repeater', :text=>'Press and hold')
|
2005-08-04 00:16:27 -04:00
|
|
|
if version?('0.6')
|
2005-08-04 00:48:13 -04:00
|
|
|
p = Tk::Tile::Progressbar.new(f, :orient=>:horizontal, :maximum=>10)
|
2005-08-04 00:16:27 -04:00
|
|
|
else # progressbar is not supported
|
2005-08-04 00:48:13 -04:00
|
|
|
p = Tk::Tile::Progress.new(f, :orient=>:horizontal, :from=>0, :to=>10)
|
2005-08-02 02:51:26 -04:00
|
|
|
def p.step
|
2005-08-02 07:49:46 -04:00
|
|
|
i = self.get + 1
|
|
|
|
i = self.from if i > self.to
|
|
|
|
self.set(i)
|
2005-08-02 02:51:26 -04:00
|
|
|
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
|
|
|
|
|
2005-04-09 05:27:54 -04:00
|
|
|
Tk.mainloop
|