tkd 1.1.14

GUI toolkit for the D programming language based on Tcl/Tk

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

#tkd GUI toolkit for the D programming language


Tkd is a fully cross-platform GUI toolkit based on Tcl/Tk. Tkd allows you to build GUI applications easily and with the knowledge of a consistent, native look and feel on every platform.

Why Tcl/Tk?

Tkd development was initiated based on the performance and uptake of the Tkinter toolkit distributed as a standard part of the Python programming language. Tkinter allows developers easy access to GUI programming with very little learning. Being the de facto GUI toolkit of Python has introduced more developers to GUI application programming and increased the popularity of the language as a whole. Tkd is an attempt to provide D with the same resource.

Supported platforms

  • Windows
  • Linux
  • Mac OSX


There is an example in this package which can be built using dub. Clone this repository and use the following command to build this example to see what's possible.

dub --config=example

The above example.


Just import the tkd.tkdapplication module and all tkd elements are publically imported.

import tkd.tkdapplication;                               // Import Tkd.

class Application : TkdApplication                       // Extend TkdApplication.
	private void exitCommand(CommandArgs args)           // Create a callback.
		this.exit();                                     // Exit the application.

	override protected void initInterface()              // Initialise user interface.
		auto frame = new Frame(2, ReliefStyle.groove)    // Create a frame.
			.pack(10);                                   // Place the frame.

		auto label = new Label(frame, "Hello World!")    // Create a label.
			.pack(10);                                   // Place the label.

		auto exitButton = new Button(frame, "Exit")      // Create a button.
			.setCommand(&this.exitCommand)               // Use the callback.
			.pack(10);                                   // Place the button.

void main(string[] args)
	auto app = new Application();                        // Create the application.;                                           // Run the application.


There is full HTML documentation within the repository inside the docs directory.

GUI elements


These windows are containers for widgets to provide a user interface to the program. Every application has at least one top level window.

WindowA window is similar to a frame except that it is created as a top level window. The primary purpose of a window is to serve as a dialog box and/or collections of widgets.

Menus allow a user to select options from a predefined list. Menus can be attached to a window (via a menu bar) or popped up independantly.

MenuBarA menubar is the bar across the top of a window holding the menu items.
MenuThe cascading menu that items are selected from. These menus can be nested as items in another.

These are the building blocks of all Tkd applications and allow the user to directly interact with your program. These are placed on windows via geometry methods.

ButtonA button widget displays a textual label and/or image, and evaluates a command when pressed.
CanvasCanvas widgets implement structured graphics. A canvas displays any number of items, which may be things like rectangles, circles, lines, and text. Items may be manipulated (e.g. moved or re-colored) and commands may be associated with items in much the same way that the bind command allows commands to be bound to widgets.
CheckButtonA checkbutton widget is used to show or change a setting. It has two states, selected and deselected. The state of the checkbutton may be linked to a value.
ComboBoxA combobox combines a text field with a pop-down list of values; the user may select the value of the text field from among the values in the list.
EntryAn entry widget displays a one-line text string and allows that string to be edited by the user.
FrameA frame widget is a container, used to group other widgets together.
LabelFrameA label frame widget is a container used to group other widgets together. It has an optional label, which may be a plain text string or another widget.
LabelA label widget displays a textual label and/or image.
MenuButtonA menu button widget displays a textual label and/or image, and displays a menu when pressed.
NoteBookA notebook widget manages a collection of panes and displays a single one at a time. Each pane is associated with a tab, which the user may select to change the currently-displayed pane.
PanedWindowA paned window widget displays a number of subwindows, stacked either vertically or horizontally. The user may adjust the relative sizes of the subwindows by dragging the sash between panes.
ProgressBarA progress bar widget shows the status of a long-running operation.
RadioButtonRadio button widgets are used in groups to show or change a set of mutually-exclusive options.
ScaleA scale widget is typically used to control the numeric value that varies uniformly over some range. A scale displays a slider that can be moved along over a trough, with the relative position of the slider over the trough indicating the value.
ScrollBarScrollbar widgets are typically linked to an associated window that displays a document of some sort, such as a file being edited or a drawing. A scrollbar displays a thumb in the middle portion of the scrollbar, whose position and size provides information about the portion of the document visible in the associated window. The thumb may be dragged by the user to control the visible region. Depending on the theme, two or more arrow buttons may also be present; these are used to scroll the visible region in discrete units.
SeparatorA separator widget displays a horizontal or vertical separator bar.
SizeGripA sizegrip widget (also known as a grow box) allows the user to resize the containing toplevel window by pressing and dragging the grip.
SpinBoxA spinbox widget is an entry widget with built-in up and down buttons that are used to either modify a numeric value or to select among a set of values.
TextA text widget displays one or more lines of text and allows that text to be edited. Text widgets support embedded widgets or embedded images.
TreeViewThe treeview widget displays a hierarchical collection of items. Each item has a textual label, an optional image, and an optional list of data values.
Geometry methods

These methods are used to place widgets onto a window.

GridGeometry method for placing this widget inside its parent using an imaginary grid. Somewhat more direct and intuitive than pack. Choose grid for tabular layouts, and when there's no good reason to choose something else.
PackGeometry method for loosely placing this widget inside its parent using a web browser model. Widgets flow around each other in the available space.
PlaceGeometry method for placing this widget inside its parent using absolute positioning.
Dialog boxes

These are pre-built dialog boxes to gather various pieces of data from a user.

Dialog boxDescription
ColorDialogPops up a dialog box for the user to select a color.
DirectoryDialogPops up a dialog box for the user to select a directory.
FontDialogPops up a dialog box for the user to select a font.
MessageDialogPops up a dialog box with a user defined message and buttons.
OpenFileDialogPops up a dialog box for the user to open a file.
SaveFileDialogPops up a dialog box for the user to save a file.


  • Tkd has been developed and tested using the latest DMD compiler.
  • It's recommended to use the dub build tool to build all Tkd projects.


Source code

Tkd requires other D source libraries to correctly use and link against pre-existing C libraries. The source dependencies are as follows:


Dub handles these automatically and during a build acquires them. While building, the tcltk repository is configured to link against the required Tcl/Tk libraries, hence they need to be installed for the application to function.


Tkd requires version 8.6 (or greater) of the Tcl/Tk libraries installed. A small exception is when creating a self-contained installation on Windows. See details below. Tcl/Tk itself requires the x11 libraries installed on Linux only.


You can copy the DLL's and the initialization script library directory into the root of the finished application. These files can be conveniently found in the dist folder within the tcktk repository. Your finished application's directory would then look something like this:

├── app.exe
├── tcl86t.dll
├── tk86t.dll
└── library
    └── *.tcl files

You can automate this process when building an application by placing the following in the application's dub.json build file. Dub version 0.9.22 or greater is required.

"copyFiles-windows": [

Alternatively, if using dub.sdl:

copyFiles \
	"$TCLTK_PACKAGE_DIR/dist/$ARCH/tcl86t.dll" \
	"$TCLTK_PACKAGE_DIR/dist/$ARCH/tk86t.dll" \
	"$TCLTK_PACKAGE_DIR/dist/library" \
Linux/Mac OSX

On Linux and Mac OSX things are a little easier as both operating systems have Tcl/Tk installed by default. If however they do not have the latest version, the libraries can be updated via their respective package managers. The linked libraries are libtcl and libtk.



The following debug flags can be passed to Tkd to help debug certain issues.


Write a log called debug.log in the current directory detailing all Tcl/Tk interaction logging all commands the Tcl interpreter is executing. (All errors are marked as WARN.)


Write all Tcl/Tk errors to stdout. This is useful to immediately be notified of interpreter errors without trawling through the debug log.



The postscript methods of this widget havn't been implemented yet due to time. This means no exporting to postscript files or printing is available from this widget. This can be added in the future if there is need.


The extended text editing functionality of this widget has not been implement because there are better, more modern editor widgets available separately. This control is not indended to be used as a fully featured text editor.

  • Gary Willoughby
1.1.14 2021-Oct-15
1.1.13 2019-Jun-13
1.1.12 2019-May-05
1.1.11 2019-May-01
1.1.10 2017-May-28
Show all 25 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 2 downloads this month

  • 1544 downloads total

Short URL: