This document has been translated from Koji Arai's draft Ruby/Tk document
(available at http://ns103.net/~arai/ruby/rubytk-20011201.html.gz)
Nagai Hidetoshi's notes on the original footnotes have been included in italics.
The translation has the following regrettable features:
* No attempt was made to fix problems or ambiguities in the original, even
obvious ones -- remember the original is a draft.
* The translation has introduced an unknown but large number of problems and
ambiguities of its own.
* Nothing was added or clarified -- all footnotes and comments are from the
original.
* No attempt was made to use consistent terms, even when the original did.
* No proofreading was done.
* Jankenpon was used to resolve all doubtful or difficult bits.
That said, enjoy!
Benjamin Peterson (http://www.jbrowse.com)
This is a class for using Tcl/Tk directly.
In Ruby/Tk programming, there is no need to be aware of the existence of this class. For details, see ext/tcltklib/MANUAL.euc
TkCore::INTERP is an instance of this class.
TclTkIp.new
Creates a Tcl/Tk interpreter object.
TclTkIp#_eval(str)
Executes the arbitrary Tcl/Tk script given in str. Returns the result.
TclTkIp#_invoke(cmd,
*args)
Executes the arbitrary Tcl/Tk command cmd, passing args as arguments. Returns the result.
TclTkIp#_return_value
Returns 0 if the last call to TclTkIp#_invoke or TclTkIp#_eval executed correctly.
TclTkIp#mainloop
Executes the Tcl/Tk main loop. Same as TclTkLib.mainloop *1
TclTkIp#_toUTF8(str,
encodename)
TclTkIp#_fromUTF8(str,
encodename)
The superclass of TkObject. The subclass redefines the class method new to take a block.
TkKernel.new {|obj| ...}
Instantiates the TkKernel object.
If a block is given, the created object will run it as an argument. The context within the block will be such that 'self' is the created object.
In short,
TkKernel.new {|obj| ... }
is equivalent to
object = TkKernel.new
object.instance_eval {|obj| ... }
.
TkKernel.new redefines Class#new, so this property is also seen in subclasses of TkKernel.
The superclass of all widgets and ofTkCanvas and TkText.
The subclasses of TkObject contain the following kinds of method:
Pure Ruby methods
Widget commands
Options
Options wrapped with Ruby
There is normally no reason to be aware of this distinction in Ruby/Tk programming, but depending on implementation such a case may arise. TkObject#method_missing, TkComposite
You can see the options for a given class at a glance with the following method:
require "tk"
puts TkLabel.new.configinfo.collect {|name,| name}
TkObject#tk_send(cmd、*rest)
Execute cmd on 'self', passing rest as parameters. An implementation of a WidgetCommand.
TkObject#tk_trace_variable(v)
This method simply takes argument v but if v is not a TkVariable object then an ArgumentError exception will be raised. There is an internal type check.
TkObject#path
Returns the path of the window. The WidgetCommand's result is applied to this path.
TkObject#epath
Returns the path of the window. The widget arranger TkWindow#pack is applied to this path.
The distinction between path and epath is for the sake of implementing TkComposite.
*2
TkObject#to_eval
Returns the representation of self in the Tcl/Tk interpreter. This method is overridden in each object to return:
The widget class
Each widget class
Widget
Widget Path
TkVariable
Tcl Variable Name
and more. This method communicates internally with the Tcl/Tk interpreter.
(In this manual, the descriptions of particular to_eval implementations are omitted.)
TkObject#[slot]
TkObject#cget(slot)
Returns the value of Optionsslot.
TkObject#[slot] =
value
TkObject#configure(slot,
value=None)
TkObject#configure(hash)
Sets the value of Optionsslot to value.
require "tk"
TkLabel.new {
configure('text', "foobar")
configure('foreground', "red")
pack
}
Tk.mainloop
When a hash is passed in, the option that corresponds to each key is set to the given value.
require "tk"
TkLabel.new {
configure('text' => "foobar", 'foreground' => "red")
pack
}
Tk.mainloop
TkObject#configure_cmd(slot,
value)
TkObject#configinfo(slot =
nil)
For Optionsslot, returns an array containing each of the 5 elements below:
[Option name, parameter name, class name, default value, actual value]
'Parameter name' is a name which, when set in the Option Database(TkOption), is the same as the option name. 'Class name' here is a name that shows the kind of value (nothing to do with a Ruby class).*4
require "tk"
p TkButton.new.configinfo("foreground")
=> ["foreground", "foreground", "Foreground", "Black", "Black"]
When the argument is omitted, an array of arrays is returned containing the above info for each option.
TkObject#event_generate(context,
keys=nil)
Generates event context.
By passing a string known as a "virtual event name" to specify a TkVirtualEvent instance, it is possible to raise a Virtual Event.
For details, please refer to TkCore#event_generate.
TkObject#destroy
If a trace variable is defined, cancels that trace.*5
TkObject#method_missing(id,
*args)
Executed when an undefined method is called. (See Object#method_missing)
For the purposes of this method, widget options are treated as methods. The variable id is the id of the called method (or option) and the number of args will be 0 or 1.
When there is 1 argument,
configure id.id2name, args[0]
is run. In other words the method creates Options. In this case, the empty string will be returned.
When there are 0 arguments,
cget id.id2name
is run. In other words, the method refers to Options and returns the value of an option.
Note
In a method implemented by method_missing, you cannot make a call from a subclass using
super. Diligence is thus required when inheriting new widget classes from the subclasses of TkObject.
require "tk"
class TkButton2 < TkButton
def text(val = nil) # redefine option text
if val
super "<#{val}>" # can't call 'text' on TkButton
else
super() # can't call 'text' on TkButton
end
end
end
TkButton2.new {
p text "a"
p text
}
((*error-->*)) -:6:in `text': super: no superclass method `text' (NameError)
Read and set options in the way shown below:
require "tk"
class TkButton2 < TkButton
def text(val = nil)
if val
configure "text", "<#{val}>" # method_missing :text, val
else
cget "text" # method_missing :text
end
end
end
TkButton2.new {
p text "a"
p text
}
=> ""
"<a>"
Below are the standard Tcl/Tk options at a glance, divided by category. However, not all widgets necessarily support all options.
In the explanations below, only the action taken when 1 argument is supplied is given; however, in all cases if 0 arguments are supplied than the existing value is read. TkObject#method_missing
TkObject#activebackground
Sets the background color for when the widget is Active.
require "tk" TkButton.new.pack.activebackground "black" Tk.mainloop
TkObject#activeborderwidth
Sets the border color for when the widget is Active.
TkObject#activeforeground
Sets the foreground color for when the widget is Active.
require "tk"
TkButton.new { text "button" }.pack.activeforeground "red"
Tk.mainloop
TkObject#anchor
Specifies where in the widget text and bitmaps will be positioned. Acceptable values are those below:
"center"
"e"
"s"
"w"
"n"
"ne"
"nw"
"se"
"sw"
require "tk"
TkLabel.new {
text "label"
bg "white"
width 5
height 3
anchor "ne"
}.pack
Tk.mainloop
TkObject#background
TkObject#bg
Usual background color for the widget.
TkObject#bitmap
Specifies a bitmap. Recently, TkObject#image has been used instead.
TkObject#borderwidth
TkObject#bd
Usual border color for the widget.
TkObject#cursor
Specifies the mouse cursor shape to use.*6
TkObject#disabledforeground
The color to use when the widget is Disabled.
require "tk"
TkButton.new {text "normal"; state text}.pack "fill" => "x"
TkButton.new {text "active"; state text}.pack "fill" => "x"
TkButton.new {text "disabled"; state text}.pack "fill" => "x"
Tk.mainloop
TkObject#exportselection
Specifies, as a boolean, whether the application can share its Selection with other applications. Default is true)。
TkObject#font
Sets text font.*7
TkObject#foreground
TkObject#fg
Sets text (and other foreground) color.
TkObject#highlightbackground
When the widget does not have the Input focus, the color of the frame around the widget.
require "tk"
TkButton.new {highlightbackground "red"; highlightcolor "blue"}.
pack("padx"=>10,"pady"=>10).focus
TkButton.new {highlightbackground "red"; highlightcolor "blue"}.
pack("padx"=>10,"pady"=>10)
Tk.mainloop
TkObject#highlightcolor
When the widget does have the Input focus, the color of the frame around the widget.
TkObject#highlightthickness
When the widget does have the Input focus, the thickness of the frame.
require "tk"
TkButton.new {
highlightbackground "red"
highlightcolor "blue"
highlightthickness 10
}.pack("padx"=>10,"pady"=>10).focus
TkButton.new {
highlightbackground "red"
highlightcolor "blue"
highlightthickness 10
}.pack("padx"=>10,"pady"=>10)
Tk.mainloop
TkObject#image
Sets the TkImage.
TkObject#insertbackground
Color of the input cursor.
require "tk"
TkEntry.new {
insertbackground "red"
insertwidth 50
insertborderwidth 10
insert 0, "foobar"
}.pack.focus
Tk.mainloop
TkObject#insertborderwidth
Specifies the width of the input cursor border. Because the cursor width (set in TkObject#insertwidth) is included, the border width cannot be greater than the cursor width.
TkObject#insertofftime
Together with TkObject#insertontime, sets the cursor's blink speed. This value is the time to spend 'off' in milliseconds.
TkObject#insertontime
Together with TkObject#insertofftime, sets the cursor's blink speed. This value is the time to spend 'on' in milliseconds.
TkObject#insertwidth
Sets the width of the input cursor.TkObject#insertborderwidth
TkObject#jump
A boolean that specifies the behavior of the scrollbar, TkScrollbar. When true, the command associated with the scrollbar is executed every time it moves. When false, the command is executed only when the scroll bar is released.
In the example below, a scroll bar with this value set to true and one with this value set to false control a text input widget (TkEntry) together.
require "tk"
s1 = s2 = nil
e = TkEntry.new {
xscrollcommand {|arg| s1.set *arg; s2.set *arg}
insert 0, ("a".."z").to_a.join * 3
}.pack "fill"=>"x"
s1 = TkScrollbar.new {
jump true
orient "h"
command {|arg| e.xview *arg }
}.pack "fill"=>"x"
s2 = TkScrollbar.new {
jump false
orient "h"
command {|arg| e.xview *arg }
}.pack "fill"=>"x"
Tk.mainloop
TkObject#justify
Specifies the text justifying method. Acceptable values are as follows:
"center"
"left"
"right"
TkObject#orient
Specifies whether a widget's orientation should be "horizontal" or "vertical"
Acceptable values are obvious (they may be abbreviated but that hardly matters).
TkObject#padx
Specifies the horizontal blank space around a widget (Not the same as TkPack.configure's "padx". Annoyingly, also different from "ipadx".)
require "tk"
TkButton.new { text "a"; padx 10; pady 10 }.pack
TkButton.new { text "b" }.pack("ipadx"=>10, "ipady"=>10)
TkButton.new { text "c" }.pack( "padx"=>10, "pady"=>10)
Tk.mainloop
TkObject#pady
Specifies the vertical blank space around a widget (Not the same as TkPack.configure's "pady". Annoyingly, also different from "ipady".)
TkObject#relief
Sets the widget's form to one of the values below:
"raised"
"sunken"
"flat"
"ridge"
"solid"
"groove"
To see the effect of each form, refer to the example below:
require "tk"
%w(raised sunken flat ridge solid groove).each {|shape|
TkLabel.new { bd 5; text shape; relief shape}.pack
}
Tk.mainloop
TkObject#repeatdelay
After a key or button is pressed, the time in milliseconds before autorepeat starts.
TkObject#repeatinterval
Autorepeat rate in milliseconds.
TkObject#selectbackground
Set the background color of the selected area.
TkObject#selectborderwidth
TkObject#selectforeground
Set the foreground color of the selected area.
TkObject#setgrid
A boolean specifying whether to resize the widget in grid units.
TkObject#takefocus
Set whether or not the widget hasInput focus.
TkObject#text
Specifies the text to be shown within the widget, as a string.
###--- TkObject#textvariable
TkObject#troughcolor
Sets the color for concavities.
require "tk"
TkScale.new {
orient "h"
troughcolor "red"
pack "fill"=>"x"
}
TkScrollbar.new {
orient "h"
troughcolor "red"
pack "fill"=>"x"
}
Tk.mainloop
TkObject#underline
Specifies where the text is underlined. This can be used to specify a shortcut key.
require "tk"
TkLabel.new { text "fooBar"; underline 3 }.pack
Tk.mainloop
TkObject#wraplength
For text wrapping, specifies the length of a line. If 0, text cannot be wrapped.
require "tk"
TkLabel.new { text "foobar"; wraplength 20; p wraplength}.pack
Tk.mainloop
###--- TkObject#xscrollcommand
###--- TkObject#yscrollcommand
This is the superclass of all widgets.
TkWindow.new(parent=nil,
keys=nil)
TkWindow.new(parent=nil,
keys=nil) {|win| ... }
The parent widget will be the widget passed in parent. If parentis omitted, the root widget TkRoot will be the parent.
keys is a hash that specifies the Options . Because the options settable in keys are implemented as methods, both
TkLabel.new(nil, "text"=>"foo").pack
and
label = TkLabel.new label.text "foo" label.pack
can be written (pack is not an option).
If a block is given, the created widget will execute the block as an argument. The context within the block will be such that 'self' is the created object.
The example above can also be written thus:
TkLabel.new {
text "foo"
pack
}
If a block is used, the parent-child relationship can be clearly expressed visually as below:
require "tk"
TkFrame.new {
TkLabel.new(self) {
text "foo"
}.pack
}.pack
Tk.mainloop
However, since self may change within the block, there is the possibility that the names of instance methods, of Ruby's functions and of local variables
may collide. Depending on the actual content, it is also necessary to be careful about legibility.
require "tk"
text = "foo"
p text # <- This is of course a local variable
TkLabel.new {
text "bar"
p text # <- This is a local variable
p self.text # <- This is TkLabel#text
raise # <- TkWindow#raise called with no exception
}.pack
Tk.mainloop
TkWindow#create_self
Creates a widget at the Tcl/Tk level. Called from
TkWindow#initialize for initialization.
TkWindow subclasses must override this method to create the relevant widget. In this manual, descriptions of the individual subclasses' create_self methods are omitted.
Usually called in the format
tk_call 'Tcl/Tk command', path
TkWindow#pack(keys=nil)
Packs widgets. The packed widgets are arranged according to the behavior specified in
keys(a {name=>value...} hash). Returns self.
Tk.pack self, keys
is the same as
TkPack.configure self, keys
See TkPack.
TkWindow#unpack
Releases a widget arranged with 'pack' (so they are no longer visible). Returns self.
TkWindow#grid(keys=nil)
Arranges widgets at the intersections of the grid specified in keys. Returns self.
Tk.grid self, keys
is the same as
TkGrid.configure self, keys
See TkGrid.
TkWindow#ungrid
Releases a widget arranged with 'grid' (so they are no longer visible). Returns self.
TkWindow#place(keys=nil)
Places the widget at the location given in keys. Returns self.
keys is a hash containing the following keys:
"in"
"x"
"relx"
"y"
"rely"
"anchor"
"width"
"relwidth"
"height"
"relheight"
"bordermode"
TkWindow#unplace
TkWindow#place_forget
Releases a widget arranged with 'place' (so they are no longer visible). Returns self.
TkWindow#place_config(keys)
Repositions a widget arranged with 'place' according to the values specified in keys.*9
TkWindow#place_info
Returns the position information of a widget positioned with 'place' as a hash.
TkWindow#pack_slaves
Returns an array of all the widgets packed within the self widget.
TkWindow#pack_info
Returns the position information of a widget positioned with 'pack' as a hash.
TkWindow#place_slaves
Returns an array of all the widgets arranged with 'place' within the self widget.
TkWindow#focus(force =
false)
Sets Input focus to self. If forceis true, then the focus will be obtained even if another application has it. Returns self.
TkWindow#grab(arg =
nil)
Performs grab-related operations on the widget. When the widget is grabbed, events are not raised with other widgets.
No arguments
Grabs the 'self' widget. Returns an empty string.
"global"
Events are not raised even with other applications.
"current"
Returns the currently grabbed widget.
"status"
Returns the grab status.
"release"
Release the grab. Returns (({nil})).
TkWindow#lower(below=None)
Puts the widget below the below widget. When below is omitted, the widget is put at the bottom.
Returns self.
TkWindow#raise(above=None)
Puts the widget above the above widget. When above is omitted, the widget is put at the top.
Returns self.
Note
In a context where 'self' is an instance of TkWindow,Kernel#raise cannot be used to raise an exception. In Ruby/Tk programming, it is safer to useKernel#fail to raise an exception.
TkWindow#command(cmd=Proc.new)
Register the Proc object given in the argument as a command.
TkButton.new {
text "button"
command { puts "button" }
pack
}
Tk.mainloop
TkWindow#colormodel(model=None)
(This method cannot be used in Tk versions greater than X.X)*10
Specify whether the Ruby/Tk widget's color model should be color or black and white. Without arguments, returns the widget's color model.
Acceptable values for model are as follows:
"color"
"monochrome"
Returns self.
TkWindow#destroy
Totally destroys the widget.
TkWindow#wait
TkWindow#wait_visibility
Waits for the widget's visibility to change.
TkWindow#wait_destroy
Waits until TkWindow#destroy destroys the widget.
TkWindow#bindtags(taglist=nil)
Specifies the self widget's Taglist as taglist. The taglist is an array showing the propagation of events. It's elements are:
Widget objects
Widget classes
TkBindTag objects
The string "all"
. When the self widget raises an event, each element in the list is found in order, and the appropriate
Event Callback Functions are all executed.
Without arguments, return's the widget's taglist.
By default, the taglist consists of:
The widget itself (self)
The widget's class
The TkRoot widget (or TkToplevel widget)
The "all" tag
require "tk"
b1 = TkButton.new
p b1.bindtags
TkToplevel.new {
TkButton.new(self) {
p bindtags
}
}
=> [#<TkButton: @path=".w0000">, TkButton, #<TkRoot: @path=".">, "all"]
[#<TkButton: @path=".w0002.w0003">, TkButton, \
#<TkToplevel: @screen=nil, @path=".w0002", @classname=nil>, "all"]
The following is an example of the definition of a taglist:
require "tk" b1 = TkButton.new.pack b1.bindtags [b1, Tk.root, "all"] p b1.bindtags Tk.mainloop => [#<TkButton: @path=".w0000">, #<TkRoot: @path=".">, "all"]
If the widget class is omitted from the list in this way, then a button will not take on the 'pressed' state even if right-clicked. This is because the Event callback function for this action is registered on the button widget class.
By default, in the "all" tag,
require "tk" p Tk.bindinfo "all" => ["Shift-Key-Tab", "Key-Tab", "Key-F10", "Alt-Key"]
actions for the above key events are defined. Accordingly, it is clear that if the "all" tag is not removed from the tag list, actions for these key presses will be defined on all widgets.
Note
Strings can also be specified as elements in the tag list. However, the 'all' widget path and widget class name are handled specially.
If a widget's path name is given in a tag, the effect is the same as if the widget itself were given. In the same way, giving the widget class name (in the case of TkButton, "Button")
is the same as giving the widget class. When specifying tags as strings, care must be taken to avoid name collisions. (In ruby-1.4.4, in tk.rb the class TkBindTag was provided for defining unique tags.)
require "tk"
newtag = TkBindTag.new
TkButton.new {
bindtags [path, "Button", newtag]
p bindtags
}
=> [#<TkButton: @path=".w0000">, TkButton, #<TkBindTag: btag00000>]
This class represents the root widget. The root widget is at the top of the Ruby/Tk widget hierarchy
TkRoot.new
Instantiates the root widget object. Always returns the same object. (Only 1 root widget can exist at once in Ruby/Tk)
TkRoot#path
Returns the root widget's path, which must be "." and nothing else.
TkObject#borderwidth TkObject#bd
TkRoot#background(color)
TkRoot#bg(color)
### --- TkRoot#class ### --- TkRoot#classname
TkRoot#colormap
TkRoot#container(bool)
TkRoot#height
TkRoot#menu
TkRoot#screen
TkRoot#use
TkRoot#visual
TkRoot#width
TkToplevel.new(parent=nil,
keys=nil)
TkToplevel.new(parent=nil,
screen=nil, classname=nil,
keys=nil)
TkToplevel#specific_class
TkObject#borderwidth TkObject#bd
TkToplevel#background(color)
TkToplevel#bg(color)
### --- TkToplevel#class
TkToplevel#classname
TkToplevel#colormap
TkToplevel#container(bool)
TkToplevel#height
TkToplevel#menu
TkToplevel#screen
TkToplevel#use
TkToplevel#visual
TkToplevel#width
A widget whose only purpose is to position other widgets.
To arrange widgets in a grid with TkWindow#pack, you must use the frame widget.
require "tk"
TkFrame.new {
TkLabel.new(self, {"text"=>"A"}).pack "side"=>"left"
TkLabel.new(self, {"text"=>"B"}).pack "side"=>"left"
}.pack
TkFrame.new {
TkLabel.new(self, {"text"=>"C"}).pack "side"=>"left"
TkLabel.new(self, {"text"=>"D"}).pack "side"=>"left"
}.pack
Tk.mainloop
TkObject#borderwidth TkObject#bd
TkFrame#background(color)
TkFrame#bg(color)
Set the frame's color to color. On TkFrame, this option has a special value, "", meaning no color.
*11
### --- TkFrame#class
TkFrame#classname
In Tcl/Tk this option is called class, but since that collides with a Ruby reserved word it is defined as
classname*12.
This option can only be specified by being passed to new when the object is created. To find the value, use the instance variable @classname.
TkFrame#colormap
This option can only be specified by being passed to new when the object is created. To find the value, use the instance variable of the same name.
TkFrame#container(bool)
This option can only be specified by being passed to new when the object is created. To find the value, use the instance variable of the same name.
TkFrame#height(h)
h is the height of the frame. If h is 0, the height of the frame depends on the widgets positioned within it.
TkFrame#visual
This option can only be specified by being passed to new when the object is created. To find the value, use the instance variable of the same name.
TkFrame#width(w)
w is the width of the frame. If w is 0, the width of the frame depends on the widgets positioned within it.
TkMenubar.new(parent = nil,
spec = nil, options =
nil) TkMenubar#add_menu(menu_info)
TkMenubar#[index]
This widget represents a label.
require "tk"
TkLabel.new {
text "label"
pack
}
Tk.mainloop
TkLabel#textvariable(var)
The TkVariable instance var's content is made into a label. If the value of var changes, the label's contents automatically change as well.
TkLabel#height
TkLabel#width
require "tk"
TkButton.new {
text "button"
command { puts "button" }
pack
}
Tk.mainloop
TkButton#invoke
Executes the command option (A TkWindow#command specified with a Proc object).
This allows you to programmatically execute the same functionality that would be invoked on an actual button press.
TkButton#flash
Makes the button flash.
### --- TkButton#command
TkButton#default
This method was implemented in Tk version 8.0
One of the 3 values below must be specified:
"normal"
"active"
"disabled"
TkButton#height
Sets the button's height. If the button contains TkObject#text then the number of lines is set; if it contains an TkObject#image then the pixel size of the image is set. (See distance )
TkButton#state
One of the 3 values below must be specified:
"normal"
Normal state. Color is determined by TkObject#foreground and TkObject#background .
"active"
Active state. The state for when the mouse cursor is over the button. Color is determined by TkObject#activeforeground and TkObject#activebackground .
"disabled"
Disabled state. Button cannot be pressed. Color is determined by TkObject#disabledforeground and TkObject#background .
TkButton#width
Sets the button's width. If the button contains TkObject#text then the number of characters is set; if it contains an TkObject#image then the pixel size of the image is set. (See distance )
require "tk"
v = TkVariable.new
c = proc {print v, "\n"}
TkRadioButton.new {text "a"; variable v; value 1; select; command c; pack}
TkRadioButton.new {text "b"; variable v; value 2; deselect; command c; pack}
TkRadioButton.new {text "c"; variable v; value 3; deselect; command c; pack}
Tk.mainloop
TkRadioButton#deselect
Puts the radion button into the unchecked state.
TkRadioButton#select
Puts the radio button into the checked state.
TkRadioButton#variable(v)
Links the radio button's state to the TkVariable v. Radio buttons linked to the same TkVariable are in the same group. When the radio button is checked, v takes on the value given in TkRadioButton#value.
TkRadioButton#value(val)
Sets the value that the radio button will have when checked to val.
### --- TkRadioButton#command
TkRadioButton#height
See TkButton#height
TkRadioButton#indicatoron
TkRadioButton#selectcolor
TkRadioButton#selectimage
TkRadioButton#state
### --- TkRadioButton#value
### --- TkRadioButton#variable
TkRadioButton#width
This class is for CheckButton widgets.
The variable option specifies a variable that will be linked to the widget. The values to which this variable will be set can be changed via TkCheckButton#onvalue and TkCheckButton#offvalue
. By default, the ON state has a value of 1 and the OFF state is 0.
require "tk"
v1 = TkVariable.new
v2 = TkVariable.new
v3 = TkVariable.new
c = proc {print v1.value,v2.value,v3.value,"\n"}
TkCheckButton.new {text "a"; variable v1; command c; pack}
TkCheckButton.new {text "b"; variable v2; command c; pack}
TkCheckButton.new {text "c"; variable v3; command c; pack}
Tk.mainloop
TkCheckButton#toggle
Toggles the check button's ON/OFF state.
###--- TkCheckButton#command
TkCheckButton#height
TkCheckButton#indicatoron
TkCheckButton#offvalue
Gives the value for when the check button is unchecked.
TkCheckButton#onvalue
Gives the value for when the check button is checked.
TkCheckButton#selectcolor
TkCheckButton#selectimage
TkCheckButton#state
### --- TkCheckButton#variable
TkCheckButton#width
See TkButton#width
In the explanations of the methods below, location is one of the following:
A Number
Character location specified as a number (starting from 0 at the left edge of the input column)
"@<Number>"
Pixel location specified as a number (starting from 0 at the left edge of the input column)
"end"
The location of the end of the inputted text
"insert"
Cursor location
"anchor"
???
"sel.first"
The location of the first character of the selected region
"sel.last"
The location of the last character of the selected region
TkEntry#bbox(index)
TkEntry#delete(s,
e=None)
Delete characters from location s to location e. If e is omitted, deletes one character at s.
TkEntry#cursor
Returns the location of the input cursor.
TkEntry#cursor=(index)
Sets the location of the input cursor to index.
TkEntry#index(index)
Returns the location of the location given in index. If index is greater than the length of the text, returns the location of the last character.
require "tk"
e = TkEntry.new.pack
e.value = "foo"
p e.index(1) # => 1
p e.index(2) # => 2
p e.index("end") # => 3
p e.index(5) # => 3
TkEntry#insert(pos,text)
Inserts the string text at location pos.
TkEntry#mark(pos)
TkEntry#dragto(pos)
TkEntry#selection_adjust(index)
TkEntry#selection_clear
Deselects the selected region.
TkEntry#selection_from(index)
TkEntry#selection_present
Depending on whether a region is selected, returns true or false.
TkEntry#selection_range(s,
e)
Selects a range from s to e.
TkEntry#selection_to(index)
TkEntry#value
Returns the text in the widget.
TkEntry#value=(val)
Sets the text in the widget to val.
A class for messageboxes.
require "tk"
TkMessage.new { text <<-END_OF_MESSAGE; pack }
Test
Message
END_OF_MESSAGE
Tk.mainloop
TkMessage#aspect(ratio)
Sets the aspect ratio of the region in which the message is displayed. If ratio is greater than 100, this region will be rectangular.
TkMessage#justify(s)
Sets the type of justification to use. Acceptable values for s are:
"center"
"left"
"right"
TkMessage#width(w)
The menu button widget. When this button is pressed, a TkMenu appears.
require "tk"
TkFrame.new {
relief "raised"
borderwidth 3
TkMenubutton.new(self) {
text "File"
menu TkMenu.new(self) {
add "command", {"label"=>"Open"}
add "command", {"label"=>"Exit",
"command"=>proc{exit},
"accelerator"=>"Ctrl-Q"
}
}
}.pack "side"=>"left"
}.pack "fill"=>"x"
TkFrame.new {
width "5c"
height "5c"
}.pack
Tk.mainloop
TkMenubutton#direction
Specifies where the menu will be displayed when the button is pressed. Acceptable values are as follows:
"above"
"below"
"left"
"right"
"flush" *15
TkMenubutton#height
TkMenubutton#indicatoron
If set to true, the indicator that shows this to be a menu button*16 is displayed.
TkMenubutton#menu
Link to a TkMenu object.
TkMenubutton#state
"normal"
"active"
"disabled"
TkMenubutton#width
A scrollbar widget. The relationship between scrollbar and widget is such that they move together and the display location of the widget is linked to the state of the bar. This process is troublesome but you can save time by using Tk::Scrollable#xscrollbar.
TkScrollbar#command {|args|
...}
Executes a block, depending on the actions of the scrollbar.
Arguments passed to the block can be of the kinds below:
The case where the little bar inside the scrollbar is dragged:*19
The case where there is a click in some random part of the scrollbar's area:*20
Pass an array consisting of ["moveto", {ratio}]. 'ratio' is a Float in the range 0 to 1, indicating over how much of the scrollbar's area the drag occurred.
The case where the arrow buttons at the end of the bar are clicked:*21
Pass an array consisting of ["scroll", {numeric}, "units"]. The numeric value is -1 or 1 depending on the direction of the button that was pressed.
The case where the blank area inside the bar is clicked:*22
Pass an array consisting of ["scroll", {numeric}, "page"]. The numeric value is -1 or 1 depending on which side of the blank area was clicked.
The format of these arguments takes into account the arguments passed to Tk::Scrollable#xview (or
yview)
TkScrollbar#delta
TkScrollbar#fraction
TkScrollbar#identify
TkScrollbar#get
TkScrollbar#set
Abstract class for text input widgets. Cannot be instantiated.
The meaning of location in the explanations below varies from one derived class to another.
TkTextWin#bbox(index)
For the element given by index, returns the rectangular region as "" is returned.
TkTextWin#delete(first,
last=None)
Deletes the range of elements between first and last. If last is omitted, only the element at first is deleted.
TkTextWin#get(index)
TkTextWin#get(first,
last)
When 1 argument is given, the element at the given location is returned as a string. When there are 2 arguments the specified range of elements is returned.
TkTextWin#index(index)
Returns the location of the element given in index. *24
TkTextWin#insert(index,
chars, *args)
Inserts the string chars into the location given by index.
Returns the empty string "".
In the case of TkListbox, you can insert multiple elements with args.
TkTextWin#scan_mark(x,
y)
The arguments x and y and the currently visible range of elements in the listbox are remembered. This information can then be used when TkTextWin#scan_dragto is called.
Returns the empty string "".
TkTextWin#scan_dragto(x,
y)
The difference between the x and y arguments from the last call to TkTextWin#scan_mark and the current x and y arguments is calculated, and the listbox is scrolled by only that amount.
Returns the empty string "".
Below is an example of scrolling a listbox by dragging with the left mouse button. By default, middle button drag works the same way.
require "tk"
l = TkListbox.new {
height 5
100.times {|i| insert 'end', i}
}.pack
# p Tk.bindinfo(TkListbox, 'Button-2')
# p Tk.bindinfo(TkListbox, 'B2-Motion')
l.bind "Button-1", proc {|e| l.scan_mark(e.x, e.y); Tk.callback_break}
l.bind "B1-Motion" , proc {|e| l.scan_dragto(e.x, e.y); Tk.callback_break}
Tk.mainloop
The calling of event handlers registered on the class is limited by the call to Tk.callback_break.
TkTextWin#see(index)
Makes it so that the location given in index is visible. Returns the empty string"".
require "tk"
l = TkListbox.new {
height 5
100.times {|i| insert 'end', i}
}.pack
TkButton.new {
command {l.see(50)}
}.pack "fill"=>"x"
Tk.mainloop
require "tk"
list = TkListbox.new { setgrid 'yes'; pack }
list.insert 'end', "abc"
list.insert 'end', "def"
list.insert 'end', "123"
list.insert 'end', "456"
Tk.mainloop
The location that appears in the method descriptions can be any of the following:
Number
An element location given by a number (topmost location is 0)
"@x,y"
x and y are numbers. A pixel location given by numbers (counting from the top left corner of the input area)
"active"
The location of the active element (the one where the cursor is)
"end"
The location of the last element
"anchor"
???
TkListbox#activate(y)
Makes the element at the location given in y active. If the listbox has input focus, the active line will be underlined.
require "tk"
TkListbox.new {
insert 'end', "foo"
insert 'end', "bar"
insert 'end', "baz"
activate 1
#focus
pack
}
Tk.mainloop
TkListbox#curselection
Returns the numbers of the currently selected elements as an array (the number of the top element is 0).
TkListbox#get(index)
TkListbox#get(first,
last)
With one argument, returns the element at location as a string. When there are 2 arguments, returns the elements in the given range as an array of strings.
TkListbox#nearest(y)
Returns the number of the element nearest to the Y-coordinate given in y
TkListbox#size
Returns the number of elements.
TkListbox#selection_anchor(index)
Anchors the element at the location given in index.
TkListbox#selection_clear(first,
last=None)
If the elements within the range given by first and last are selected, deselects them. If last is omitted, deselects the element given in first.
TkListbox#selection_includes(index)
Returns a boolean, describing whether the element at the location given in index is selected or not.
require "tk"
l = TkListbox.new {
100.times {|i| insert "end", i}
}.pack
p l.selection_set(0)
p l.selection_includes(0)
Tk.mainloop
TkListbox#selection_set(first,
last=None)
Selects the elements in the range first to last . If last is omitted, selects the element at first.
TkListbox#height
Sets the height of the listbox to the given element number. If 0 is given, automatically adjusts the listbox's size so that all the elements fit (in this case, the value read will be 0).
require "tk"
TkListbox.new {
height 0
insert "end", "a"
insert "end", "b"
insert "end", "c"
p height
}.pack
Tk.mainloop
TkListbox#selectmode
Sets the behavior when an item is selected to one of the following:
"single"
Only one line can be selected at a given time (if another line is picked, that's a whole new selection).
"browse" (default)
Only one line can be selected at a given time (if another line is picked, that's a whole new selection).
Dragging button 1 changes the selected item.
"multiple"
Many lines can be selected at once.
If you click a selected line, it becomes unselected.
"extended"
Please contemplate the different actions of each mode below:
require "tk"
list = TkListbox.new {
("a".."z").each {|c| insert 'end', c}
}.pack 'fill'=>'both', 'expand'=>true
mode_var = TkVariable.new("browse") # default mode
TkLabel.new {
text "select one of below modes"
}.pack 'fill'=>'x'
%w(single browse multiple extended).each {|mode|
TkRadioButton.new {
text mode
variable mode_var
value mode
command {
list.selectmode mode
}
}.pack 'side'=>'left', 'fill'=>'x', 'expand'=>true
}
Tk.mainloop
TkListbox#width
Set the width using a string. If 0 is given, the width will be automatically adjusted so that all strings fit (in this case, the value read will be 0)。
require "tk"
TkListbox.new {
width 0
insert "end", "a" * 10
insert "end", "b"
insert "end", "c"
p width
}.pack
Tk.mainloop
If the font is not fixed-width, using the string "0" is the norm.
A widget that combines a Tk::Scrollbar with a TkListbox. This class is an example of the usage of the TkComposite module.
location
"line.char"
"@x,y"
"end"
[mark]
[tag].first
[tag].last
[path]
[image]
TkText.new(*args)
TkText#init_instance_variable
TkText#index(index)
TkText#value
TkText#value= (val)
TkText#_addcmd(cmd)
TkText#_addtag(name,
obj)
TkText#tagid2obj(tagid)
TkText#tag_names(index=None)
TkText#mark_names
TkText#window_names
TkText#image_names
TkText#set_insert(index)
TkText#set_current(index)
TkText#insert(index, chars,
*tags)
TkText#destroy
TkText#backspace
TkText#compare(idx1, op,
idx2)
TkText#debug
TkText#debug=(boolean)
TkText#bbox(index)
TkText#dlineinfo(index)
TkText#yview(*what)
TkText#yview_pickplace(*what)
TkText#xview(*what)
TkText#xview_pickplace(*what)
TkText#tag_add(tag, index1,
index2=None)
TkText#tag_bind(tag, seq,
cmd=Proc.new,
args=nil)
TkText#tag_bind_append(tag,
seq, cmd=Proc.new,
args=nil)
TkText#tag_bindinfo(tag,
context=nil)
TkText#tag_cget(tag,
key)
TkText#tag_configure(tag,
key, val=None)
TkText#tag_configinfo(tag,
key=nil)
TkText#tag_raise(tag,
above=None)
TkText#tag_lower(tag,
below=None)
TkText#tag_remove(tag,
*index)
TkText#tag_ranges(tag)
TkText#tag_nextrange(tag,
first, last=None)
TkText#tag_prevrange(tag,
first, last=None)
TkText#search_with_length(pat,start,stop=None)
TkText#search(pat,start,stop=None)
TkText#rsearch_with_length(pat,start,stop=None)
TkText#rsearch(pat,start,stop=None)
TkText#height
TkText#spacing1
TkText#spacing2
TkText#spacing3
TkText#state
TkText#tabs
TkText#width
TkText#wrap
Also see TkMenubutton
require "tk"
v = TkVariable.new
v1 = TkVariable.new
v2 = TkVariable.new
v3 = TkVariable.new
menu = TkMenu.new {
title "menu entries"
tearoff false
c = proc { p self.entryconfiginfo "end"}
add "command", {"label"=>"hoge", "command"=>c}
add "separator"
add "checkbutton", {"label"=>"hoge1", "command"=>c, "variable"=>v1, "onvalue"=>1}
add "checkbutton", {"label"=>"hoge2", "command"=>c, "variable"=>v2}
add "checkbutton", {"label"=>"hoge3", "command"=>c, "variable"=>v3}
add "separator"
add "radiobutton", {"label"=>"hoge1", "command"=>c, "variable"=>v}
add "radiobutton", {"label"=>"hoge2", "command"=>c, "variable"=>v}
add "radiobutton", {"label"=>"hoge3", "command"=>c, "variable"=>v}
20.times {|i| p menutype i}
activate 0
}
Tk.root.bind('Button-1') {|e| menu.post(e.x_root, e.y_root) }
Tk.mainloop
The location mentioned in the method explanations below is one of the following:
Number
The item whose ordinal is given (the topmost item is 0)
"@<number>"
The item that is <number> pixels down from the top.
"end" or "last"
The last item
"active"
The active item
"none"
Makes no item active at all.
<pattern>
Items matching the pattern (In the pattern you can use
TkMenu#activate(index)
Makes the element at the location given in index active.
TkMenu#add(type,
keys=nil)
Add one of the kind of item specified by type. type is one of the following:
"command"
(button)
"checkbutton"
"radiobutton"
"cascade"
(cascade menu)
"separator"
(horizontal line)
keys is a hash that contains options for the menu item. The possible options are below:
"activebackground"
"activeforeground"
"accelerator"
A string to be displayed on the far right of the item (to indicate what keypress to use)
"background"
"bitmap"
"columnbreak"
"command"
"font"
"foreground"
"hidemargin"
"image"
"indicatoron"
"label"
A string to be displayed as a menu item.
"menu"
"offvalue"
"onvalue"
"selectcolor"
"selectimage"
"state"
"underline"
"value"
"variable"
TkMenu#index(index)
Returns the index number of the element whose location is given in index.
TkMenu#invoke(index)
Execute the item whose location is given in index.
TkMenu#insert(index, type,
keys=nil)
Insert an item at the location given in index. type and keys are as in TkMenu#add
TkMenu#delete(index,
last=None)
Deletes the item whose location is given in index. If last is specified, items from index to last are deleted.
TkMenu#post(x, y)
Positions self at the given coordinates.
require "tk"
menu = TkMenu.new {
add 'command', {'label'=>'foo1', 'command'=>proc { puts '1'}}
add 'command', {'label'=>'foo2', 'command'=>proc { puts '2'}}
add 'command', {'label'=>'foo3', 'command'=>proc { puts '3'}}
}
Tk.root.bind 'Button-3', proc {|e| menu.post e.x_root, e.y_root }
Tk.root.bind 'Button', proc {|e| menu.unpost }
Tk.mainloop
TkMenu#postcascade(index)
Position a cascade menu at the location given in index. *28
TkMenu#postcommand(cmd=Proc.new)
When self is repositioned, execute cmd. Called from the TkMenu#post method.
TkMenu#menutype(index)
"menubar"
"tearoff"
"normal"
TkMenu#unpost
Make self no longer have a position -- it will no longer be displayed.
TkMenu#yposition(index)
Returns the position pixels of the item whose location is given in index.
TkMenu#entrycget(index,
key)
Return the value of the option given in key, for the item whose location is given in index.
TkMenu#entryconfiure(index,
key, val=None)
TkMenu#entryconfiure(index,
hash)
Sets the value of option key to val, for the item whose location is given in index.
If a hash is given in the 2nd argument, the keys are treated as option names and the values as option values.
TkMenu#entryconfiginfo(index,
key=nil)
Sets the value of option key to val, for the item whose location is given in index.
### --- TkMenu#postcommand
TkMenu#selectcolor
TkMenu#tearoff
TkMenu#tearoffcommand
TkMenu#title
### --- TkMenu#type
require "tk"
TkScale.new {
orient "horizontal"
length 200
from 1
to 500
command {|val|
p val
}
pack
}
Tk.mainloop
TkScale#get
TkScale#value
Obtains the value of the scale.
TkScale#set(val)
TkScale#value=(val)
Sets the value of the scale to val.
TkScale#bigincrement
TkScale#command
TkScale#digits
Valid digits
TkScale#from(n)
Set the topmost (leftmost) value to n.
TkScale#label(text)
Set the scale widget's label to text.
TkScale#length(len)
Set the scale widget's length.
TkScale#resolution(n)
Sets the size of the smallest possible increment on the scale. The value of the scale will be a multiple of this.
TkScale#showvalue(bool)
Sets whether to show the value (bool="1") or hide it (bool="0").
TkScale#sliderlength(len)
Set the slider length to len.
TkScale#sliderrelief(s)
Set the form of the slider. The value used is one of the following:
"raised"
"sunken"
TkScale#state
TkScale#tickinterval(n)
Set the interval between gradations on the scale. If n is 0, no ticks are shown.
TkScale#to(n)
Sets the bottommost (rightmost) value to n.
TkScale#variable(v)
Links the TkVariable object v to the scale.
TkScale#width
require "tk"
TkCanvas.new {
xscrollincrement 50
yscrollincrement 50
scrollregion [10, 10, 500, 500]
xscrollbar(TkScrollbar.new).grid 'column'=>0, 'row'=>1, 'sticky'=>'ew'
yscrollbar(TkScrollbar.new).grid 'column'=>1, 'row'=>0, 'sticky'=>'ns'
TkcOval.new(self, 40, 40, 240, 340)
grid 'column'=>0, 'row'=>0, 'sticky'=>'nsew'
}
TkGrid.columnconfigure Tk.root, 0, 'weight'=>100
TkGrid.rowconfigure Tk.root, 0, 'weight'=>100
Tk.mainloop
In the method explanations below, location is one of the following:
Number
A character position given by a number (starting with 0 at the left edge of the input area)
"@x,y"
A pixel location (starting with 0 at the left edge of the input area)
"end"
The location of the last character .
"insert"
The cursor location
"sel.first"
The location of the first selected character.
"sel.last"
The location of the last selected character.
TkCanvas#tagid(tag)
TkCanvas#addtag(tag, mode,
*args)
TkCanvas#addtag_above(tagOrId,
target)
TkCanvas#addtag_all(tagOrId)
TkCanvas#addtag_below(tagOrId,
target)
TkCanvas#addtag_closest(tagOrId,
x, y, halo=None,
start=None)
TkCanvas#addtag_enclosed(tagOrId,
x1, y1, x2, y2)
TkCanvas#addtag_overlapping(tagOrId,
x1, y1, x2, y2)
TkCanvas#addtag_withtag(tagOrId,
tag)
TkCanvas#bbox(tagOrId,
*tags)
TkCanvas#itembind(tag,
context, cmd=Proc.new,
args=nil)
TkCanvas#itembind_append(tag,
context, cmd=Proc.new,
args=nil)
TkCanvas#itembindinfo(tag,
context=nil)
TkCanvas#canvasx(x,
*args)
TkCanvas#canvasy(y,
*args)
TkCanvas#coords(tag,
*args)
TkCanvas#dchars(tag, first,
last=None)
TkCanvas#delete(*args)
TkCanvas#remove(*args)
TkCanvas#dtag(tag,
tag_to_del=None)
TkCanvas#find(mode,
*args)
Returns the specified item as an array.
Values of mode:
"above"
"all"
"below"
"closest"
"enclosed"
"overlapping"
"withtag"
TkCanvas#find_above(target)
Return the item above the one given in target as an array of elements.
TkCanvas#find_all
Return all items as an array.
require "tk"
x1 = 10
y1 = 10
x2 = 250
y2 = 200
x3 = (x2-x1)/2 + x1
y3 = (y2-y1)/2 + y1
TkCanvas.new {
TkcArc.new self, x1, y1, x2, y2, 'width'=>2.0
TkcBitmap.new self, x3, y3, 'bitmap'=>'error'
# TkcImage.new self, x3, y3, 'image'=>TkImage.new('bitmap'=>'error')
TkcLine.new self, x1, y1, x2, y2, 'arrow'=>'both'
TkcOval.new self, x1, y1, x2, y2
TkcPolygon.new self, x3, y1, x2, y3, x3, y2, x1, y3,
'fill'=>'', 'outline'=>'black'
TkcRectangle.new self, x1, y1, x2, y2
TkcText.new self, x2+20, y2-20, 'text'=>"foo\nbar"
TkcWindow.new self, x2, y2, 'window'=>TkButton.new
# puts find_all
pack
} Tk.mainloop => #<TkcArc:0x4036fd50> #<TkcBitmap:0x4036fa08> #<TkcLine:0x4036f648> #<TkcOval:0x4036f60c> #<TkcPolygon:0x4036eec8> #<TkcRectangle:0x4036eeb4> #<TkcText:0x4036e734> #<TkcWindow:0x4036e4b4>
((-how to specify an image?-))
TkCanvas#find_below(target)
Return the item below the one given in target as an array of elements.
TkCanvas#find_closest(x, y,
halo=None, start=None)
TkCanvas#find_enclosed(x1,
y1, x2, y2)
Return the item inside the given rectangle as an array of elements.
TkCanvas#find_overlapping(x1,
y1, x2, y2)
Return the item that best fits the given rectangle as an array of elements.
Any item that would be found by find_enclosed will be found by find_overlapping.
TkCanvas#find_withtag(tag)
TkCanvas#itemfocus(tagOrId=nil)
TkCanvas#gettags(tagOrId)
TkCanvas#icursor(tagOrId,
index)
TkCanvas#index(tagOrId,
index)
TkCanvas#insert(tagOrId,
index, string)
TkCanvas#itemcget(tagOrId,
option)
TkCanvas#itemconfigure(tagOrId,
key, value=None)
TkCanvas#itemconfiginfo(tagOrId,
key=nil)
TkCanvas#lower(tag,
below=None)
TkCanvas#move(tag, x,
y)
TkCanvas#postscript(keys)
TkCanvas#raise(tag,
above=None)
TkCanvas#scale(tag, x,
y, xs, ys)
TkCanvas#scan_mark(x,
y)
TkCanvas#scan_dragto(x,
y)
TkCanvas#select(mode,
*args)
TkCanvas#select_adjust(tagOrId,
index)
TkCanvas#select_clear
TkCanvas#select_from(tagOrId,
index)
TkCanvas#select_item
TkCanvas#select_to(tagOrId,
index)
TkCanvas#itemtype(tag)
TkCanvas#xview(*index)
TkCanvas#yview(*index)
TkCanvas#closeenough
TkCanvas#confine
TkCanvas#height
TkCanvas#scrollregion
TkCanvas#width
TkCanvas#xscrollincrement
TkCanvas#yscrollincrement
require "tk"
dialog = TkDialog.new('message'=>"test", 'buttons'=>["b1","b2","b3"])
p dialog.value
TkDialog.new(keys =
nil)
Creates a dialog box object. A top level window is displayed, and queries the user for information based on the values specified in keys.
When the user replies to a dialog box, a dialog object is returned. In this way, using TkDialog#value, it is possible to tell what button was pressed.
TkDialog#value
Returns which button was pressed, as a number. Buttons are counted from the left starting at 0.
TkDialog#title
Returns the initial value of the dialog box's title ("DIALOG"). The intention is for this method to be overridden in subclasses.
TkDialog#message
Returns the initial value of the dialog box's message ("MESSAGE"). The intention is for this method to be overridden in subclasses.
TkDialog#message_config
Returns the initial value of the dialog box's message settings (nil). The intention is for this method to be overridden in subclasses.
Please override this method to return a hash.
TkDialog#bitmap
Returns the initial value of the dialog box's bitmap ("info"). The intention is for this method to be overridden in subclasses.
TkDialog#bitmap_config
Returns the initial value of the dialog box's bitmap settings (nil). The intention is for this method to be overridden in subclasses.
TkDialog#default_button
Returns the initial value of the dialog box's default button (0). The intention is for this method to be overridden in subclasses.
TkDialog#buttons
Returns the initial value of the dialog box's buttons. The intention is for this method to be overridden in subclasses.
Please override this method to return an array whose elements consist of the text of each button.
TkDialog#button_configs(num)
Returns the initial value of the dialog box's num-th button settings. The intention is for this method to be overridden in subclasses.
TkWarning.new(mes)
TkWarning#message
TkWarning#title
TkWarning#bitmap
TkWarning#default_button
TkWarning#buttons
TkcItem.type2class(type)
Returns a class determined by type.
type may be any one of:
'arc',
'bitmap',
'image',
'line',
'oval',
'polygon',
'rectangle',
'text',
'window'
TkcItem.id2obj(id)
TkcItem.new(parent,
*args) TkcItem#id
TkcItem#delete
TkcTag.id2obj(id)
TkcTag.new(parent,
mode=nil, *args) TkcTag#id
TkcTag#delete
TkcTag#set_to_above(target)
TkcTag#set_to_all
TkcTag#set_to_below(target)
TkcTag#set_to_closest(x, y,
halo=None, start=None)
TkcTag#set_to_enclosed(x1,
y1, x2, y2)
TkcTag#set_to_overlapping(x1,
y1, x2, y2)
TkcTag#set_to_withtag(target)
TkcGroup#include(*tags)
TkcGroup#exclude(*tags)
TkcTagAll.new(parent)
TkcTagCurrent.new(parent)
TkImage.names
TkImage.types
TkImage.new(keys=nil)
TkImage#delete
TkImage#height
TkImage#itemtype
TkImage#width
TkBitmapImage.new(*args)
TkPhotoImage.new(*args)
TkPhotoImage#blank
TkPhotoImage#cget(option)
TkPhotoImage#copy(source,
*opts)
TkPhotoImage#get(x,
y)
TkPhotoImage#put(data,
*to)
TkPhotoImage#read(file,
*opts)
TkPhotoImage#redither
TkPhotoImage#write(file,
*opts) TkTextImage.new(parent,
index, keys) TkTextImage#[slot]
TkTextImage#[slot] =
value
TkTextImage#cget(slot)
TkTextImage#configure(slot,
value=None)
TkTextImage#image
TkTextImage#image=(value)
TkTextImage#configinfo(slot =
nil) TkTextMark.new(parent,
index) TkTextMark#id
TkTextMark#set(where)
TkTextMark#unset
TkTextMark#gravity
TkTextMark#gravity=(direction)
TkTextMark#next(index)
TkTextMark#previous(index)
TkTextMarkAnchor.new(paren