Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "TCL-PERL 1" | |
132 | .TH TCL-PERL 1 "2000-12-30" "perl v5.8.0" "User Contributed Perl Documentation" | |
133 | .SH "NAME" | |
134 | Tcl vs perl \- very old suspect documentation on porting. | |
135 | .SH "DESCRIPTION" | |
136 | .IX Header "DESCRIPTION" | |
137 | This isn't really a .pod yet, nor is it Tcl vs perl | |
138 | it is a copy of John's comparison of Malcolm's original perl/Tk | |
139 | port with the current one. It is also out-of-date in places. | |
140 | .PP | |
141 | .Vb 1 | |
142 | \& From: john@WPI.EDU (John Stoffel ) | |
143 | .Ve | |
144 | .PP | |
145 | .Vb 5 | |
146 | \& Here are some thoughts on the new Tk extension and how I think the | |
147 | \& organization of the commands looks. Mostly, I'm happy with it, it | |
148 | \& makes some things more organized and more consistent with tcl/tk, but | |
149 | \& since the overlying language is so different, I don't think we need to | |
150 | \& follow exactly the tcl/tk model for how to call the language. | |
151 | .Ve | |
152 | .PP | |
153 | .Vb 1 | |
154 | \& The basic structure of the Tk program is: | |
155 | .Ve | |
156 | .PP | |
157 | .Vb 1 | |
158 | \& require Tk; | |
159 | .Ve | |
160 | .PP | |
161 | .Vb 1 | |
162 | \& $top = MainWindow->new(); | |
163 | .Ve | |
164 | .PP | |
165 | .Vb 3 | |
166 | \& # | |
167 | \& # create widgets | |
168 | \& # | |
169 | .Ve | |
170 | .PP | |
171 | .Vb 1 | |
172 | \& Tk::MainLoop; | |
173 | .Ve | |
174 | .PP | |
175 | .Vb 2 | |
176 | \& sub method1 { | |
177 | \& } | |
178 | .Ve | |
179 | .PP | |
180 | .Vb 2 | |
181 | \& sub methodN { | |
182 | \& } | |
183 | .Ve | |
184 | .PP | |
185 | .Vb 3 | |
186 | \& This is pretty much the same as tkperl5a5, with some cosmetic naming | |
187 | \& changes, and some more useful command name and usage changes. A quick | |
188 | \& comparison in no particular order follows: | |
189 | .Ve | |
190 | .PP | |
191 | .Vb 3 | |
192 | \& tkperl5a5 Tk | |
193 | \& ------------------------------- ----------------------------------- | |
194 | \& $top=tkinit(name,display,sync); $top=MainWindow->new(); | |
195 | .Ve | |
196 | .PP | |
197 | .Vb 1 | |
198 | \& tkpack $w, ... ; $w->pack(...) | |
199 | .Ve | |
200 | .PP | |
201 | .Vb 1 | |
202 | \& $w = Class::new($top, ...); $w = $top->Class(...); | |
203 | .Ve | |
204 | .PP | |
205 | .Vb 1 | |
206 | \& tkmainloop; Tk::MainLoop; | |
207 | .Ve | |
208 | .PP | |
209 | .Vb 1 | |
210 | \& tkbind($w,"<key>",sub); $w->bind("<key>",sub); | |
211 | .Ve | |
212 | .PP | |
213 | .Vb 1 | |
214 | \& tkdelete($w, ...); $w->delete(...); | |
215 | .Ve | |
216 | .PP | |
217 | .Vb 1 | |
218 | \& $w->scanmark(...); $w->scan("mark", ...); | |
219 | .Ve | |
220 | .PP | |
221 | .Vb 1 | |
222 | \& $w->scandragto(...); $w->scan("dragto", ...); | |
223 | .Ve | |
224 | .PP | |
225 | .Vb 1 | |
226 | \& $w->tkselect(); $w->Select(); | |
227 | .Ve | |
228 | .PP | |
229 | .Vb 1 | |
230 | \& $w->selectadjust(...); $w->selection("adjust", ...); | |
231 | .Ve | |
232 | .PP | |
233 | .Vb 1 | |
234 | \& $w->selectto(...); $w->selection("to", ...); | |
235 | .Ve | |
236 | .PP | |
237 | .Vb 1 | |
238 | \& $w->selectfrom(...); $w->selection("from", ...); | |
239 | .Ve | |
240 | .PP | |
241 | .Vb 1 | |
242 | \& $w->tkindex(...); $w->index(...); | |
243 | .Ve | |
244 | .PP | |
245 | .Vb 1 | |
246 | \& tclcmd("xxx",...); &Tk::xxx(...) # all Tk commands, but no Tcl at all | |
247 | .Ve | |
248 | .PP | |
249 | .Vb 1 | |
250 | \& tclcmd("winfo", xxx, $w, ...); $w->xxx(...); | |
251 | .Ve | |
252 | .PP | |
253 | .Vb 1 | |
254 | \& $w->mark(...); | |
255 | .Ve | |
256 | .PP | |
257 | .Vb 1 | |
258 | \& $w->tag(...); | |
259 | .Ve | |
260 | .PP | |
261 | .Vb 1 | |
262 | \& $w->grabstatus(); $w->grab("status"); | |
263 | .Ve | |
264 | .PP | |
265 | .Vb 1 | |
266 | \& $w->grabrelease(...); $w->grab("release", ...); | |
267 | .Ve | |
268 | .PP | |
269 | .Vb 1 | |
270 | \& focus($w); $w->focus; | |
271 | .Ve | |
272 | .PP | |
273 | .Vb 1 | |
274 | \& update(); Tk->update(); | |
275 | .Ve | |
276 | .PP | |
277 | .Vb 1 | |
278 | \& idletasks(); Tk->update("idletasks"); | |
279 | .Ve | |
280 | .PP | |
281 | .Vb 1 | |
282 | \& wm("cmd",$w, ...); $w->cmd(...); | |
283 | .Ve | |
284 | .PP | |
285 | .Vb 1 | |
286 | \& destroy($w); $w->destroy(); | |
287 | .Ve | |
288 | .PP | |
289 | .Vb 2 | |
290 | \& Tk::option(...); | |
291 | \& $w->OptionGet(name,Class) | |
292 | .Ve | |
293 | .PP | |
294 | .Vb 1 | |
295 | \& $w->place(...) | |
296 | .Ve | |
297 | .PP | |
298 | .Vb 1 | |
299 | \& Tk::property(...); | |
300 | .Ve | |
301 | .PP | |
302 | .Vb 1 | |
303 | \& $w = Entry::new($parent,...) | |
304 | .Ve | |
305 | .PP | |
306 | .Vb 1 | |
307 | \& is now | |
308 | .Ve | |
309 | .PP | |
310 | .Vb 1 | |
311 | \& $w = $parent->Entry(...) | |
312 | .Ve | |
313 | .PP | |
314 | .Vb 1 | |
315 | \& As this allows new to be inherited from a Window class. | |
316 | .Ve | |
317 | .PP | |
318 | .Vb 1 | |
319 | \& -method=>x,-slave=>y | |
320 | .Ve | |
321 | .PP | |
322 | .Vb 1 | |
323 | \& is now | |
324 | .Ve | |
325 | .PP | |
326 | .Vb 1 | |
327 | \& -command => [x,y] | |
328 | .Ve | |
329 | .PP | |
330 | .Vb 2 | |
331 | \& 1st element of list is treated as "method" if y is an object reference. | |
332 | \& (You can have -command => [a,b,c,d,e] too; b..e get passed as args). | |
333 | .Ve | |
334 | .PP | |
335 | .Vb 3 | |
336 | \& Object references are now hashes rather than scalars and there | |
337 | \& is only ever one such per window. The Tcl_CmdInfo and PathName | |
338 | \& are entries in the hash. | |
339 | .Ve | |
340 | .PP | |
341 | .Vb 2 | |
342 | \& (This allows derived classes to | |
343 | \& re-bless the hash and keep their on stuff in it too.) | |
344 | .Ve | |
345 | .PP | |
346 | .Vb 4 | |
347 | \& Tk's "Tcl_Interp" is in fact a ref to "." window. | |
348 | \& You can find all the Tk windows descended from it as their object | |
349 | \& references get added (by PathName) into this hash. | |
350 | \& $w->MainWindow returns this hash from any window. | |
351 | .Ve | |
352 | .PP | |
353 | .Vb 2 | |
354 | \& I think that it should extend to multiple tkinits / Tk->news | |
355 | \& with different Display's - if Tk code does. | |
356 | .Ve | |
357 | .PP | |
358 | .Vb 2 | |
359 | \& Finally "bind" passes window as "extra" (or only) | |
360 | \& argument. Thus | |
361 | .Ve | |
362 | .PP | |
363 | .Vb 1 | |
364 | \& Tk::Button->bind(<Any-Enter>,"Enter"); | |
365 | .Ve | |
366 | .PP | |
367 | .Vb 4 | |
368 | \& Binds Enter events to Tk::Button::Enter by default | |
369 | \& but gets called as $w->Enter so derived class of Button can just | |
370 | \& define its own Enter method. &EvWref and associated globals and race | |
371 | \& conditions are no longer needed. | |
372 | .Ve | |
373 | .PP | |
374 | .Vb 2 | |
375 | \& One thing to beware of : commands bound to events with $widget->bind | |
376 | \& follow same pattern, but get passed extra args : | |
377 | .Ve | |
378 | .PP | |
379 | .Vb 1 | |
380 | \& $widget->bind(<Any-1>,[sub {print shift}, $one, $two ]); | |
381 | .Ve | |
382 | .PP | |
383 | .Vb 1 | |
384 | \& When sub gets called it has : | |
385 | .Ve | |
386 | .PP | |
387 | .Vb 1 | |
388 | \& $widget $one $two | |
389 | .Ve | |
390 | .PP | |
391 | .Vb 1 | |
392 | \& passed. | |
393 | .Ve | |
394 | .PP | |
395 | .Vb 2 | |
396 | \& 1st extra arg is reference to the per-widget hash that serves as the | |
397 | \& perl object for the widget. | |
398 | .Ve | |
399 | .PP | |
400 | .Vb 2 | |
401 | \& Every time an XEvent a reference to a special class is placed | |
402 | \& in the widget hash. It can be retrieved by $w->XEvent method. | |
403 | .Ve | |
404 | .PP | |
405 | .Vb 2 | |
406 | \& The methods of the XEvent class are the | |
407 | \& Tcl/Tk % special characters. | |
408 | .Ve | |
409 | .PP | |
410 | .Vb 1 | |
411 | \& Thus: | |
412 | .Ve | |
413 | .PP | |
414 | .Vb 6 | |
415 | \& $widget->bind(<Any-KeyPress>, | |
416 | \& sub { | |
417 | \& my $w = shift; | |
418 | \& my $e = $w->XEvent; | |
419 | \& print $w->PathName," ",$e->A," pressed ,$e->xy,"\en"); | |
420 | \& }); | |
421 | .Ve | |
422 | .PP | |
423 | .Vb 2 | |
424 | \& XEvent->xy is a special case which returns "@" . $e->x . "," . $e->y | |
425 | \& which is common in Text package. | |
426 | .Ve | |
427 | .PP | |
428 | .Vb 2 | |
429 | \& Because of passing a blessed widget hash to "bound" subs they can be | |
430 | \& bound to (possibly inherited) methods of the widget's class: | |
431 | .Ve | |
432 | .PP | |
433 | .Vb 1 | |
434 | \& Class->bind(<Any-Down>,Down); | |
435 | .Ve | |
436 | .PP | |
437 | .Vb 5 | |
438 | \& sub Class::Down | |
439 | \& { | |
440 | \& my $w = shift; | |
441 | \& # handle down arrow | |
442 | \& } | |
443 | .Ve | |
444 | .PP | |
445 | .Vb 1 | |
446 | \& Also: | |
447 | .Ve | |
448 | .PP | |
449 | .Vb 3 | |
450 | \& -command and friends can take a list the 1st element can be a ref to | |
451 | \& as sub or a method name. Remaining elements are passed as args to the | |
452 | \& sub at "invoke" time. Thus : | |
453 | .Ve | |
454 | .PP | |
455 | .Vb 1 | |
456 | \& $b= $w->Button(blah blah, '-command' => [sub{print shift} , $fred ]); | |
457 | .Ve | |
458 | .PP | |
459 | .Vb 1 | |
460 | \& Should do the trick, provided $fred is defined at time of button creation. | |
461 | .Ve | |
462 | .PP | |
463 | .Vb 3 | |
464 | \& Thus 1st element of list is equivalent to Malcolm's -method and second | |
465 | \& would be his -slave. Any further elements are a bonus and avoid | |
466 | \& having to pass ref to an array/hash as a slave. | |
467 | .Ve |