Name

class

class className definition

Define a new class named className. The properties of the class are described by definition, a list containing any of the following Tcl statements:

inherit [baseClass...]

Cause class to inherit characteristics from one or more existing base classes.

constructor args [init] body

Define the argument list and body for the constructor method called when an object is created. Can optionally specify init statement to pass parameters to base class constructors. Constructor always returns the class name.

destructor body

Define the code body for the destructor method called when an object is deleted.

method name [args] [body]

Declare a method named name. Can define the argument list args and code body body. The body command can define or redefine the method body outside of the class definition.

proc name [args] [body]

Declare a procedure named name. Can define the argument list args and code body body. The body command can define or redefine the body outside of the class definition.

variable varName [init] [config]

Define an object-specific variable named varName. Optional string init supplies an initial value for the variable when the object is created. Optional script config specifies code to be executed whenever a public variable is modified using the configure command.

common varName [init]

Declare a common variable (shared by all class objects) named varName. Optional string init supplies a value for the variable to be initialized with whenever a new object is ...

Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.