ffi-tk 2009.11.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +748 -0
- data/MANIFEST +188 -0
- data/README.md +85 -0
- data/Rakefile +47 -0
- data/TODO.md +62 -0
- data/bin/rwish +33 -0
- data/doc/MIT_LICENSE +18 -0
- data/doc/TCL_LICENSE +39 -0
- data/example/choose_color.rb +22 -0
- data/example/choose_directory.rb +22 -0
- data/example/dialog.rb +37 -0
- data/example/hello.rb +11 -0
- data/example/message_box.rb +26 -0
- data/example/option_menu.rb +17 -0
- data/example/popup.rb +24 -0
- data/example/set_palette.rb +32 -0
- data/example/text.rb +47 -0
- data/example/tile/kroc_demo_small.rb +123 -0
- data/example/tile/kroc_rb_demo.rb +135 -0
- data/example/tile/notebook.rb +48 -0
- data/example/tile/theme_hello.rb +38 -0
- data/example/tile/treeview.rb +71 -0
- data/example/various.rb +25 -0
- data/example/wait.rb +16 -0
- data/ffi-tk.gemspec +33 -0
- data/lib/ffi-tk.rb +76 -0
- data/lib/ffi-tk/command.rb +39 -0
- data/lib/ffi-tk/command/after.rb +36 -0
- data/lib/ffi-tk/command/bell.rb +34 -0
- data/lib/ffi-tk/command/bind.rb +11 -0
- data/lib/ffi-tk/command/bindtags.rb +69 -0
- data/lib/ffi-tk/command/cget.rb +92 -0
- data/lib/ffi-tk/command/choose_color.rb +29 -0
- data/lib/ffi-tk/command/choose_directory.rb +45 -0
- data/lib/ffi-tk/command/clipboard.rb +102 -0
- data/lib/ffi-tk/command/configure.rb +88 -0
- data/lib/ffi-tk/command/destroy.rb +12 -0
- data/lib/ffi-tk/command/dialog.rb +54 -0
- data/lib/ffi-tk/command/event.rb +79 -0
- data/lib/ffi-tk/command/focus.rb +70 -0
- data/lib/ffi-tk/command/font.rb +124 -0
- data/lib/ffi-tk/command/get_open_file.rb +85 -0
- data/lib/ffi-tk/command/get_save_file.rb +83 -0
- data/lib/ffi-tk/command/grab.rb +141 -0
- data/lib/ffi-tk/command/grid.rb +246 -0
- data/lib/ffi-tk/command/image.rb +79 -0
- data/lib/ffi-tk/command/lower.rb +23 -0
- data/lib/ffi-tk/command/message_box.rb +65 -0
- data/lib/ffi-tk/command/option_menu.rb +8 -0
- data/lib/ffi-tk/command/pack.rb +99 -0
- data/lib/ffi-tk/command/place.rb +91 -0
- data/lib/ffi-tk/command/popup.rb +14 -0
- data/lib/ffi-tk/command/raise.rb +25 -0
- data/lib/ffi-tk/command/scrollable.rb +151 -0
- data/lib/ffi-tk/command/selection.rb +132 -0
- data/lib/ffi-tk/command/set_palette.rb +9 -0
- data/lib/ffi-tk/command/tk_cmd.rb +155 -0
- data/lib/ffi-tk/command/vars.rb +82 -0
- data/lib/ffi-tk/command/wait.rb +39 -0
- data/lib/ffi-tk/command/winfo.rb +668 -0
- data/lib/ffi-tk/command/wm.rb +1025 -0
- data/lib/ffi-tk/core_extensions.rb +154 -0
- data/lib/ffi-tk/event/data.rb +60 -0
- data/lib/ffi-tk/event/handler.rb +44 -0
- data/lib/ffi-tk/ffi/tcl.rb +92 -0
- data/lib/ffi-tk/ffi/tcl/cmd_proc.rb +10 -0
- data/lib/ffi-tk/ffi/tcl/eval_result.rb +148 -0
- data/lib/ffi-tk/ffi/tcl/interp.rb +95 -0
- data/lib/ffi-tk/ffi/tcl/obj.rb +89 -0
- data/lib/ffi-tk/ffi/tcl/time.rb +36 -0
- data/lib/ffi-tk/ffi/tk.rb +35 -0
- data/lib/ffi-tk/geometry.rb +32 -0
- data/lib/ffi-tk/thread_sender.rb +26 -0
- data/lib/ffi-tk/tk.rb +222 -0
- data/lib/ffi-tk/variable.rb +46 -0
- data/lib/ffi-tk/widget.rb +68 -0
- data/lib/ffi-tk/widget/button.rb +41 -0
- data/lib/ffi-tk/widget/canvas.rb +806 -0
- data/lib/ffi-tk/widget/canvas/arc.rb +18 -0
- data/lib/ffi-tk/widget/canvas/bitmap.rb +13 -0
- data/lib/ffi-tk/widget/canvas/image.rb +10 -0
- data/lib/ffi-tk/widget/canvas/item.rb +170 -0
- data/lib/ffi-tk/widget/canvas/line.rb +16 -0
- data/lib/ffi-tk/widget/canvas/oval.rb +15 -0
- data/lib/ffi-tk/widget/canvas/polygon.rb +16 -0
- data/lib/ffi-tk/widget/canvas/rectangle.rb +15 -0
- data/lib/ffi-tk/widget/canvas/text.rb +15 -0
- data/lib/ffi-tk/widget/canvas/window.rb +11 -0
- data/lib/ffi-tk/widget/checkbutton.rb +63 -0
- data/lib/ffi-tk/widget/entry.rb +208 -0
- data/lib/ffi-tk/widget/frame.rb +12 -0
- data/lib/ffi-tk/widget/label.rb +26 -0
- data/lib/ffi-tk/widget/labelframe.rb +7 -0
- data/lib/ffi-tk/widget/listbox.rb +192 -0
- data/lib/ffi-tk/widget/menu.rb +318 -0
- data/lib/ffi-tk/widget/menubutton.rb +7 -0
- data/lib/ffi-tk/widget/message.rb +36 -0
- data/lib/ffi-tk/widget/panedwindow.rb +164 -0
- data/lib/ffi-tk/widget/radiobutton.rb +43 -0
- data/lib/ffi-tk/widget/root.rb +8 -0
- data/lib/ffi-tk/widget/scale.rb +44 -0
- data/lib/ffi-tk/widget/scrollbar.rb +114 -0
- data/lib/ffi-tk/widget/spinbox.rb +198 -0
- data/lib/ffi-tk/widget/text.rb +893 -0
- data/lib/ffi-tk/widget/text/peer.rb +10 -0
- data/lib/ffi-tk/widget/tile.rb +70 -0
- data/lib/ffi-tk/widget/tile/button.rb +8 -0
- data/lib/ffi-tk/widget/tile/checkbutton.rb +8 -0
- data/lib/ffi-tk/widget/tile/combobox.rb +43 -0
- data/lib/ffi-tk/widget/tile/entry.rb +8 -0
- data/lib/ffi-tk/widget/tile/frame.rb +13 -0
- data/lib/ffi-tk/widget/tile/label.rb +9 -0
- data/lib/ffi-tk/widget/tile/labelframe.rb +8 -0
- data/lib/ffi-tk/widget/tile/menubutton.rb +8 -0
- data/lib/ffi-tk/widget/tile/notebook.rb +93 -0
- data/lib/ffi-tk/widget/tile/panedwindow.rb +9 -0
- data/lib/ffi-tk/widget/tile/progressbar.rb +59 -0
- data/lib/ffi-tk/widget/tile/radiobutton.rb +8 -0
- data/lib/ffi-tk/widget/tile/scale.rb +8 -0
- data/lib/ffi-tk/widget/tile/scrollbar.rb +41 -0
- data/lib/ffi-tk/widget/tile/separator.rb +23 -0
- data/lib/ffi-tk/widget/tile/sizegrip.rb +24 -0
- data/lib/ffi-tk/widget/tile/style.rb +114 -0
- data/lib/ffi-tk/widget/tile/treeview.rb +414 -0
- data/lib/ffi-tk/widget/toplevel.rb +14 -0
- data/spec/ffi-tk/command/bindtags.rb +18 -0
- data/spec/ffi-tk/command/clipboard.rb +18 -0
- data/spec/ffi-tk/command/font.rb +67 -0
- data/spec/ffi-tk/command/grid.rb +6 -0
- data/spec/ffi-tk/command/image.rb +26 -0
- data/spec/ffi-tk/command/pack.rb +20 -0
- data/spec/ffi-tk/command/place.rb +20 -0
- data/spec/ffi-tk/command/selection.rb +13 -0
- data/spec/ffi-tk/command/vars.rb +32 -0
- data/spec/ffi-tk/command/winfo.rb +233 -0
- data/spec/ffi-tk/command/wm.rb +185 -0
- data/spec/ffi-tk/event.rb +95 -0
- data/spec/ffi-tk/tile/button.rb +51 -0
- data/spec/ffi-tk/tile/checkbutton.rb +13 -0
- data/spec/ffi-tk/tile/combobox.rb +65 -0
- data/spec/ffi-tk/tile/entry.rb +61 -0
- data/spec/ffi-tk/tile/frame.rb +65 -0
- data/spec/ffi-tk/tile/label.rb +17 -0
- data/spec/ffi-tk/tile/labelframe.rb +13 -0
- data/spec/ffi-tk/tile/menubutton.rb +13 -0
- data/spec/ffi-tk/tile/notebook.rb +103 -0
- data/spec/ffi-tk/tile/panedwindow.rb +13 -0
- data/spec/ffi-tk/tile/progressbar.rb +78 -0
- data/spec/ffi-tk/tile/radiobutton.rb +13 -0
- data/spec/ffi-tk/tile/scale.rb +13 -0
- data/spec/ffi-tk/tile/scrollbar.rb +43 -0
- data/spec/ffi-tk/tile/separator.rb +22 -0
- data/spec/ffi-tk/tile/sizegrip.rb +13 -0
- data/spec/ffi-tk/tile/style.rb +161 -0
- data/spec/ffi-tk/tile/treeview.rb +101 -0
- data/spec/ffi-tk/variable.rb +24 -0
- data/spec/ffi-tk/widget/button.rb +22 -0
- data/spec/ffi-tk/widget/canvas.rb +169 -0
- data/spec/ffi-tk/widget/checkbutton.rb +44 -0
- data/spec/ffi-tk/widget/entry.rb +155 -0
- data/spec/ffi-tk/widget/frame.rb +8 -0
- data/spec/ffi-tk/widget/label.rb +16 -0
- data/spec/ffi-tk/widget/labelframe.rb +12 -0
- data/spec/ffi-tk/widget/listbox.rb +19 -0
- data/spec/ffi-tk/widget/menu.rb +12 -0
- data/spec/ffi-tk/widget/menubutton.rb +12 -0
- data/spec/ffi-tk/widget/message.rb +12 -0
- data/spec/ffi-tk/widget/panedwindow.rb +12 -0
- data/spec/ffi-tk/widget/radiobutton.rb +12 -0
- data/spec/ffi-tk/widget/root.rb +9 -0
- data/spec/ffi-tk/widget/scale.rb +12 -0
- data/spec/ffi-tk/widget/scrollbar.rb +12 -0
- data/spec/ffi-tk/widget/spinbox.rb +12 -0
- data/spec/ffi-tk/widget/text.rb +246 -0
- data/spec/ffi-tk/widget/toplevel.rb +12 -0
- data/spec/helper.rb +3 -0
- data/tasks/authors.rake +21 -0
- data/tasks/bacon.rake +66 -0
- data/tasks/changelog.rake +18 -0
- data/tasks/gem.rake +22 -0
- data/tasks/gem_setup.rake +113 -0
- data/tasks/grancher.rake +12 -0
- data/tasks/manifest.rake +4 -0
- data/tasks/rcov.rake +17 -0
- data/tasks/release.rake +65 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/setup.rake +12 -0
- data/tasks/ycov.rake +84 -0
- metadata +261 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Tk
|
|
2
|
+
# Create and manipulate frame widgets
|
|
3
|
+
# A frame is a simple widget.
|
|
4
|
+
# Its primary purpose is to act as a spacer or container for complex window
|
|
5
|
+
# layouts. The only features of a frame are its background color and an
|
|
6
|
+
# optional 3-D border to make the frame appear raised or sunken.
|
|
7
|
+
class Frame < Widget
|
|
8
|
+
include Cget, Configure
|
|
9
|
+
|
|
10
|
+
def self.tk_command; 'frame'; end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Tk
|
|
2
|
+
# A label is a widget that displays a textual string, bitmap or image.
|
|
3
|
+
#
|
|
4
|
+
# If text is displayed, it must all be in a single font, but it can occupy
|
|
5
|
+
# multiple lines on the screen (if it contains newlines or if wrapping occurs
|
|
6
|
+
# because of the wrapLength option) and one of the characters may optionally
|
|
7
|
+
# be underlined using the underline option.
|
|
8
|
+
#
|
|
9
|
+
# The label can be manipulated in a few simple ways, such as changing its
|
|
10
|
+
# relief or text.
|
|
11
|
+
# Additional options may be specified to configure aspects of the label such
|
|
12
|
+
# as its colors, font, text, and initial relief.
|
|
13
|
+
class Label < Widget
|
|
14
|
+
include Cget, Configure
|
|
15
|
+
|
|
16
|
+
def self.tk_command; 'label'; end
|
|
17
|
+
|
|
18
|
+
def value=(string)
|
|
19
|
+
configure(text: string)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def value
|
|
23
|
+
cget(:text)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
module Tk
|
|
2
|
+
class Listbox < Widget
|
|
3
|
+
include Cget, Configure, Scrollable
|
|
4
|
+
|
|
5
|
+
def self.tk_command; 'listbox'; end
|
|
6
|
+
|
|
7
|
+
def clear
|
|
8
|
+
delete 0, :end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def value
|
|
12
|
+
get(0, size)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def value=(enumerable)
|
|
16
|
+
clear
|
|
17
|
+
enumerable.each{|element| insert(:end, element) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Sets the active element to the one indicated by index.
|
|
21
|
+
# If index is outside the range of elements in the listbox then the closest
|
|
22
|
+
# element is activated.
|
|
23
|
+
# The active element is drawn as speci‐ fied by -activestyle when the
|
|
24
|
+
# widget has the input focus, and its index may be retrieved with the index
|
|
25
|
+
# active.
|
|
26
|
+
def activate(index)
|
|
27
|
+
execute_only(:activate, index)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Returns a list of four numbers describing the bounding box of the text in
|
|
31
|
+
# the element given by index.
|
|
32
|
+
# The first two elements of the list give the x and y coordinates of the
|
|
33
|
+
# upper-left corner of the screen area covered by the text (specified in
|
|
34
|
+
# pixels relative to the widget) and the last two elements give the width
|
|
35
|
+
# and height of the area, in pixels.
|
|
36
|
+
# If no part of the element given by index is visible on the screen, or if
|
|
37
|
+
# index refers to a non-existent element, then the result is an empty
|
|
38
|
+
# string; if the element is partially visible, the result gives the full
|
|
39
|
+
# area of the element, including any parts that are not visible.
|
|
40
|
+
def bbox(index)
|
|
41
|
+
execute(:bbox, index).to_a(&:to_i)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Returns a list containing the numerical indices of all of the elements in
|
|
45
|
+
# the listbox that are currently selected.
|
|
46
|
+
# If there are no elements selected in the listbox then an empty string is
|
|
47
|
+
# returned.
|
|
48
|
+
def curselection
|
|
49
|
+
execute(:curselection).to_a(&:to_i)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Deletes one or more elements of the listbox.
|
|
53
|
+
# First and last are indices specifying the first and last elements in the
|
|
54
|
+
# range to delete.
|
|
55
|
+
# If last is not specified it defaults to first, i.e.
|
|
56
|
+
# a single element is deleted.
|
|
57
|
+
def delete(first, last = None)
|
|
58
|
+
execute_only(:delete, first, last)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# If last is omitted, returns the contents of the listbox element indicated
|
|
62
|
+
# by first, or an empty string if first refers to a non-existent element.
|
|
63
|
+
# If last is specified, the command returns a list whose elements are all
|
|
64
|
+
# of the listbox elements between first and last, inclusive.
|
|
65
|
+
# Both first and last may have any of the standard forms for indices.
|
|
66
|
+
def get(first, last = None)
|
|
67
|
+
if None == last
|
|
68
|
+
execute(:get, first).to_s
|
|
69
|
+
else
|
|
70
|
+
execute(:get, first, last).to_a
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Returns the integer index value that corresponds to index.
|
|
75
|
+
# If index is end the return value is a count of the number of elements in
|
|
76
|
+
# the listbox (not the index of the last element).
|
|
77
|
+
def index(index)
|
|
78
|
+
execute(:index, index)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Inserts zero or more new elements in the list just before the element
|
|
82
|
+
# given by index.
|
|
83
|
+
# If index is specified as end then the new elements are added to the end
|
|
84
|
+
# of the list.
|
|
85
|
+
# Returns an empty string.
|
|
86
|
+
def insert(index, *elements)
|
|
87
|
+
execute_only(:insert, index, *elements)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Returns the current value of the item configuration option given by
|
|
91
|
+
# option. Option may have any of the values accepted by the listbox
|
|
92
|
+
# itemconfigure command.
|
|
93
|
+
def itemcget(index, option)
|
|
94
|
+
execute(:itemcget, index, option.to_tcl_option)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Query or modify the configuration options of an item in the listbox.
|
|
98
|
+
# If no option is specified, returns a list describing all of the available
|
|
99
|
+
# options for the item (see Tk_ConfigureInfo for information on the format
|
|
100
|
+
# of this list).
|
|
101
|
+
# If option is specified with no value, then the command returns a list
|
|
102
|
+
# describing the one named option (this list will be identical to the
|
|
103
|
+
# correspond‐ ing sublist of the value returned if no option is specified).
|
|
104
|
+
# If one or more option-value pairs are specified, then the command
|
|
105
|
+
# modifies the given widget option(s) to have the given value(s); in this
|
|
106
|
+
# case the command returns an empty string.
|
|
107
|
+
# The following options are currently supported for items: -background
|
|
108
|
+
# color Color specifies the background color to use when displaying the
|
|
109
|
+
# item. It may have any of the forms accepted by Tk_GetColor.
|
|
110
|
+
# -foreground color Color specifies the foreground color to use when
|
|
111
|
+
# displaying the item.
|
|
112
|
+
# It may have any of the forms accepted by Tk_GetColor.
|
|
113
|
+
# -selectbackground color color specifies the background color to use when
|
|
114
|
+
# displaying the item while it is selected.
|
|
115
|
+
# It may have any of the forms accepted by Tk_GetColor.
|
|
116
|
+
# -selectforeground color color specifies the foreground color to use when
|
|
117
|
+
# displaying the item while it is selected.
|
|
118
|
+
# It may have any of the forms accepted by Tk_GetColor.
|
|
119
|
+
def itemconfigure(index, options = None)
|
|
120
|
+
common_configure([:itemconfigure, index], options)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Given a y-coordinate within the listbox window, this command returns the
|
|
124
|
+
# index of the (visible) listbox element nearest to that y-coordinate.
|
|
125
|
+
def nearest(y)
|
|
126
|
+
execute(:nearest, y)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Records x and y and the current view in the listbox window; used in
|
|
130
|
+
# conjunction with later scan dragto commands.
|
|
131
|
+
# Typically this command is associated with a mouse button press in the
|
|
132
|
+
# widget. It returns an empty string.
|
|
133
|
+
def scan_mark(x, y)
|
|
134
|
+
execute_only(:scan, :mark, x, y)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# This command computes the difference between its x and y arguments and
|
|
138
|
+
# the x and y arguments to the last scan mark command for the widget.
|
|
139
|
+
# It then adjusts the view by 10 times the dif‐ ference in coordinates.
|
|
140
|
+
# This command is typically associated with mouse motion events in the
|
|
141
|
+
# widget, to produce the effect of dragging the list at high speed through
|
|
142
|
+
# the window.
|
|
143
|
+
# The return value is an empty string.
|
|
144
|
+
def scan_dragto(x, y)
|
|
145
|
+
execute_only(:scan, :dragto, x, y)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Adjust the view in the listbox so that the element given by index is
|
|
149
|
+
# visible. If the element is already visible then the command has no
|
|
150
|
+
# effect; if the element is near one edge of the window then the listbox
|
|
151
|
+
# scrolls to bring the element into view at the edge; otherwise the listbox
|
|
152
|
+
# scrolls to center the element.
|
|
153
|
+
def see(index)
|
|
154
|
+
execute(:see, index)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Sets the selection anchor to the element given by index.
|
|
158
|
+
# If index refers to a non-existent element, then the closest element is
|
|
159
|
+
# used. The selection anchor is the end of the selection that is fixed
|
|
160
|
+
# while dragging out a selection with the mouse.
|
|
161
|
+
# The index anchor may be used to refer to the anchor element.
|
|
162
|
+
def selection_anchor(index)
|
|
163
|
+
execute(:selection, :anchor, index)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# If any of the elements between first and last (inclusive) are selected,
|
|
167
|
+
# they are deselected.
|
|
168
|
+
# The selection state is not changed for elements outside this range.
|
|
169
|
+
def selection_clear(first, last = None)
|
|
170
|
+
execute(:selection, :clear, first, last)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Returns 1 if the element indicated by index is currently selected, 0 if
|
|
174
|
+
# it is not.
|
|
175
|
+
def selection_includes(index)
|
|
176
|
+
execute(:selection, :includes, index)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Selects all of the elements in the range between first and last,
|
|
180
|
+
# inclusive, without affecting the selection state of elements outside that
|
|
181
|
+
# range.
|
|
182
|
+
def selection_set(first, last = None)
|
|
183
|
+
execute(:selection, :set, first, last)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Returns a decimal string indicating the total number of elements in the
|
|
187
|
+
# listbox.
|
|
188
|
+
def size
|
|
189
|
+
execute(:size)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
module Tk
|
|
2
|
+
class Menu < Widget
|
|
3
|
+
include Cget, Configure
|
|
4
|
+
|
|
5
|
+
def self.tk_command; 'menu'; end
|
|
6
|
+
|
|
7
|
+
# Change the state of the entry indicated by index to active and redisplay
|
|
8
|
+
# it using its active colors.
|
|
9
|
+
# Any previously-active entry is deactivated.
|
|
10
|
+
# If index is specified as none, or if the specified entry is disabled,
|
|
11
|
+
# then the menu ends up with no active entry.
|
|
12
|
+
# Returns an empty string.
|
|
13
|
+
def activate(index)
|
|
14
|
+
execute(:activate, index)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Add a new entry to the bottom of the menu.
|
|
18
|
+
# The new entry's type is given by type and must be one of cascade,
|
|
19
|
+
# checkbutton, command, radiobutton, or separator, or a unique abbreviation
|
|
20
|
+
# of one of the above.
|
|
21
|
+
# If additional arguments are present, they specify any of the following
|
|
22
|
+
# options: -activebackground value Specifies a background color to use for
|
|
23
|
+
# displaying this entry when it is active.
|
|
24
|
+
# If this option is specified as an empty string (the default), then the
|
|
25
|
+
# activeBackground option for the overall menu is used.
|
|
26
|
+
# If the tk_strictMotif variable has been set to request strict Motif
|
|
27
|
+
# compliance, then this option is ignored and the -background option is
|
|
28
|
+
# used in its place.
|
|
29
|
+
# This option is not available for separator or tear-off entries.
|
|
30
|
+
# -activeforeground value Specifies a foreground color to use for
|
|
31
|
+
# displaying this entry when it is active.
|
|
32
|
+
# If this option is specified as an empty string (the default), then the
|
|
33
|
+
# activeForeground option for the overall menu is used.
|
|
34
|
+
# This option is not available for separator or tear-off entries.
|
|
35
|
+
# -accelerator value Specifies a string to display at the right side of the
|
|
36
|
+
# menu entry.
|
|
37
|
+
# Normally describes an accelerator keystroke sequence that may be typed to
|
|
38
|
+
# invoke the same function as the menu entry.
|
|
39
|
+
# This option is not available for separator or tear-off entries.
|
|
40
|
+
# -background value Specifies a background color to use for displaying this
|
|
41
|
+
# entry when it is in the normal state (neither active nor disabled).
|
|
42
|
+
# If this option is specified as an empty string (the default), then the
|
|
43
|
+
# background option for the overall menu is used.
|
|
44
|
+
# This option is not available for separator or tear-off entries.
|
|
45
|
+
# -bitmap value Specifies a bitmap to display in the menu instead of a
|
|
46
|
+
# textual label, in any of the forms accepted by Tk_GetBitmap.
|
|
47
|
+
# This option overrides the -label option (as controlled by the -com‐ pound
|
|
48
|
+
# option) but may be reset to an empty string to enable a textual label to
|
|
49
|
+
# be displayed.
|
|
50
|
+
# If a -image option has been specified, it overrides -bitmap.
|
|
51
|
+
# This option is not available for separator or tear-off entries.
|
|
52
|
+
# -columnbreak value When this option is zero, the entry appears below the
|
|
53
|
+
# previous entry.
|
|
54
|
+
# When this option is one, the entry appears at the top of a new column in
|
|
55
|
+
# the menu.
|
|
56
|
+
# -command value Specifies a Tcl command to execute when the menu entry is
|
|
57
|
+
# invoked. Not available for separator or tear-off entries.
|
|
58
|
+
# -compound value Specifies whether the menu entry should display both an
|
|
59
|
+
# image and text, and if so, where the image should be placed relative to
|
|
60
|
+
# the text.
|
|
61
|
+
# Valid values for this option are bottom, cen‐ ter, left, none, right and
|
|
62
|
+
# top. The default value is none, meaning that the button will display
|
|
63
|
+
# either an image or text, depending on the values of the -image and
|
|
64
|
+
# -bitmap options.
|
|
65
|
+
# -font value Specifies the font to use when drawing the label or
|
|
66
|
+
# accelerator string in this entry.
|
|
67
|
+
# If this option is specified as an empty string (the default) then the
|
|
68
|
+
# font option for the overall menu is used.
|
|
69
|
+
# This option is not available for separator or tear-off entries.
|
|
70
|
+
# -foreground value Specifies a foreground color to use for displaying this
|
|
71
|
+
# entry when it is in the normal state (neither active nor disabled).
|
|
72
|
+
# If this option is specified as an empty string (the default), then the
|
|
73
|
+
# foreground option for the overall menu is used.
|
|
74
|
+
# This option is not available for separator or tear-off entries.
|
|
75
|
+
# -hidemargin value Specifies whether the standard margins should be drawn
|
|
76
|
+
# for this menu entry.
|
|
77
|
+
# This is useful when creating palette with images in them, i.e., color
|
|
78
|
+
# palettes, pattern palettes, etc.
|
|
79
|
+
# 1 indicates that the margin for the entry is hidden; 0 means that the
|
|
80
|
+
# margin is used.
|
|
81
|
+
# -image value Specifies an image to display in the menu instead of a text
|
|
82
|
+
# string or bitmap.
|
|
83
|
+
# The image must have been created by some previous invocation of image
|
|
84
|
+
# create. This option overrides the -label and -bitmap options (as
|
|
85
|
+
# controlled by the -compound option) but may be reset to an empty string
|
|
86
|
+
# to enable a textual or bitmap label to be displayed.
|
|
87
|
+
# This option is not available for separator or tear-off entries.
|
|
88
|
+
# -indicatoron value Available only for checkbutton and radiobutton
|
|
89
|
+
# entries. Value is a boolean that determines whether or not the indicator
|
|
90
|
+
# should be displayed.
|
|
91
|
+
# -label value Specifies a string to display as an identifying label in the
|
|
92
|
+
# menu entry.
|
|
93
|
+
# Not available for separator or tear-off entries.
|
|
94
|
+
# -menu value Available only for cascade entries.
|
|
95
|
+
# Specifies the path name of the submenu associated with this entry.
|
|
96
|
+
# The submenu must be a child of the menu.
|
|
97
|
+
# -offvalue value Available only for checkbutton entries.
|
|
98
|
+
# Specifies the value to store in the entry's associated variable when the
|
|
99
|
+
# entry is deselected.
|
|
100
|
+
# -onvalue value Available only for checkbutton entries.
|
|
101
|
+
# Specifies the value to store in the entry's associated variable when the
|
|
102
|
+
# entry is selected.
|
|
103
|
+
# -selectcolor value Available only for checkbutton and radiobutton
|
|
104
|
+
# entries. Specifies the color to display in the indicator when the entry
|
|
105
|
+
# is selected.
|
|
106
|
+
# If the value is an empty string (the default) then the selectColor option
|
|
107
|
+
# for the menu determines the indicator color.
|
|
108
|
+
# -selectimage value Available only for checkbutton and radiobutton
|
|
109
|
+
# entries. Specifies an image to display in the entry (in place of the
|
|
110
|
+
# -image option) when it is selected.
|
|
111
|
+
# Value is the name of an image, which must have been created by some
|
|
112
|
+
# previous invocation of image create.
|
|
113
|
+
# This option is ignored unless the -image option has been specified.
|
|
114
|
+
# -state value Specifies one of three states for the entry: normal, active,
|
|
115
|
+
# or disabled.
|
|
116
|
+
# In normal state the entry is displayed using the foreground option for
|
|
117
|
+
# the menu and the background option from the entry or the menu.
|
|
118
|
+
# The active state is typically used when the pointer is over the entry.
|
|
119
|
+
# In active state the entry is displayed using the activeForeground option
|
|
120
|
+
# for the menu along with the activebackground option from the entry.
|
|
121
|
+
# Disabled state means that the entry should be insensitive: the default
|
|
122
|
+
# bindings will refuse to activate or invoke the entry.
|
|
123
|
+
# In this state the entry is displayed according to the disabledForeground
|
|
124
|
+
# option for the menu and the background option from the entry.
|
|
125
|
+
# This option is not available for separa‐ tor entries.
|
|
126
|
+
# -underline value Specifies the integer index of a character to underline
|
|
127
|
+
# in the entry.
|
|
128
|
+
# This option is also queried by the default bindings and used to implement
|
|
129
|
+
# keyboard traversal.
|
|
130
|
+
# 0 corresponds to the first character of the text displayed in the entry,
|
|
131
|
+
# 1 to the next character, and so on.
|
|
132
|
+
# If a bitmap or image is displayed in the entry then this option is
|
|
133
|
+
# ignored. This option is not available for separator or tear-off entries.
|
|
134
|
+
# -value value Available only for radiobutton entries.
|
|
135
|
+
# Specifies the value to store in the entry's associated variable when the
|
|
136
|
+
# entry is selected.
|
|
137
|
+
# If an empty string is specified, then the -label option for the entry as
|
|
138
|
+
# the value to store in the variable.
|
|
139
|
+
# -variable value Available only for checkbutton and radiobutton entries.
|
|
140
|
+
# Specifies the name of a global value to set when the entry is selected.
|
|
141
|
+
# For checkbutton entries the variable is also set when the entry is
|
|
142
|
+
# deselected. For radiobutton entries, changing the variable causes the
|
|
143
|
+
# currently-selected entry to deselect itself.
|
|
144
|
+
# The add widget command returns an empty string.
|
|
145
|
+
def add(type, options = None)
|
|
146
|
+
if None == options
|
|
147
|
+
execute(:add, type)
|
|
148
|
+
else
|
|
149
|
+
execute(:add, type, option_hash_to_tcl(options))
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Makes a clone of the current menu named newPathName.
|
|
154
|
+
# This clone is a menu in its own right, but any changes to the clone are
|
|
155
|
+
# propagated to the original menu and vice versa.
|
|
156
|
+
# cloneType can be normal, menubar, or tearoff.
|
|
157
|
+
# Should not normally be called outside of the Tk library.
|
|
158
|
+
# See the CLONES section for more information.
|
|
159
|
+
def clone(newPathname, cloneType = None)
|
|
160
|
+
execute(:clone, newPathname, cloneType)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Delete all of the menu entries between index1 and index2 inclusive.
|
|
164
|
+
# If index2 is omitted then it defaults to index1.
|
|
165
|
+
# Attempts to delete a tear-off menu entry are ignored (instead, you should
|
|
166
|
+
# change the tearOff option to remove the tear-off entry).
|
|
167
|
+
def delete(index1, index2 = None)
|
|
168
|
+
execute(:delete, index1, index2)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Returns the current value of a configuration option for the entry given
|
|
172
|
+
# by index.
|
|
173
|
+
# Option may have any of the values accepted by the add widget command.
|
|
174
|
+
def entrycget(index, option)
|
|
175
|
+
execute(:entrycget, index, option)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# This command is similar to the configure command, except that it applies
|
|
179
|
+
# to the options for an individual entry, whereas configure applies to the
|
|
180
|
+
# options for the menu as a whole.
|
|
181
|
+
# Options may have any of the values accepted by the add widget command.
|
|
182
|
+
# If options are specified, options are modified as indicated in the
|
|
183
|
+
# command and the command returns an empty string.
|
|
184
|
+
# If no options are specified, returns a list describing the current
|
|
185
|
+
# options for entry index (see Tk_ConfigureInfo for information on the
|
|
186
|
+
# format of this list).
|
|
187
|
+
def entryconfigure(index, options = None)
|
|
188
|
+
common_configure([:entryconfigure, index], options)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Returns the numerical index corresponding to index, or none if index was
|
|
192
|
+
# specified as none.
|
|
193
|
+
def index(index)
|
|
194
|
+
execute(:index, index)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Same as the add widget command except that it inserts the new entry just
|
|
198
|
+
# before the entry given by index, instead of appending to the end of the
|
|
199
|
+
# menu. The type, option, and value arguments have the same interpretation
|
|
200
|
+
# as for the add widget command.
|
|
201
|
+
# It is not possible to insert new menu entries before the tear-off entry,
|
|
202
|
+
# if the menu has one.
|
|
203
|
+
def insert(index, type, options = None)
|
|
204
|
+
if None == options
|
|
205
|
+
execute(:insert, index, type)
|
|
206
|
+
else
|
|
207
|
+
execute(:insert, index, type, options.to_tcl_options)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Invoke the action of the menu entry.
|
|
212
|
+
# See the sections on the individual entries above for details on what
|
|
213
|
+
# happens. If the menu entry is disabled then nothing happens.
|
|
214
|
+
# If the entry has a command associated with it then the result of that
|
|
215
|
+
# command is returned as the result of the invoke widget command.
|
|
216
|
+
# Otherwise the result is an empty string.
|
|
217
|
+
# Note: invoking a menu entry does not automatically unpost the menu; the
|
|
218
|
+
# default bindings normally take care of this before invoking the invoke
|
|
219
|
+
# widget command.
|
|
220
|
+
def invoke(index)
|
|
221
|
+
execute(:invoke, index)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Arrange for the menu to be displayed on the screen at the root-window
|
|
225
|
+
# coordinates given by x and y.
|
|
226
|
+
# These coordinates are adjusted if necessary to guarantee that the entire
|
|
227
|
+
# menu is visible on the screen.
|
|
228
|
+
# This command normally returns an empty string.
|
|
229
|
+
# If the postCommand option has been specified, then its value is executed
|
|
230
|
+
# as a Tcl script before posting the menu and the result of that script is
|
|
231
|
+
# returned as the result of the post widget command.
|
|
232
|
+
# If an error returns while executing the command, then the error is
|
|
233
|
+
# returned without posting the menu.
|
|
234
|
+
def post(x, y)
|
|
235
|
+
execute(:post, x, y).to_s?
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Posts the submenu associated with the cascade entry given by index, and
|
|
239
|
+
# unposts any previously posted submenu.
|
|
240
|
+
# If index does not correspond to a cascade entry, or if pathName is not
|
|
241
|
+
# posted, the command has no effect except to unpost any currently posted
|
|
242
|
+
# submenu.
|
|
243
|
+
def postcascade(index)
|
|
244
|
+
execute(:postcascade, index)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Returns the type of the menu entry given by index.
|
|
248
|
+
# This is the type argument passed to the add widget command when the entry
|
|
249
|
+
# was created, such as command or separator, or tearoff for a tear- off
|
|
250
|
+
# entry.
|
|
251
|
+
def type(index)
|
|
252
|
+
execute(:type, index)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Unmap the window so that it is no longer displayed.
|
|
256
|
+
# If a lower-level cascaded menu is posted, unpost that menu.
|
|
257
|
+
# Returns an empty string.
|
|
258
|
+
# This subcommand does not work on Windows and the Mac‐ intosh, as those
|
|
259
|
+
# platforms have their own way of unposting menus.
|
|
260
|
+
def unpost
|
|
261
|
+
execute(:unpost)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# Returns a decimal string giving the x-coordinate within the menu window
|
|
265
|
+
# of the leftmost pixel in the entry specified by index.
|
|
266
|
+
# │
|
|
267
|
+
def xposition(index)
|
|
268
|
+
execute(:xposition, index)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# Returns a decimal string giving the y-coordinate within the menu window
|
|
272
|
+
# of the topmost pixel in the entry specified by index.
|
|
273
|
+
# This is the most common case.
|
|
274
|
+
# You create a menu widget that will become the menu bar.
|
|
275
|
+
# You then add cascade entries to this menu, specifying the pull down menus
|
|
276
|
+
# you wish to use in your menu bar.
|
|
277
|
+
# You then create all of the pulldowns.
|
|
278
|
+
# Once you have done this, specify the menu using the -menu option of the
|
|
279
|
+
# toplevel's widget command.
|
|
280
|
+
# See the toplevel manual entry for details.
|
|
281
|
+
# This is the compatible way to do menu bars.
|
|
282
|
+
# You create one menubutton widget for each top-level menu, and typically
|
|
283
|
+
# you arrange a series of menubuttons in a row in a menubar window.
|
|
284
|
+
# You also create the top-level menus and any cascaded submenus, and tie
|
|
285
|
+
# them together with -menu options in menubuttons and cascade menu entries.
|
|
286
|
+
# The top-level menu must be a child of the menubutton, and each submenu
|
|
287
|
+
# must be a child of the menu that refers to it.
|
|
288
|
+
# Once you have done this, the default bindings will allow users to
|
|
289
|
+
# traverse and invoke the tree of menus via its menubutton; see the
|
|
290
|
+
# menubutton manual entry for details.
|
|
291
|
+
# Popup menus typically post in response to a mouse button press or
|
|
292
|
+
# keystroke. You create the popup menus and any cascaded submenus, then you
|
|
293
|
+
# call the tk_popup procedure at the appropriate time to post the top-level
|
|
294
|
+
# menu. An option menu consists of a menubutton with an associated menu
|
|
295
|
+
# that allows you to select one of several values.
|
|
296
|
+
# The current value is displayed in the menubutton and is also stored in a
|
|
297
|
+
# global variable.
|
|
298
|
+
# Use the tk_optionMenu procedure to create option menubuttons and their
|
|
299
|
+
# menus. You create a torn-off menu by invoking the tear-off entry at the
|
|
300
|
+
# top of an existing menu.
|
|
301
|
+
# The default bindings will create a new menu that is a copy of the
|
|
302
|
+
# original menu and leave it perma‐ nently posted as a top-level window.
|
|
303
|
+
# The torn-off menu behaves just the same as the original menu.
|
|
304
|
+
# and unposts the menu.
|
|
305
|
+
# If the current menu is a top-level menu posted from a menubutton, then
|
|
306
|
+
# the current menubutton is unposted and the next menubutton to the left is
|
|
307
|
+
# posted. Otherwise the key has no effect.
|
|
308
|
+
# The left-right order of menubuttons is determined by their stacking
|
|
309
|
+
# order: Tk assumes that the lowest menubutton (which by default is the
|
|
310
|
+
# first one created) is on the left.
|
|
311
|
+
# Otherwise, if the current menu was posted from a menubutton, then the
|
|
312
|
+
# current menubutton is unposted and the next menubutton to the right is
|
|
313
|
+
# posted.
|
|
314
|
+
def yposition(index)
|
|
315
|
+
execute(:yposition, index)
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|