[incr Tcl]



incr Tcl is an OO system for Tcl. The name is a play on C, and incr Tcl provides a similar object model, including multiple inheritance, and public and private classes and variables. The name is often written as “itcl” as that contains no metacharacters (i.e., space or brackets). You can use Tcl commands in TPC. Use these commands for working with variables, manipulating strings, arithmetic operations, and more. This section describes how to use the most common commands in TPC. For all Tcl commands, see Tcl commands. Variable commands Set. Read and write variables. A simple class in incr-tcl - Tcl example. For 2021 - online Python 3 training - see. Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7. See also the old incr Tcl home page. incr Tcl project resources at SourceForge: File Distributions; Bug Database; Patch Manager; Browse CVS Repository. Tcl Developer Xchange This is the primary site for Tcl users. There is lots of information here, and this is the primary site to get all the Tcl/Tk releases. A lot of Tcl discussion also.

itcl manual page - [incr Tcl]

Tcl8.6.10/Tk8.6.10 Documentation>[incr Tcl] Package Commands, version 4.2.0> itcl

[incr

Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

NAME

itcl — object-oriented extensions to TclTcl]

Incr Command In Tcl

DESCRIPTION

Incr Tcl

[incr Tcl] provides object-oriented extensions to Tcl, much asC++ provides object-oriented extensions to C. The emphasis of thiswork, however, is not to create a whiz-bang object-orientedprogramming environment. Rather, it is to support more structuredprogramming practices in Tcl without changing the flavor of the language.More than anything else, [incr Tcl] provides a means ofencapsulating related procedures together with their shared datain a namespace that is hidden from the outside world.It encourages better programming by promoting the object-oriented'library' mindset. It also allows for code re-use through inheritance.

CLASSES

The fundamental construct in [incr Tcl] is the class definition.Each class acts as a template for actual objects that can be created.Each object has its own unique bundle of data, which contains instancesof the 'variables' defined in the class. Special procedures called'methods' are used to manipulate individual objects. Methods are justlike the operations that are used to manipulate Tk widgets. The'button' widget, for example, has methods such as 'flash' and'invoke' that cause a particular button to blink and invoke its command.

Within the body of a method, the 'variables' defined in the classare automatically available. They need not be declared with anythinglike the global command. Within another class method, a methodcan be invoked like any other command-simply by using its name.From any other context, the method name must be prefaced by an objectname, which provides a context for the data that the method can access.

Each class has its own namespace containing things that are commonto all objects which belong to the class. For example, 'common' datamembers are shared by all objects in the class. They are globalvariables that exist in the class namespace, but since they areincluded in the class definition, they need not be declared usingthe global command; they are automatically available to anycode executing in the class context. A class can also createordinary global variables, but these must be declared using theglobal command each time they are used.

Classes can also have ordinary procedures declared as 'procs'.Within another class method or proc, a proc can be invoked likeany other command-simply by using its name. From any other context,the procedure name should be qualified with the class namespacelike 'className::proc'. Class procs execute in theclass context, and therefore have automatic access to all 'common'data members. However, they cannot access object-specific 'variables',since they are invoked without reference to any specific object.They are usually used to perform generic operations which affectall objects belonging to the class.

Each of the elements in a class can be declared 'public', 'protected'or 'private'. Public elements can be accessed by the class, byderived classes (other classes that inherit this class), and byexternal clients that use the class. Protected elements can beaccessed by the class, and by derived classes. Private elementsare only accessible in the class where they are defined.

The 'public' elements within a class define its interface to theexternal world. Public methods define the operations that canbe used to manipulate an object. Public variables are recognizedas configuration options by the 'configure' and 'cget' methodsthat are built into each class. The public interface sayswhat an object will do but not how it will do it.Protected and private members, along with the bodies of classmethods and procs, provide the implementation details. Insulatingthe application developer from these details leaves the class designerfree to change them at any time, without warning, and without affectingprograms that rely on the class. It is precisely this encapsulationthat makes object-oriented programs easier to understand and maintain.

Incr Tcl Tutorial

The fact that [incr Tcl] objects look like Tk widgets isno accident. [incr Tcl] was designed this way, to blendnaturally into a Tcl/Tk application. But [incr Tcl]extends the Tk paradigm from being merely object-based to beingfully object-oriented. An object-oriented system supportsinheritance, allowing classes to share common behaviors byinheriting them from an ancestor or base class. Having a baseclass as a common abstraction allows a programmer to treatrelated classes in a similar manner. For example, a toasterand a blender perform different (specialized) functions, butboth share the abstraction of being appliances. By abstractingcommon behaviors into a base class, code can be shared ratherthan copied. The resulting application is easier tounderstand and maintain, and derived classes (e.g., specializedappliances) can be added or removed more easily.

This description was merely a brief overview of object-orientedprogramming and [incr Tcl]. A more tutorial introduction ispresented in the paper included with this distribution. See theclass command for more details on creating and using classes.

NAMESPACES

[incr Tcl] now includes a complete namespace facility.A namespace is a collection of commands and global variables thatis kept apart from the usual global scope. This allows Tcl codelibraries to be packaged in a well-defined manner, and preventsunwanted interactions with other libraries. A namespace can alsohave child namespaces within it, so one library can contain itsown private copy of many other libraries. A namespace can alsobe used to wrap up a group of related classes. The global scope(named '::') is the root namespace for an interpreter; allother namespaces are contained within it.

Incr Tcl Language

Incr tcl examples

See the namespace command for details on creating andusing namespaces.

Incr Tcl Example

MEGA-WIDGETS

Incr Tcl Examples

Mega-widgets are high-level widgets that are constructed usingTk widgets as component parts, usually without any C code. Afileselectionbox, for example, may have a few listboxes, someentry widgets and some control buttons. These individual widgetsare put together in a way that makes them act like one bigwidget.

[incr Tk] is a framework for building mega-widgets. Ituses [incr Tcl] to support the object paradigm, and addsbase classes which provide default widget behaviors. See theitk man page for more details.

[incr Widgets] is a library of mega-widgets built using[incr Tk]. It contains more than 30 different widgetclasses that can be used right out of the box to build Tcl/Tkapplications. Each widget class has its own man page describingthe features available.

KEYWORDS

Tcl incr float

Incr Tcl Loop

class, object, object-oriented, namespace, mega-widget