Skip to content

Clipboard

This capability documents one focused aspect of the widget interface (Tk/Tcl-style behavior + bootstack extensions).

Note: You typically won’t use bootstack.core.capabilities.clipboard directly. This page describes the behavior that widgets expose.

Clipboard helpers (clipboard).

Tk’s clipboard command provides access to the system (or Tk-managed) clipboard. Tkinter exposes this via the clipboard_* methods.

Notes
  • Clipboard behavior can vary by platform and window system.
  • Most apps only need text clipboard operations (clear/append/get).
  • For advanced cases (multiple clipboard types, non-text formats), Tk supports additional options passed via keyword arguments.

clipboard_clear

clipboard_clear(**kw: Any) -> None

Clear the clipboard on the target display.

This removes all data from the clipboard for the specified display.

Parameters:

Name Type Description Default
**kw Any

Clipboard options forwarded to Tk. Common options include: - displayof: A widget/window whose display should be targeted. (Rarely needed in typical single-display apps.)

{}

clipboard_append

clipboard_append(string: str, **kw: Any) -> None

Append text to the clipboard.

Appends string to the clipboard. If you want to replace clipboard contents, call clipboard_clear() first and then clipboard_append().

Parameters:

Name Type Description Default
string str

Text to append to the clipboard.

required
**kw Any

Clipboard options forwarded to Tk. Common options include: - displayof: Target display for the clipboard. - type: Clipboard type name (platform/window-system dependent). - format: Data format name (platform/window-system dependent).

{}
Example

self.clipboard_clear() self.clipboard_append("Hello, world!")

clipboard_get

clipboard_get(**kw: Any) -> str

Return clipboard contents as text.

Parameters:

Name Type Description Default
**kw Any

Clipboard options forwarded to Tk. Common options include: - displayof: Target display for the clipboard. - type: Clipboard type name (platform/window-system dependent).

{}

Returns:

Type Description
str

The clipboard contents as a string.

Raises:

Type Description
TclError

If the clipboard is empty or does not contain data that can be converted to the requested type.

clipboard_set

clipboard_set(text: str, **kw: Any) -> None

Replace clipboard contents with text.

This is a convenience wrapper for:

clipboard_clear(...)
clipboard_append(text, ...)

Parameters:

Name Type Description Default
text str

Text to set on the clipboard.

required
**kw Any

Clipboard options forwarded to clipboard_clear / clipboard_append.

{}

clipboard_get_text

clipboard_get_text(**kw: Any) -> str

Return clipboard contents as text (alias for clipboard_get).