tcl/tk 指导老师:肖炳甲 学生:林冬涛 tool command language toolkit

14
TCL/TK 指指指指 指指指 指指 指指指 tool command language toolkit

Upload: jessica-bruce

Post on 16-Dec-2015

491 views

Category:

Documents


8 download

TRANSCRIPT

TCL/TK

指导老师:肖炳甲学生:林冬涛

tool command languagetoolkit

Tcl was designed from the outset as a flexible language with a small core, that could be adapted in ways the original authors couldn't have foreseen.

Tcl truly is a general purpose language. 1.Web ApplicationsTcl, being a dynamic, string oriented language, is a great match for web applications.

2. Desktop GUI Applications Tk helped establish Tcl's popularity as the only sane way to write GUI applicationsunder Unix and X11. People found Tcl's dynamic approach a natural fit for GUI's,making GUI development much easier and faster than with lower-level C and C++oriented toolkits. 3. Testing and AutomationLong before "test-driven development" had become a buzzword, Tcl had been wellestablished as a testing powerhouse, leveraging its ability to easily interface with othersoftware and hardware.4. Databases5. Embedded Development

Tcl and Tk Applications

Who uses Tcl and Tk?

“We use a Tcl interpreter in each of the hundreds of back-end host processes that provide services to AOL's Digital City's 3 million monthly visitors. Tcl greatly simplifies the task of configuring these services and managing them remotely. In addition, we are using Tcl to create high performance, completely dynamic, database driven Web sites. Every Web page in the AOL's Digital City network is generated by an embedded Tcl script.“Jim Davidson, Chief Technology Officer AOL's Digital City, Inc.

It's used by elite hackers, application programmers, system administrators, and scientists.Tcl runs the operator interface of a Shell Oil drilling rig, runs the NBC network control system 24x7, has been used to program the Hubble Space Telescope and prototype the Mars Pathfinder, is hiding in every Tivo box and many Oracle products. Don't forget companies like Pixar, Motorola, IBM, Sybase, Nortel, Raytheon...

Features and Benefits1.Rapid developmentIn many cases you can implement applications 5-10x faster with Tcl than with otherlanguages, especially if the application involves GUIs, string-handling, or integration.2.Graphical user interfacesWith its Tk toolkit, Tcl provides facilities for creating GUIs that are incredibly simple

yetremarkably powerful. 3. Cross-platform applications4. Easy to learnTcl is a very simple language. Experienced programmers can learn Tcl and producetheir first interesting application in just a few hours or days.5.Mature but Evolving6.Extend, Embed and IntegrateTcl is unmatched when it comes to integrating with other software. You can easilyinclude Tcl as an embedded scripting language in an application, or make existing C,C++, or Java code look like it wasbuilt right into Tcl.7.Deployment

8. Network-aware applications

Comparison Dynamic Languages vs System Programming Languages

TclPython

JavaC++

complex data structures and algorithms quickly manipulate data less rigidly defined, and determined at runtimetypically interpreted, highly introspective, and emphasize integration and extension to add new capabilities. programs are shorter, much faster to develop

Choosing a Dynamic Language Why Tcl?•a rich deployment model that is second to none, including support for protecting commercial applications •Tk is designed explicitly for Tcl; while it works well with other languages, the API is both more natural, more current, and better documented •built-in event-driven programming model for networks, GUI's, and more •supports a wide variety of programming styles, including procedural, several styles of object-oriented, and others, and is great for building domain specific languages •excellent internationalization support

Basic syntaxcommand arg1 arg2 arg3

Where do commands come from? Provided by Tcl interpreter itself Tcl provides APIs that allow you to create a new command by writing a command procedure in C/C++ Consisits of procedures created with proc command

Tk Conceptswidgets, geometry management, and event handling

Window HierarchyThe root of the hierarchy, the toplevel widget that Tk automatically creates, is named simply "." (dot). The frame, which was a child of the root, was named ".c". The labels ,buttons and so on are children of frame

grid [ttk::label .c.flbl -text "feet"] -column 3 -row 1 -sticky w

grid [ttk::label .l -text "Starting..."] bind .l <Enter> {.l configure -text "Moved mouse inside"}

Basic Widgets

The Grid Geometry Manager

Grid is one of several geometry managers available in Tk, "pack" is also quite powerful,but harder to use and understand; "place" gives you complete control of positioningeach element; we'll see even widgets like paned windows, notebooks, canvas and textcan act as geometry managers.

grid .c.namelbl -column 3 -row 0 -columnspan 2

Tree

A treeview widget can display and allow browsingthrough a hierarchy of items, and can show one ormore attributes of each item as columns to the right ofthe tree.

ttk::treeview .tree

ET:EPICS TCL/TK Interface

The BLT Toolkit is an extension to Tcl and Tk. It adds newcommands and widgets to the Tcl interpreter. Includedwidgets are 2D graph, barchart, stripchart, tab notebook, and

tree viewer.

tcl command (pv) and command operations (link, linkw, get, getw,put, putq, mon, umon, cmon, info, stat, vset, vset, and vmap) which are used to interface with EPICS.

The tcl package libraries upon which et is built include tk and blt.

• caTCL• caTCL requires that the X11, Tk/Tcl, DP, and

BLT header files and libraries be available and that the X11, TK, TCL, and BLT settings in CONFIG_SITE.<host_arch> be set correctly.