ffi-tk 2009.11.29
Sign up to get free protection for your applications and to get access to all the features.
- 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,246 @@
|
|
1
|
+
module Tk
|
2
|
+
# Geometry manager that arranges widgets in a grid
|
3
|
+
#
|
4
|
+
# The grid command is used to communicate with the grid geometry manager that
|
5
|
+
# arranges widgets in rows and columns inside of another window, called the
|
6
|
+
# geometry master (or master window).
|
7
|
+
module Grid
|
8
|
+
# If the first argument to grid is suitable as the first slave argument to
|
9
|
+
# grid configure, either a window name (any value starting with .) or one of
|
10
|
+
# the characters x or ^ (see the RELATIVE PLACEMENT section below), then the
|
11
|
+
# command is processed in the same way as grid configure.
|
12
|
+
def self.slave(*arguments)
|
13
|
+
Tk.execute('grid', 'slave', *arguments)
|
14
|
+
end
|
15
|
+
|
16
|
+
# The anchor value controls how to place the grid within the master when no
|
17
|
+
# row/column has any weight.
|
18
|
+
# The default anchor is nw.
|
19
|
+
def self.anchor(master, anchor = None)
|
20
|
+
Tk.execute('grid', 'anchor', master, anchor)
|
21
|
+
end
|
22
|
+
|
23
|
+
# With no arguments, the bounding box (in pixels) of the grid is returned.
|
24
|
+
# The return value consists of 4 integers.
|
25
|
+
#
|
26
|
+
# The first two are the pixel offset from the master window (x then y) of
|
27
|
+
# the top-left corner of the grid, and the second two integers are the width
|
28
|
+
# and height of the grid, also in pixels.
|
29
|
+
#
|
30
|
+
# If only +col1+ and +row1+ are given, then the bounding box for that cell
|
31
|
+
# is returned, where the top left cell is numbered from zero.
|
32
|
+
# If +col2+ and +col2+ are given as well, then the bounding box
|
33
|
+
# spanning the rows and columns indicated is returned.
|
34
|
+
#
|
35
|
+
# @usage Example
|
36
|
+
#
|
37
|
+
# Bbox.bbox('.', 0, 0) # top left cell
|
38
|
+
# Bbox.bbox('.', 1, 1) # cell in second column and row
|
39
|
+
# Bbox.bbox('.', 0, 0, 1, 1) # cells from top left to second col/row
|
40
|
+
def self.bbox(master, col1 = None, row1 = None, col2 = None, row2 = None)
|
41
|
+
bbox = Tk.execute('grid', 'bbox', master, column1, row1, column2, row2)
|
42
|
+
bbox.map(&:to_i)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Query or set the column properties of the index column of the geometry
|
46
|
+
# master, master.
|
47
|
+
# The valid options are -minsize, -weight, -uniform and -pad.
|
48
|
+
# If one or more options are provided, then index may be given as a list of
|
49
|
+
# column indices to which the configuration options will operate on.
|
50
|
+
# Indices may be integers, window names or the keyword all.
|
51
|
+
# For all the options apply to all columns currently occupied be slave
|
52
|
+
# windows. For a window name, that window must be a slave of this master and
|
53
|
+
# the options apply to all columns currently occupied be the slave.
|
54
|
+
# The -minsize option sets the minimum size, in screen units, that will be
|
55
|
+
# permitted for this column.
|
56
|
+
# The -weight option (an integer value) sets the relative weight for
|
57
|
+
# apportioning any extra spaces among columns.
|
58
|
+
# A weight of zero (0) indicates the column will not deviate from its
|
59
|
+
# requested size.
|
60
|
+
# A column whose weight is two will grow at twice the rate as a column of
|
61
|
+
# weight one when extra space is allocated to the layout.
|
62
|
+
# The -uniform option, when a non-empty value is supplied, places the column
|
63
|
+
# in a uniform group with other columns that have the same value for
|
64
|
+
# -uniform. The space for columns belonging to a uniform group is allocated
|
65
|
+
# so that their sizes are always in strict proportion to their -weight
|
66
|
+
# values. See THE GRID ALGORITHM below for further details.
|
67
|
+
# The -pad option specifies the number of screen units that will be added to
|
68
|
+
# the largest window contained completely in that column when the grid
|
69
|
+
# geometry manager requests a size from the containing window.
|
70
|
+
# If only an option is specified, with no value, the current value of that
|
71
|
+
# option is returned.
|
72
|
+
# If only the master window and index is specified, all the current settings
|
73
|
+
# are returned in a list of â-option valueâ pairs.
|
74
|
+
def self.columnconfigure(master, index, options = {})
|
75
|
+
Tk.execute('grid', 'columnconfigure', master, index, options)
|
76
|
+
end
|
77
|
+
|
78
|
+
# The arguments consist of the names of one or more slave windows followed
|
79
|
+
# by pairs of arguments that specify how to manage the slaves.
|
80
|
+
# The characters -, x and ^, can be specified instead of a window name to
|
81
|
+
# alter the default location of a slave.
|
82
|
+
def self.configure(*arguments)
|
83
|
+
options, slaves = arguments.partition{|arg| arg.respond_to?(:to_tcl_options?) }
|
84
|
+
options = options.first
|
85
|
+
Tk.execute('grid', 'configure', *slaves, options.to_tcl_options?)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Removes each of the slaves from grid for its master and unmaps their
|
89
|
+
# windows. The slaves will no longer be managed by the grid geometry
|
90
|
+
# manager. The configuration options for that window are forgotten, so that
|
91
|
+
# if the slave is managed once more by the grid geometry manager, the
|
92
|
+
# initial default settings are used.
|
93
|
+
def self.forget(*slaves)
|
94
|
+
Tk.execute('grid', 'forget', *slaves)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns a list whose elements are the current configuration state of the
|
98
|
+
# slave given by slave in the same option-value form that might be specified
|
99
|
+
# to grid configure.
|
100
|
+
# The first two elements of the list are â-in masterâ where master is
|
101
|
+
# the slave's master.
|
102
|
+
def self.info(slave)
|
103
|
+
Tk.execute('grid', 'info', slave)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Given x and y values in screen units relative to the master window, the
|
107
|
+
# column and row number at that x and y location is returned.
|
108
|
+
# For locations that are above or to the left of the grid, -1 is returned.
|
109
|
+
def self.location(master, x, y)
|
110
|
+
Tk.execute('grid', 'location', master, x, y)
|
111
|
+
end
|
112
|
+
|
113
|
+
# If boolean has a true boolean value such as 1 or on then propagation is
|
114
|
+
# enabled for master, which must be a window name (see GEOMETRY PROPAGATION
|
115
|
+
# below). If boolean has a false boolean value then propagation is disabled
|
116
|
+
# for master.
|
117
|
+
# In either of these cases an empty string is returned.
|
118
|
+
# If boolean is omitted then the command returns 0 or 1 to indicate whether
|
119
|
+
# propagation is currently enabled for master.
|
120
|
+
# Propagation is enabled by default.
|
121
|
+
def self.propagate(master, boolean = None)
|
122
|
+
Tk.execute('grid', 'propagate', master, boolean)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Query or set the row properties of the index row of the geometry master,
|
126
|
+
# master. The valid options are -minsize, -weight, -uniform and -pad.
|
127
|
+
# If one or more options are provided, then index may be given as a list of
|
128
|
+
# row indices to which the configuration options will operate on.
|
129
|
+
# Indices may be integers, window names or the keyword all.
|
130
|
+
# For all the options apply to all rows currently occupied be slave windows.
|
131
|
+
# For a window name, that window must be a slave of this master and the
|
132
|
+
# options apply to all rows currently occupied be the slave.
|
133
|
+
# The -minsize option sets the minimum size, in screen units, that will be
|
134
|
+
# permitted for this row.
|
135
|
+
# The -weight option (an integer value) sets the relative weight for
|
136
|
+
# apportioning any extra spaces among rows.
|
137
|
+
# A weight of zero (0) indicates the row will not deviate from its requested
|
138
|
+
# size. A row whose weight is two will grow at twice the rate as a row of
|
139
|
+
# weight one when extra space is allocated to the layout.
|
140
|
+
# The -uniform option, when a non-empty value is supplied, places the row in
|
141
|
+
# a uniform group with other rows that have the same value for -uniform.
|
142
|
+
# The space for rows belonging to a uniform group is allocated so that their
|
143
|
+
# sizes are always in strict proportion to their -weight values.
|
144
|
+
# See THE GRID ALGORITHM below for further details.
|
145
|
+
# The -pad option specifies the number of screen units that will be added to
|
146
|
+
# the largest window contained completely in that row when the grid geometry
|
147
|
+
# manager requests a size from the containing window.
|
148
|
+
# If only an option is specified, with no value, the current value of that
|
149
|
+
# option is returned.
|
150
|
+
# If only the master window and index is specified, all the current settings
|
151
|
+
# are returned in a list of â-option valueâ pairs.
|
152
|
+
def self.rowconfigure(master, index, options = None)
|
153
|
+
Tk.execute('grid', 'rowconfigure', master, index, options.to_tcl_options?)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Removes each of the slaves from grid for its master and unmaps their
|
157
|
+
# windows. The slaves will no longer be managed by the grid geometry
|
158
|
+
# manager. However, the configuration options for that window are
|
159
|
+
# remembered, so that if the slave is managed once more by the grid geometry
|
160
|
+
# manager, the previous values are retained.
|
161
|
+
def self.remove(*slaves)
|
162
|
+
Tk.execute('grid', 'remove', *slaves)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Returns the size of the grid (in columns then rows) for master.
|
166
|
+
# The size is determined either by the slave occupying the largest row or
|
167
|
+
# column, or the largest column or row with a minsize, weight, or pad that
|
168
|
+
# is non-zero.
|
169
|
+
def self.size(master)
|
170
|
+
Tk.execute('grid', 'size', master)
|
171
|
+
end
|
172
|
+
|
173
|
+
# If no options are supplied, a list of all of the slaves in master are
|
174
|
+
# returned, most recently manages first.
|
175
|
+
# Option can be either -row or -column which causes only the slaves in the
|
176
|
+
# row (or column) specified by value to be returned.
|
177
|
+
def self.slaves(master, options = {})
|
178
|
+
Tk.execute('grid', 'slaves')
|
179
|
+
end
|
180
|
+
|
181
|
+
# @see Grid::slave
|
182
|
+
def grid_slave(options = {})
|
183
|
+
Grid.slave(self, options)
|
184
|
+
end
|
185
|
+
|
186
|
+
# @see Grid::anchor
|
187
|
+
def grid_anchor(anchor = None)
|
188
|
+
Grid.anchor(self, anchor)
|
189
|
+
end
|
190
|
+
|
191
|
+
# @see Grid::bbox
|
192
|
+
def grid_bbox(col1 = None, row1 = None, col2 = None, row2 = None)
|
193
|
+
Grid.bbox(self, col1, row1, col2, row2)
|
194
|
+
end
|
195
|
+
|
196
|
+
# @see Grid::columnconfigure
|
197
|
+
def grid_columnconfigure(index, options = {})
|
198
|
+
Grid.columnconfigure(self, index, options.to_tcl_options)
|
199
|
+
end
|
200
|
+
|
201
|
+
# @see Grid::configure
|
202
|
+
def grid_configure(options = None)
|
203
|
+
Grid.configure(self, options)
|
204
|
+
end
|
205
|
+
|
206
|
+
# @see Grid::forget
|
207
|
+
def grid_forget
|
208
|
+
Grid.forget(self)
|
209
|
+
end
|
210
|
+
|
211
|
+
# @see Grid::info
|
212
|
+
def grid_info
|
213
|
+
Grid.info(self)
|
214
|
+
end
|
215
|
+
|
216
|
+
# @see Grid::location
|
217
|
+
def grid_location(x, y)
|
218
|
+
Grid.location(self, x, y)
|
219
|
+
end
|
220
|
+
|
221
|
+
# @see Grid::propagte
|
222
|
+
def grid_propagate(boolean = None)
|
223
|
+
Grid.propagate(self, boolean)
|
224
|
+
end
|
225
|
+
|
226
|
+
# @see grid::rowconfigure
|
227
|
+
def grid_rowconfigure(index, options = None)
|
228
|
+
Grid.rowconfigure(self, index, options)
|
229
|
+
end
|
230
|
+
|
231
|
+
# @see Grid::remove
|
232
|
+
def grid_remove
|
233
|
+
Grid.remove(self)
|
234
|
+
end
|
235
|
+
|
236
|
+
# @see Grid::size
|
237
|
+
def grid_size
|
238
|
+
Grid.size(self)
|
239
|
+
end
|
240
|
+
|
241
|
+
# @see Grid::slaves
|
242
|
+
def grid_slaves(options = {})
|
243
|
+
Grid.slaves(self, options)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Tk
|
2
|
+
module Image
|
3
|
+
module_function
|
4
|
+
|
5
|
+
# Creates an image and a commend of the same name.
|
6
|
+
# Returns the name of the command containing the image.
|
7
|
+
#
|
8
|
+
# +type+ specifies the type of the image, which must be one of the types
|
9
|
+
# currently defined (e.g., bitmap or photo).
|
10
|
+
#
|
11
|
+
# +name+ specifies the name for the image; if it is ommitted then Tk picks a
|
12
|
+
# name of the form imagex, where x is an integer.
|
13
|
+
#
|
14
|
+
# +options+ may be a Hash containing configuration options for the new
|
15
|
+
# image.
|
16
|
+
#
|
17
|
+
# The legal set of +options+ is defined separately for each image type; see
|
18
|
+
# documentation of [Image] for built-in image types.
|
19
|
+
#
|
20
|
+
# If a proc already exists with the given name, then it is replaced with
|
21
|
+
# the new image and any instances of that image will redisplay with the new
|
22
|
+
# contents.
|
23
|
+
# It is important to note that [create] will silently overwrite any existing
|
24
|
+
# images of the same name, so choose the name wisely.
|
25
|
+
#
|
26
|
+
# It is recommended to use a separate namespace for image names, like
|
27
|
+
# "::img::logo" or "::img::large"
|
28
|
+
def create(type, name = None, options = None)
|
29
|
+
if None == name
|
30
|
+
Tk.execute(:image, :create, type)
|
31
|
+
elsif None == options && name.respond_to?(:to_hash)
|
32
|
+
Tk.execute(:image, :create, name.to_tcl_options)
|
33
|
+
elsif None != name && None != options
|
34
|
+
Tk.exeucte(:image, :create, name, options.to_tcl_options)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Deletes each of the named images and returns an empty string.
|
39
|
+
# If there are instances of the images displayed in widgets, the images
|
40
|
+
# will not actually be deleted until all of the instances are released.
|
41
|
+
# However, the association between the instances and the image manager will
|
42
|
+
# be dropped.
|
43
|
+
# Existing instances will retain their sizes but redisplay as empty areas.
|
44
|
+
# If a deleted image is recreated with another call to image create, the
|
45
|
+
# existing instances will use the new image.
|
46
|
+
def delete(*names)
|
47
|
+
Tk.execute(:image, :delete, *names)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns a decimal string giving the height of image name in pixels.
|
51
|
+
def height(name)
|
52
|
+
Tk.execute(:image, :height, name)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns a boolean value indicating whether or not the image given by name
|
56
|
+
# is in use by any widgets.
|
57
|
+
def inuse(name)
|
58
|
+
Tk.execute(:image, :inuse, name).to_boolean
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns a list containing the names of all existing images.
|
62
|
+
def names
|
63
|
+
Tk.execute(:image, :names).to_a
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns the type of image name (the value of the type argument to image
|
67
|
+
# create when the image was created).
|
68
|
+
def type(name)
|
69
|
+
Tk.execute(:image, :type, name).to_sym
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns a list whose elements are all of the valid image types (i.e., all
|
73
|
+
# of the values that may be supplied for the type argument to image
|
74
|
+
# create).
|
75
|
+
def types
|
76
|
+
Tk.execute(:image, :types).to_sym
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Tk
|
2
|
+
# Change a window's position in the stacking order
|
3
|
+
module Lower
|
4
|
+
def lower(below = None)
|
5
|
+
Lower.lower(self, below)
|
6
|
+
end
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
# If the +below+ argument is omitted then the command lowers window so that
|
11
|
+
# it is below all of its siblings in the stacking order (it will be obscured
|
12
|
+
# by any siblings that overlap it and will not obscure any siblings).
|
13
|
+
#
|
14
|
+
# If +below+ is specified then it must be the path name of a window that is
|
15
|
+
# either a sibling of window or the descendant of a sibling of window.
|
16
|
+
# In this case the lower command will insert window into the stacking order
|
17
|
+
# just below +below+ or the ancestor of +below+ that is a sibling of
|
18
|
+
# window); this could end up either raising or lowering window.
|
19
|
+
def lower(below = None)
|
20
|
+
Tk.execute_only(:lower, window, below)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Tk
|
2
|
+
module_function
|
3
|
+
|
4
|
+
# Pops up a message window and waits for user response.
|
5
|
+
# This procedure creates and displays a message window with an
|
6
|
+
# application-specified message, an icon and a set of buttons.
|
7
|
+
# Each of the buttons in the message window is identified by a unique symbolic
|
8
|
+
# name (see the :type options).
|
9
|
+
#
|
10
|
+
# After the message window is popped up, [message_box] waits for the user to
|
11
|
+
# select one of the buttons.
|
12
|
+
# Then it returns the symbolic name of the selected button.
|
13
|
+
#
|
14
|
+
# The following options pairs are supported:
|
15
|
+
#
|
16
|
+
# default: name
|
17
|
+
# Name gives the symbolic name of the default button for this message
|
18
|
+
# window (:ok, :cancel, and so on).
|
19
|
+
# See :type for a list of the symbolic names.
|
20
|
+
# If this option is not specified, the first button in the dialog will be
|
21
|
+
# made the default.
|
22
|
+
#
|
23
|
+
# detail: string
|
24
|
+
# Specifies an auxiliary message to the main message given by the :message
|
25
|
+
# option. Where supported by the underlying OS, the message detail will be
|
26
|
+
# presented in a less emphasized font than the main message.
|
27
|
+
#
|
28
|
+
# icon: icon_image
|
29
|
+
# Specifies an icon to display.
|
30
|
+
# icon_image must be one of the following: :error, :info, :question or
|
31
|
+
# :warning. If this option is not specified, then the info icon will be
|
32
|
+
# displayed.
|
33
|
+
#
|
34
|
+
# message: string
|
35
|
+
# Specifies the message to display in this message box.
|
36
|
+
#
|
37
|
+
# parent: window
|
38
|
+
# Makes window the logical parent of the message box.
|
39
|
+
# The message box is displayed on top of its parent window.
|
40
|
+
#
|
41
|
+
# title: string
|
42
|
+
# Specifies a string to display as the title of the message box.
|
43
|
+
# The default value is an empty string.
|
44
|
+
#
|
45
|
+
# type: predefined_type
|
46
|
+
# Arranges for a predefined set of buttons to be displayed.
|
47
|
+
#
|
48
|
+
# The following values are possible for predefined_type:
|
49
|
+
#
|
50
|
+
# :abortretryignore
|
51
|
+
# Displays three buttons whose symbolic names are :abort, :retry and :ignore.
|
52
|
+
# :ok
|
53
|
+
# Displays one button whose symbolic name is :ok.
|
54
|
+
# :okcancel
|
55
|
+
# Displays two buttons whose symbolic names are :ok and :cancel.
|
56
|
+
# :retrycancel
|
57
|
+
# Displays two buttons whose symbolic names are :retry and :cancel.
|
58
|
+
# :yesno
|
59
|
+
# Displays two buttons whose symbolic names are :yes and :no.
|
60
|
+
# :yesnocancel
|
61
|
+
# Displays three buttons whose symbolic names are :yes, :no and :cancel.
|
62
|
+
def message_box(options = None)
|
63
|
+
Tk.execute(:tk_messageBox, options.to_tcl_options?).to_sym
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Tk
|
2
|
+
# Geometry manager that packs around edges of cavity
|
3
|
+
#
|
4
|
+
# The pack command is used to communicate with the packer, a geometry manager
|
5
|
+
# that arranges the children of a parent by packing them in order around the
|
6
|
+
# edges of the parent.
|
7
|
+
module Pack
|
8
|
+
# If the first argument to pack is a window name (any value starting with
|
9
|
+
# "."), then the command is processed in the same way as [configure].
|
10
|
+
def self.pack(*args)
|
11
|
+
Tk.execute('pack', *args)
|
12
|
+
end
|
13
|
+
|
14
|
+
# The arguments consist of the names of one or more slave windows followed
|
15
|
+
# by a hash of arguments that specify how to manage the slaves.
|
16
|
+
# See THE PACKER ALGORITHM for details on how the options are used by the
|
17
|
+
# packer.
|
18
|
+
def self.configure(*arguments)
|
19
|
+
Tk.execute('pack', 'configure', *arguments)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Removes each of the +slaves+ from the packing order for its master and
|
23
|
+
# unmaps their windows.
|
24
|
+
# The +slaves+ will no longer be managed by the packer.
|
25
|
+
def self.forget(*slaves)
|
26
|
+
Tk.execute_only('pack', 'forget', *slaves)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns a hash whose elements are the current configuration state of the
|
30
|
+
# +slave+ given by in the same option-value form that might be specified
|
31
|
+
# to pack configure.
|
32
|
+
# The hash contains`in: master` where master is the +slave+'s master.
|
33
|
+
def self.info(slave)
|
34
|
+
info = Tk.execute('pack', 'info', slave)
|
35
|
+
|
36
|
+
array = info.split.each_slice(2).map{|key, value|
|
37
|
+
case key = key[1..-1].to_sym
|
38
|
+
when :expand
|
39
|
+
[key, Tk.boolean(value)]
|
40
|
+
when :ipadx, :ipady, :padx, :pady
|
41
|
+
[key, value.to_i]
|
42
|
+
when :fill, :side
|
43
|
+
[key, value.to_sym]
|
44
|
+
when :after, :anchor, :before, :in
|
45
|
+
[key, value]
|
46
|
+
else
|
47
|
+
raise "Unknown info pair: %p => %p" % [key, value]
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
51
|
+
Hash[array]
|
52
|
+
end
|
53
|
+
|
54
|
+
# If +boolean+ is true then propagation is enabled for +master+, which must
|
55
|
+
# be a window (see GEOMETRY PROPAGATION below).
|
56
|
+
# If +boolean+ is false, then propagation is disabled for +master+.
|
57
|
+
# In either of these cases nil is returned.
|
58
|
+
# If boolean is omitted then the command returns 0 or 1 to indicate whether
|
59
|
+
# propagation is currently enabled for master.
|
60
|
+
# Propagation is enabled by default.
|
61
|
+
def self.propagate(master, boolean = true)
|
62
|
+
Tk.execute_only('pack', 'propagate', master, boolean)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns a list of all of the slaves in the packing order for master. The
|
66
|
+
# order of the slaves in the list is the same as their order in the packing
|
67
|
+
# order.
|
68
|
+
def self.slaves(master)
|
69
|
+
Tk.execute('pack', 'slaves', master)
|
70
|
+
end
|
71
|
+
|
72
|
+
def pack(options = {})
|
73
|
+
Pack.pack(self, options.to_tcl_options)
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def pack_configure(options = {})
|
78
|
+
Tk.execute_only('pack', 'configure', self, options)
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
def pack_forget
|
83
|
+
Pack.forget(self)
|
84
|
+
self
|
85
|
+
end
|
86
|
+
|
87
|
+
def pack_info
|
88
|
+
Pack.info(self)
|
89
|
+
end
|
90
|
+
|
91
|
+
def pack_propagate(boolean = true)
|
92
|
+
Pack.propagate(self, boolean)
|
93
|
+
end
|
94
|
+
|
95
|
+
def pack_slaves
|
96
|
+
Pack.slaves(self)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|