r/Tcl Oct 26 '19

Meta DO NOT DELETE YOUR QUESTIONS!

51 Upvotes

A very disturbing phenomenon on other tech subreddits has finally reached r/Tcl's shores: folks who ask questions, get answers, then delete their questions, thus also removing the answers from the public record.

THAT'S. NOT. COOL.

It's unfair to the community members who spent time and effort to help you.

It's unfair to the people after you who may have the same holes in their knowledge.

It's unfair to the Internet at large, who can no longer find these nuggets of Tcl wisdom.

So please keep your questions up for the good of this community and the technosphere at large.

Thanks much!


r/Tcl 1d ago

New Stuff EuroTcl/OpenACS 2026 conference videos now online

Thumbnail learn.wu.ac.at
12 Upvotes

r/Tcl 11d ago

oauth2 — a small, pure-Tcl OAuth 2.0 client (Authorization Code + PKCE; deps = http + tls)

21 Upvotes

Every useful web API now speaks OAuth 2.0 — Google, Microsoft, QuickBooks, GitHub, Basecamp, Twitter/X — but Tcl only ever had snippets, and copy-pasting the token/refresh/redirect dance into every script gets old fast. So I wrote a small, self-contained library for it:

github.com/johnbuckman/tcl_oauth2_library (Tcl/Tk license)

It drives the whole Authorization Code flow for you: opens the browser, catches the redirect on a one-shot local socket, exchanges the code for tokens, saves them to a 0600 JSON file, and refreshes expired access tokens transparently. After that, oauth2::get $c $url just works.

Pure Tcl. Depends only on http (core) and tls. JSON is parsed by a small decoder in the package, base64 by core Tcl, and the SHA-256 for PKCE is implemented in-package — so nothing from tcllib, and no C extension. No Tk either; it's happy headless on a server or in cron.

Quick start:

package require oauth2

set c [oauth2::new \
    -auth_url      https://provider.example/authorize \
    -token_url     https://provider.example/token \
    -client_id     $env(CLIENT_ID) \
    -client_secret $env(CLIENT_SECRET) \
    -redirect_uri  http://localhost:9876/callback \
    -scope         "read write" \
    -pkce          S256 \
    -token_file    ~/.config/myapp/tokens.json]

oauth2::login $c                 ;# first run: opens browser, saves tokens
set body [oauth2::get $c https://api.example/v1/things]

It's deliberately provider-agnostic — each provider's quirks are configuration, not code. The same code path drives Basecamp (which uses type=web_server instead of response_type=code), QuickBooks Online (HTTP Basic on the token endpoint, returns a realmId), and Twitter/X (requires PKCE). Runnable examples for all three — plain-Tcl and small-Tk variants — are in the repo.

Background: this came out of a real production need. A native (C++) OAuth2 library we'd been using would occasionally crash, and — worse — our tokens kept silently going invalid despite hourly auto-refresh, and we could never figure out why. The Tcl rewrite has been rock-solid: tokens stay alive and refresh cleanly days later. It's in daily production use against Intuit/QuickBooks and Basecamp.

Also in the box: refresh-token-rotation handling, the client-credentials (machine-to-machine) grant, token introspection (RFC 7662), JWT decode, and — for servers — you can drive oauth2::authorize_url / oauth2::exchange_code yourself instead of the loopback listener.

I gave a EuroTcl 2026 talk on it if you want the fuller tour — slides (PDF).

Feedback very welcome. And if folks find it useful — could it eventually belong in tcllib?


r/Tcl 12d ago

iWish — Tcl/Tk (AndroWish's undroidwish) running natively on iPad, with BLE and a prebuilt IPA

19 Upvotes

I've ported undroidwish — AndroWish's batteries-included, SDL2-rendered Tcl 8.6 / Tk 8.6 wish — to iOS/iPadOS, arm64. It's called iWish. It's the iOS sibling of Christian Werner's AndroWish / undroidwish work: the same SDL-based drawing path that runs on Android and the desktop, now on Apple tablets.

Meant for iPad. It'll launch on iPhone, but the native wish UI (menus, canvas, standard Tk widgets) is desktop-sized — a phone is just too small to use comfortably. Think of it as running your Tk desktop app on a tablet.

What's in it

  • A real Tcl 8.6 / Tk 8.6 interpreter under iOS/iPadOS. Tk renders through an X11-on-SDL2 layer (SdlTkX) onto Metal — native canvas and widgets, no UIKit bridging.
  • Batteries included: ~114 bundled packages, 64 of them native arm64-apple-ios dylibs — tkimg, TLS (LibreSSL), TclCurl, sqlite3, itcl/itk, Thread, tDOM, Tktable, tktreectrl, zint, TkBLT, Tix, VecTcl, and more.
  • Bluetooth LE via CoreBluetooth (a ble-ios native shim) — Tcl apps can talk to BLE peripherals directly.
  • An iOS device bridge (borg) for platform features.
  • A File ▸ Demos menu with ready-to-run examples: TkBLT plotting, a BLE debugger, iOS-bridge demos, and a paint tool.

Download / install

  • Prebuilt IPA (alpha): iWish.ipa on the releases page — currently iWish 0.2-alpha.
  • The IPA is unsigned — re-sign with your own Apple Development certificate, then install. A free Apple ID works but expires after 7 days; a paid developer account ($99/yr) gives a 1-year signature. Easiest paths: Sideloadly or AltStore (they re-sign as they install), or straight from Xcode.
  • Source + build recipes: https://github.com/johnbuckman/iwish
  • 32-bit / iOS 9 (original iPad mini, A5–A6): separate project, androwish-ios9. Apple won't take 32-bit apps in the App Store, so that one is sideload-only.

Status: it's 0.2-alpha and young, but the underlying runtime is the same one shipping in the iOS build of the Decent Espresso machine app — a big real-world Tk app (thousands of lines, live graphs, BLE hardware control). If it runs that, it'll very likely run yours.

Bug reports, PRs, and "here's my Tk app running on an iPad" screenshots all welcome. Built entirely on Christian Werner's AndroWish/undroidwish foundation — thank you.


r/Tcl 15d ago

Request for Help [Expect] Is the "catch" in the "catch wait result" idiom really necessary? It seems very broken.

8 Upvotes

I see this a lot in example code, where people wait on a process to exit and then collect it's return code using "catch wait result" and then usually do something like "exit [lindex $result 3]" to return the process' exit code. This doesn't seem right at all.

Firstoff, it seems like wait already does a pretty good job of handling weird process termination. From [1]:

wait normally returns a list of four integers. The first integer is the pid of the process that was waited upon. The second integer is the corresponding spawn id. The third integer is -1 if an operating system error occurred, or 0 otherwise. If the third integer was 0, the fourth integer is the status returned by the spawned process. If the third integer was -1, the fourth integer is the value of errno set by the operating system. The global variable errorCode is also set.

so it seems like "set result [wait]" would be sufficient. Or even "exit [lindex [wait] 3]" (see postscript for caveats).

Second, nobody actually seems to be checking the returncode of catch, they're just silently catching any errors and continuing. Going by [2] this means that if wait did fail, then result will not contain the 4-element list people are anticipating:

When the return code from the script is 1 (TCL_ERROR), the value stored in varName is an error message. When the return code from the script is 0 (TCL_OK), the value stored in resultVarName is the value returned from script.

Meaning in the case that catch does do something and somehow catches an error from wait, the variable $result will contain some random string of text which may or may not be an iterable list. (could be something like "killed" or "no space left on device"?) It's very possible that "exit [lindex $result 3]" would result in trying to return the 4th word of a textual error message as a returncode, which probably isn't likely to go very well.

If anyone knows of a case where wait could fail with TCL_ERROR etc, please do chime in.

[1] https://www.tcl-lang.org/man/expect5.31/expect.1.html

[2] https://www.tcl-lang.org/man/tcl8.4/TclCmd/catch.htm

P.S. technically "exit [lindex [wait] 3]" still only sort-of correct, since if "lindex [wait] 2" is -1 you're returning the OS errno not the process returncode. Most (but not all) of the time they agree that 0 is success (so if you're using this as a wrapper you'll probably still detect the presence of an error correctly) but actually trying to interpret the error condition outside of expect is likely to go haywire when the OS-generated errno is misinterpreted as a return code from the process itself.

An actual situation where a process exits with non-zero as success (eg. 1) is a very tricky one indeed, because then any failure in TCL could be misinterpreted. This gets tricky because your TCL script either has to be infallible(?) or surrounded in catch, with logic to return some made-up returncode. You'd think this to be a rare occurrence, but I've seen software in the wild that does things like return 0/1/2/3 to indicate one of four successful outcomes, or returns the number of items processed.


r/Tcl 23d ago

EuroTcl 2026 list of talks published.

6 Upvotes

The list of talks for this year's Tcl and OpenACS conference has just been published: https://openacs.km.at/ . It's all happening in Vienna, Austria, on 16 & 17 July. Registration officially closes tomorrow, but late applications are quite likely to be accepted.


r/Tcl 24d ago

Access Apple Intelligence with a Tcl Interpreter

12 Upvotes

I've started a new project tclai-apple that will allow a Tcl script to access the built-in Apple Intelligence engine. It is hosted on my fossil mirror: https://fossil.etoyoc.com/fossil/tclai-apple/home

Unpack the Fossil repo and run:

tclsh make.tcl all

The quick and dirty demo:

#!/bin/env tclsh
###
# applefm-demo.tcl — tclai-apple: Apple Intelligence on-device LLM for Tcl
#
# https://fossil.etoyoc.com/fossil/tclai-apple/
###

load [file join [file dirname [info script]] libapplefm1.0.dylib] Applefm

puts "applefm version: [applefm::version]"
puts "availability: [applefm::availability]"
puts ""

# --- One-shot: can it count r's in "strawberry"? ---
puts "Q: How many r's are in the word \"strawberry\"?"
puts "A: [applefm::respond {How many r's are in the word "strawberry"?}]"
puts ""

# --- Multi-turn conversation with memory ---
set sid [applefm::session create -instructions "You are a concise assistant. Answer in one sentence."]

puts "Q: My name is Sean."
puts "A: [applefm::session respond $sid {My name is Sean.}]"
puts ""

puts "Q: What is your favorite programming language?"
puts "A: [applefm::session respond $sid {What is your favorite programming language?}]"
puts ""

puts "Q: What did I say my name was?"
puts "A: [applefm::session respond $sid {What did I say my name was?}]"

applefm::session destroy $sid
puts ""
puts "Done. 100% on-device, no API key, no network."

And the output:

applefm version: 1.0
availability: available

Q: How many r's are in the word "strawberry"?
A: The word "strawberry" contains two r's.

Q: My name is Sean.
A: Hello Sean! How can I assist you today?

Q: What is your favorite programming language?
A: I don't have personal preferences, but I'm proficient in many programming languages, including Python, JavaScript, and Java. Which one are you interested in learning?

Q: What did I say my name was?
A: You said your name is Sean.

Done. 100% on-device, no API key, no network.

I did use opencode (running GLM 5.2) to help me through the swift bindings and auto-generate a lot of the plumbing. And... I ended up adding Swift support to Practcl. But not bad for a couple of hour's work.

The current build system assumes MacPorts is installed, but it should theoretically also work under HomeBrew. Let me know if you run into problems. The system is written in the Practcl toolkit. TL/DR its a self-contained TclOO script. As long as you have a semi-recent (tcl 8.6+) the make file should just run.

--Sean "The Hypnotoad" Woods


r/Tcl 26d ago

New Stuff Tcl/Tk 9.0.4 Released.

27 Upvotes

r/Tcl Jun 09 '26

Reminder: Only one week left to submit presentation proposals for EuroTcl 2026

10 Upvotes

Deadline for submission of abstracts is 17th June - https://openacs.km.at .


r/Tcl May 26 '26

Post your .tclshrc!

23 Upvotes

Tcl scripts are usually things designed to be boringly sensible and useful, but the .tclshrc? That's for your interactive sessions, where you can get more creative! So post them! Any tricks in there that are particularly good or that are just plain old nice to work with?

Here's mine:

namespace path tcl::unsupported
proc % args {tailcall {*}$args}
if {
    [package vsatisfies [package require Tcl] 9.0]
    && [dict exists [chan configure stdin] -inputmode]
} then {
    apply {{} {
        const CSI "\x1b\["
        const envname [if {[info commands tk] ne ""} {subst Tcl/Tk} {subst Tcl}]
        puts [format "${CSI}38;5;2;1;3mThis is %s %s, build %.12s\u2026${CSI}0m" \
                $envname \
                [tcl::build-info patchlevel] \
                [tcl::build-info commit]]
        set ::tcl_prompt1 [list apply {{CSI} {
            puts -nonewline "${CSI}38;5;1;1m% ${CSI}0m"
            flush stdout
        }} $CSI]
    }}
}

r/Tcl May 25 '26

New Stuff Tiny menu framework thing for TCL

16 Upvotes

This is a super simple menu library thing for TCL. It adds a text, indicator, and command to their own list, and by calling "menu::start" will start an input loop which:

  1. Prints the indicator, ". " and the text

  2. Checks for a valid input (matching an indicator from the list)

  3. Evaluates the code in the command list, using the index of the indicator chosen.

I have both demo code and the source code listed below if anyone is interested

# DEMO CODE
proc demomenu {} {
  menu::reset
  menu::add Alpha a $othermenu
  menu::add Bravo b {puts bravo}
  menu::add Cancel c break
  menu::start
}

# MENU CODE
namespace eval menu {} {
  variable ::menu::text {}
  variable ::menu::indicator {}
  variable ::menu::command {}
}
proc menu::reset {} {
  set menu::text {}
  set menu::indicator {}
  set menu::command {}
}
proc menu::print {} {
  for {set index 0} {$index < [llength $menu::text]} {incr index} {
    set text [lindex $menu::text $index]
    set indicator [lindex $menu::indicator $index]
    set command [lindex $menu::command $index]
    puts "$indicator. $text"
  }
}
proc menu::input {} {
  puts -nonewline "# "
  flush stdout
  gets stdin value
  return $value
}
proc menu::start {} {
  while {1} {
    menu::print
    set inp [menu::input]
    eval [lindex $menu::command [lsearch $menu::indicator $inp]]
  }
}
proc menu::add {text indicator command} {
  lappend menu::text $text
  lappend menu::indicator $indicator
  lappend menu::command $command
}

r/Tcl May 22 '26

New Stuff Yet another "simple" command-line option parser .tm

Thumbnail
github.com
8 Upvotes

I needed this simple library instead of tcllib's `cmdline`.

(Sorry if it's so redundant)


r/Tcl May 19 '26

New Stuff Tclish v1.0!

Thumbnail
13 Upvotes

r/Tcl May 13 '26

New Stuff GitHub - ageldama/tclish: Much more Lispy(tm) Tcl/Tk 9.0

Thumbnail
github.com
11 Upvotes

r/Tcl May 12 '26

New Stuff Tcl/Tk 8.6.18 Release Announcement

Thumbnail newsgrouper.org
34 Upvotes

r/Tcl Apr 28 '26

New Stuff WrithDeck: my writerdeck app for any system (text editor in Tcl/Tk)

Thumbnail gallery
17 Upvotes

r/Tcl Apr 13 '26

Pre-built Tcl/Tk 9.0 and 8.6 binaries

26 Upvotes

Dear TCL community,

I’m happy to share that new Tcl/Tk binary downloads are now available at: https://codeberg.org/tcltk/binaries

Happy TCLing!


r/Tcl Apr 09 '26

Pre-built Tcl/Tk 9.0 and 8.6 binaries - GitHub account locked

13 Upvotes

Dear TCL Community,

I recently moved from GitLab to GitHub with considerable effort, and now my account has been locked. There was no notification and no explanation for the reason. I googled a bit, it could take months until they find time to reactivate.

I can still access the account, but all the TCL binaries have been deleted. Was there too much storage usage? I don’t know — if that was the case, why not simply make the repository read-only until some storage had been freed?

Sorry for the inconvenience. I’m now looking for alternatives, so any suggestions would be welcome.

Best regards


r/Tcl Apr 07 '26

Tk*Fonts default to values that match appropriate system defaults.

10 Upvotes

I know, I specialize in stupid questions, but, for example, on my system TkDefaultFont is set to "Noto Sans 10" and I would like to change it to 11 or 12. The trouble is that there no longer seems to be an "appropriate system default".

So far I have found:

/etc/vconsole.conf

~/.config/xsettingsd/xsettingsd.conf

~/.gtkrc-2.0

~/.config/gtk-3.0/settings.ini

~/.config/gtk-4.0/settings.ini

$ qt5ct # ~/.config/gt5ct/qt5ct.conf

$ qt6ct # ~/.config/qt6ct/qt6ct.conf

None of which seem to be the right one.

Please, someone, put me out of my misery.


r/Tcl Apr 03 '26

General Interest EuroTcl/OpenACS conference, Vienna, 16-17 July 2026

Thumbnail openacs.km.at
8 Upvotes

r/Tcl Mar 31 '26

Introducing Mudpuppy : An agent framework for Tcl

17 Upvotes

Hello all, I'm Sean Woods (aka the Hypnotoad). You may know me as the guy who does the crazy presentations at the US Tcl Conferences.

After a few months of work, I have assembled Tcl's answer to ClaudeBot/Moltbot/Open Claw. A series of packages that I have dubbed "Mudpuppy". The name stems from an amphibian known for eating crustaceans.

I have built mudpuppy atop my clay framework. Mudpuppy is mainly a series of connectors that abstract out the details of maintaining serial conversations over a variety of web protocols. Mudpuppy connectors are built in TclOO and are designed to run as coroutines.

The system includes a sample agent "Sukkal" who uses a local LLM combined with a natural language system to build a database of topics interactively over chat.

Elements include:

  • Connectors for Local LLM as well connecting through OpenRouter to massive commercially hosted LLMs
  • Connectors for Sqlite database that require custom schemas and local behaviors
  • Connectors for Telegram and Discord
  • A local "webchat" which provides the same interfaces as Telegram and Discord across a webserver running on localhost
  • Tools for LLM context management, including compaction
  • Injecting Tcl based tool calls into LLM

The Mudpuppy is part of the clay library distribution. It is posted on my site at:

http://fossil.etoyoc.com/fossil/clay/index

It is also mirrored on Chisel:

https://chiselapp.com/user/hypnotoad/repository/clay/index

The clay library is structured in the style of Tcllib. In fact many of the modules are already part of Tcllib. The Clay repo is just a handy place where I can take development in different directions and not end up breaking Tcllib in the process.

The sukkal agent is located in the /apps/sukkal directory. The mudpuppy framework is in /modules/mudpuppy.


r/Tcl Mar 22 '26

Package registry for Tcl/Tk - looking for feedback and submissions

20 Upvotes

I built a centralized registry: tcltk-pkgs.pages.dev

  • Search by name/tags (json, tk, database...)
  • Direct links to repos & docs
  • Clean, mobile-friendly

Maintainers : Submit a PR to add your package (takes 2 mins) → https://github.com/tcltk-pkgs/registry

Beginners : Try it out and tell me what's missing or confusing!

I need your help : Spread the word to anyone learning Tcl/Tk.

Thanks


r/Tcl Mar 14 '26

Tcl LSP/MCP and editor extensions

21 Upvotes

Hi All,

I've built an LSP + MCP (and a lot more) for Tcl 8.4-9.0. It includes other dialects like f5 irules and iapps too.

https://github.com/bitwisecook/tcl-lsp

Take a look at the README to see what's in there, semantic tokens, tonnes of diagnostics, optimisation passes, type inference and shimmer detection, taint tracking, a configurable formatter, minifier, compiler explorer that tries to match the Tcl 9.0 compiler output and CLI tooling.

It's largely written in Python 3.10+, and you'll find in the releases bundled pyz (zipapp) files that Python can directly run, the vscode VSIX, sublime-package, and so on.

I've built this on my nights and weekends of the last couple of months, trying to flesh it out. There's still a lot of gaps and I need help finding them. Please, if you find issues in it, raise them with both source and what the expectation/output should be.

cheers


r/Tcl Mar 12 '26

"The weirdest programming language I ever learned" - YouTube

Thumbnail
youtube.com
27 Upvotes

It's mildly amusing, watching someone discover Tcl for the first time.


r/Tcl Mar 01 '26

Fedora 43 - tcl odbc

11 Upvotes

I was using Debian previously and didn't have to install anything to use tdbc::odbc package. Using Fedora 43 now and it can't find the package. Ther's no RPM that i can find to install with this package. There's no package manager (like pip or gem, etc). Do I have to compile it to use it?