没有合适的资源?快使用搜索试试~ 我知道了~
首页Practical Programming in Tcl and Tk: 英语教程
Practical Programming in Tcl and Tk: 英语教程
5星 · 超过95%的资源 需积分: 10 2 下载量 68 浏览量
更新于2024-07-29
收藏 1.08MB PDF 举报
"tcl_tk教程英语版"
这篇资源是一个英语版的Tcl/Tk教程,由Brent Welch编写,并针对Tcl 7.4和Tk 4.0进行了更新。尽管它是一份未完成的草稿,缺少部分章节且索引不全,但作者鼓励用户通过电子邮件提供反馈。该教程的正式出版版本由Prentice Hall发行,具有ISBN 0-13-182007-9。如果想要获取完整版本,可以访问提供的链接或购买图书。
教程的内容涵盖了Tcl的基础知识,包括如何开始、Tcl命令、Hello World程序、变量、命令替换、数学表达式、反斜杠替换、双引号、过程、while循环示例、命令分组和替换、变量替换的更多细节、替换和分组的总结、以及一些细微的要点。其中提到了注释、命令行参数、反斜杠序列、算术运算符和内置命令等主题。
1. Tcl基础知识:这部分介绍了Tcl语言的基础,包括如何启动和使用Tcl环境。
2. Tcl命令:详述了Tcl中的各种内建命令及其用法。
3. Hello World:通过一个简单的程序展示Tcl的基本语法。
4. 变量:讨论了Tcl中的变量概念,包括变量的声明、赋值和引用。
5. 命令替换:解释了如何在命令中使用其他命令的输出。
6. 数学表达式:展示了Tcl如何处理数学计算。
7. 反斜杠替换:说明了反斜杠在字符串中的特殊含义,如转义字符。
8. 双引号:讨论了双引号在字符串中的作用,如保留特殊字符。
9. 过程(Procedures):介绍如何定义和调用自定义函数。
10. While循环示例:展示了如何使用while循环结构来控制程序流程。
11. 命令分组与替换:解释了如何通过括号进行命令分组,以及如何在命令替换中使用括号。
12. 更多关于变量替换:深入探讨变量在字符串中的替换机制。
13. 细节:包括注释的使用和一些高级技巧。
14. 命令行参数:讲解如何处理和解析程序的输入参数。
15. 反斜杠序列:列出了一些常见的反斜杠转义序列。
16. 算术运算符:列出了Tcl支持的数学运算符,如加减乘除等。
17. 内置命令:提及了一些Tcl的内置命令,这些命令提供了基本的控制结构和功能。
这个教程对于有一定编程经验的开发者来说是很有价值的资源,但对于初学者可能会有些挑战。尽管存在一些缺失的部分,但它仍然能够提供对Tcl/Tk编程语言的深入了解。为了获取完整的学习体验,建议读者同时参考正式出版的书籍。
xiv Chap.
Created: May 9, 1994 —bookTOC.doc—Copyright Prentice Hall—DRAFT: 1/13/95
Tcl applications ..................................................407
33. Porting to Tk 4.0 .........................................409
wish .........................................................................409
Obsolete Features ....................................................409
The cget Operation ...................................................410
Input Focus Highlight ..............................................410
Bindings ..................................................................410
Scrollbar Interface ....................................................411
Pack info ..................................................................411
Focus .......................................................................411
Send ........................................................................412
Internal Button Padding ...........................................412
Radio Buttons ..........................................................412
Entry Widget ............................................................412
Menus ......................................................................413
Listboxes ..................................................................413
No geometry Attribute ..............................................413
Text Widget ..............................................................413
Canvas scrollincrement ............................................414
The Selection ...........................................................414
Color Attributes .......................................................414
The bell Command ...................................................415
List of Examples 0
10Tcl Fundamentals..........................................................................................................................................1
1.1 The “Hello, World!” example. .......................................................3
1.2 Tcl variables. ..............................................................................3
1.3 Command substitution. ..............................................................4
1.4 Simple arithmetic........................................................................5
1.5 Nested commands.......................................................................5
1.6 Built-in math functions...............................................................5
1.7 Controlling precision with tcl_precision.......................................5
1.8 Quoting special characters with backslash..................................6
1.9 Continuing long lines with backslashes.......................................6
1.10 Grouping with double quotes allows substitutions. .....................7
1.11 Defining a procedure...................................................................8
1.12 A loop that multiplies the numbers from 1 to 10. ........................9
1.13 Embedded command and variable substitution.........................10
1.14 Embedded variable references...................................................11
20Strings and Pattern Matching......................................................................................................................19
2.1 Comparing strings. ...................................................................21
2.2 Regular expression to parse the DISPLAY environment variable. .27
30Tcl Data Structures .....................................................................................................................................29
3.1 Using set to return a variable value...........................................30
3.2 Using info to determine if a variable exists. ..............................30
3.3 Constructing a list with the list command...............................32
3.4 Using lappend to add elements to a list. ....................................32
3.5 Using concat to splice together lists. .........................................33
3.6 Double quotes compared to the list command.........................33
3.7 Modifying lists with linsert and lreplace.................................34
3.8 Deleting a list element by value.................................................34
3.9 Sorting a list using a comparison function. ...............................35
3.10 Use split to turn input data into Tcl lists...................................35
3.11 Using arrays. ............................................................................36
3.12 What if the name of the array is in a variable. ...........................37
3.13 Converting from an array to a list..............................................38
3.14 printenv prints the environment variable values. ......................39
3.15 Tracing variables.......................................................................40
3.16 Creating array elements with array traces.................................40
40Control Flow Commands .............................................................................................................................41
4.1 A conditional if-then-else command......................................42
4.2 Chained conditional with elseif. ..............................................42
4.3 Using switch for an exact match. ..............................................43
4.4 Using switch with substitutions in the patterns. .......................44
4.5 Using switch with all pattern body pairs grouped with quotes. ..44
4.6 Looping with foreach. ...............................................................44
4.7 Parsing command line arguments. ............................................45
4.8 Using list with foreach............................................................45
xvi
Created: September 9, 1994 —bookLOX.doc—Copyright Prentice Hall—DRAFT: 1/13/95
4.9 A while loop to read standard input..........................................46
4.10 A for loop.................................................................................46
4.11 A standard catch phrase...........................................................47
4.12 A longer catch phrase. ..............................................................47
4.13 The results of error with no info argument. ..............................48
4.14 Preserving errorInfo when calling error...................................48
4.15 Specifying errorinfo with return..............................................49
50Procedures and Scope................................................................................................................................. 51
5.1 Default parameter values..........................................................52
5.2 Variable number of arguments..................................................52
5.3 Variable scope and Tcl procedures............................................53
5.4 A random number generator.....................................................54
5.5 Using arrays for global state. ....................................................55
5.6 Print by name...........................................................................56
5.7 Improved incr procedure. .........................................................56
5.8 Using an array to implement a stack.........................................56
60Eval............................................................................................................................................................ 59
6.1 Using list to construct commands...........................................60
6.2 Using eval with $args...............................................................61
70Working with UNIX..................................................................................................................................... 65
7.1 Using exec on a process pipeline...............................................66
7.2 A procedure to compare file modify times..................................68
7.3 Creating a directory recusively..................................................69
7.4 Determining if pathnames reference the same file. ....................69
7.5 Opening a file for writing...........................................................70
7.6 Opening a file using the POSIX access flags................................71
7.7 A more careful use of open. .......................................................71
7.8 Opening a process pipeline. ......................................................72
7.9 Prompting for input. .................................................................72
7.10 A read loop using gets. .............................................................73
7.11 A read loop using read and split..............................................73
7.12 Finding a file by name...............................................................74
80Reflection and Debugging ........................................................................................................................... 77
8.1 Printing a procedure definition..................................................79
8.2 Getting a trace of the Tcl call stack. ..........................................80
8.3 Interactive history usage..........................................................82
8.4 Implementing special history syntax. ........................................83
8.5 A Debug procedure. ..................................................................83
90Script Libraries........................................................................................................................................... 89
9.1 Maintaining a tclIndex file. ......................................................90
9.2 Loading a tclIndex file..............................................................91
100Tk Fundamentals...................................................................................................................................... 95
10.1 “Hello, World!” Tk program........................................................96
110Tk by Example........................................................................................................................................ 103
11.1 Logging the output of a UNIX program. ....................................104
11.2 A browser for the code examples in the book...........................109
11.3 A Tcl shell in a text widget. .....................................................113
120The Pack Geometry Manager................................................................................................................... 115
xvii
Created: September 9, 1994 —bookLOX.doc—Copyright Prentice Hall—DRAFT: 1/13/95
12.1 Two frames packed inside the main frame...............................116
12.2 Turning off geometry propagation............................................116
12.3 A horizontal stack inside a vertical stack.................................117
12.4 Even more nesting of horizontal and vertical stacks. ...............117
12.5 Mixing bottom and right packing sides....................................118
12.6 Filling the display into extra packing space. ...........................119
12.7 Using horizontal fill in a menubar...........................................120
12.8 The effects of internal padding (-ipady)....................................122
12.9 Button padding vs. packer padding.........................................122
12.10 The look of a default button. ...................................................123
12.11 Resizing without the expand option.........................................124
12.12 Resizing with expand turned on. .............................................124
12.13 More than one expanding widget.............................................125
12.14 Setup for anchor experiments. ................................................125
12.15 The effects of non-center anchors............................................126
12.16 Animating the packing anchors...............................................126
12.17 Controlling the packing order..................................................127
12.18 Packing into other relatives.....................................................128
130Binding Commands to X Events ..............................................................................................................133
13.1 The binding hierarchy.............................................................134
13.2 Output from the UNIX xmodmap program. ...............................140
13.3 Emacs-like binding convention for Meta and Escape. ..............141
140Buttons and Menus.................................................................................................................................145
14.1 A troublesome button command. ............................................146
14.2 Fixing up the troublesome situation........................................147
14.3 A button associated with a Tcl procedure. ...............................148
14.4 Radio and Check buttons........................................................150
14.5 Acommand on a radiobutton or checkbutton...........................151
14.6 A menu sampler........................................................................154
14.7 A simple menu-by-name package............................................156
14.8 Adding menu entries...............................................................157
14.9 A wrapper for cascade entries. ................................................158
14.10 Using the basic menu package................................................158
14.11 Keeping the accelerator display up-to-date..............................158
150Simple Tk Widgets...................................................................................................................................163
15.1 A label that displays different strings. ....................................165
15.2 The message widget formats long lines of text...........................167
15.3 Controlling the text layout in a message widget.......................168
15.4 A scale widget. .......................................................................169
15.5 A text widget and two scrollbars.............................................173
160Entry and Listbox Widgets.......................................................................................................................177
16.1 A command, a label and an entry. .........................................179
16.2 A listbox with scrollbars. .......................................................183
16.3 A listbox with scrollbars and better alignment. ......................184
16.4 Choosing items from a listbox ............................ 188
170Focus, Grabs, and Dialogs.......................................................................................................................195
17.1 Setting focus-follows-mouse input focus model. ......................196
xviii
Created: September 9, 1994 —bookLOX.doc—Copyright Prentice Hall—DRAFT: 1/13/95
17.2 A simple dialog. ......................................................................199
17.3 A feedback procedure..............................................................200
17.4 A file selection dialog. .............................................................201
17.5 Listing a directory for fileselect................................................204
17.6 Accepting a file name..............................................................206
17.7 Simple support routines. ........................................................207
17.8 File name completion..............................................................208
180The text Widget....................................................................................................................................... 211
18.1 Tag configurations for basic character styles...........................216
18.2 Line spacing and justification in the text widget.....................217
18.3 An active text button..............................................................219
18.4 Delayed creation of embedded widgets. ...................................221
190The canvas Widget.................................................................................................................................. 227
19.1 The canvas Hello, World! example. ..........................................227
19.2 A double slider canvas example...............................................229
19.3 Moving the markers for the double-slider................................231
19.4 A large scrollable canvas. ........................................................233
19.5 Canvas arc items....................................................................234
19.6 Canvas bitmap items. ..............................................................235
19.7 Canvas image items. ................................................................236
19.8 A canvas stroke drawing example............................................237
19.9 Canvas oval items ..................................................................238
19.10 Canvas polygon items. ............................................................239
19.11 Dragging out a box. ................................................................240
19.12 Simple edit bindings for canvas text items. .............................242
19.13 Using a canvas to scroll a set of widgets. .................................244
19.14 Generating postscript from a canvas. ......................................249
200Selections and the Clipboard................................................................................................................... 253
20.1 Paste the PRIMARY or CLIPBOARD selection.................................253
20.2 A selection handler for canvas widgets.....................................256
210Callbacks and Handlers.......................................................................................................................... 259
21.1 A read event file handler. ........................................................261
21.2 The sender application............................................................262
21.3 Using the sender application...................................................264
21.4 Hooking the browser to an eval server. ...................................266
21.5 Making the shell into an eval server. ......................................267
220Tk Widget Attributes............................................................................................................................... 269
22.1 Equal-sized labels...................................................................272
22.2 3D relief sampler. ...................................................................273
22.3 Borders and padding. .............................................................275
230Color, Images, and Cursors..................................................................................................................... 277
23.1 Resources for reverse video.....................................................277
23.2 Computing a darker color .......................................................279
23.3 Specifying an image attribute for a widget...............................281
23.4 Specifying a bitmap for a widget..............................................282
23.5 The built-in bitmaps ...............................................................282
240Fonts and Text Attributes ....................................................................................................................... 289
剩余454页未读,继续阅读
2008-06-26 上传
2009-04-03 上传
2024-12-25 上传
lumiereaa
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Android应用源码之写的google map api 应用.zip项目安卓应用源码下载
- AdvExpFig:导出 MATLAB 图-matlab开发
- SuperChangelog:超级变更日志插件的源代码
- death_calc_version2
- hw_python_oop
- LX-PWM,ev3程序怎么看c语言源码,c语言程序
- material-typeahead-sample
- 基于Linux、QT、C++的“别踩白块儿”小游戏
- physx-js:PhysX for JavaScript
- 提取均值信号特征的matlab代码-First_unofficial_entry_2021:First_unofficial_entry_20
- Siege_solution_website
- ecf-2021-jd
- number.github.io:通过Szymon Rutyna
- Kinesys-RenPy-Practice:RenPy制作游戏
- Ad,c语言源码反码补码转换代码,c语言程序
- vgrid:具有魔术媒体查询混合功能的可变SCSS网格系统
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功