SkillAgentSearch skills...

Tkd

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

Install / Use

/learn @nomad-software/Tkd
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

#tkd GUI toolkit for the D programming language


Overview

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

Example

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.

Usage

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.
	app.run();                                           // Run the application.
}

Documentation

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

GUI elements

Windows

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

| Window | Description | | :----- | :---------- | | Window | A 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

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.

| Menu | Description | | :----- | :---------- | | MenuBar | A menubar is the bar across the top of a window holding the menu items. | | Menu | The cascading menu that items are selected from. These menus can be nested as items in another.|

Widgets

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.

| Widget | Description | | :----- | :---------- | | Button | A button widget displays a textual label and/or image, and evaluates a command when pressed. | | Canvas | Canvas 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. | | CheckButton | A 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. | | ComboBox | A 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. | | Entry | An entry widget displays a one-line text string and allows that string to be edited by the user. | | Frame | A frame widget is a container, used to group other widgets together. | | LabelFrame | A 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. | | Label | A label widget displays a textual label and/or image. | | MenuButton | A menu button widget displays a textual label and/or image, and displays a menu when pressed. | | NoteBook | A 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. | | PanedWindow | A 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. | | ProgressBar | A progress bar widget shows the status of a long-running operation. | | RadioButton | Radio button widgets are used in groups to show or change a set of mutually-exclusive options. | | Scale | A 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. | | ScrollBar | Scrollbar 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. | | Separator | A separator widget displays a horizontal or vertical separator bar. | | SizeGrip | A sizegrip widget (also known as a grow box) allows the user to resize the containing toplevel window by pressing and dragging the grip. | | SpinBox | A 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. | | Text | A text widget displays one or more lines of text and allows that text to be edited. Text widgets support embedded widgets or embedded images. | | TreeView | The 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.

| Method | Description | | :----- | :---------- | | Grid | Geometry 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. | | [Pack](http://htmlpreview.github.io/?https://github.com/nomad-sof

Related Skills

View on GitHub
GitHub Stars118
CategoryDevelopment
Updated25d ago
Forks14

Languages

D

Security Score

100/100

Audited on Mar 6, 2026

No findings