Project

tkxml

0.0
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
TkXML translates XML markup into Ruby Tk interface code
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

TkXML

*ARCHIVED – HISTORICAL ARTIFACT*

TkXML is the *oldest piece of publicly redistributed Ruby code* its author ever wrote. The original version dates to April 2002 – the year he learned the Ruby language – and a copy of that original alpha release is preserved in this repository under work/tkxml.rb, complete with the original runbox.com contact email.

The library is a small experiment in defining graphical user interfaces declaratively in XML, building Ruby/Tk widgets from an XML document in a one-to-one correspondence with the Ruby/Tk API. It was inspired by GTK’s Glade format. At the time, the idea of “UI as data” was novel and exciting; it would be another decade before declarative-UI ideas (React, SwiftUI, Compose, Flutter, etc.) became dominant in mainstream software, though those wisely chose code-as-data rather than literal XML markup.

Both this library and its target are now historical:

  • Tk itself was removed from Ruby’s standard library in Ruby 3.0, and the tk gem is essentially unmaintained. Few modern Ruby projects use Tk for new GUI work.

  • *XML-based UI definitions* in general lost out to declarative code, JSON-based formats, and language-native DSLs.

What remains interesting about this code is its age. It is a small piece of one Ruby programmer’s first year with the language, preserved intact. No further development is planned.


DESCRIPTION

An XML markup language for generating Tk user-interfaces. It was inspired by GTK’s glade format. The TkXML format defines a very simple one-to-one correlation to the Ruby Tk API.

SYNOPSIS

Here’s an example.xml TkXML file:

<Tk:Root name="test" title="Test">
  <Tk:Frame name="menuframe">
    <Tk:Menubutton name="filebutton" text="File" underline="0">
      <Tk:Menu name="filemenu" tearoff="false">
        <Tk:_add _1="command" label="Open" underline="0" accel="Ctrl+O" command="openDocument" />
        <Tk:_add _1="command" label="Exit" underline="0" accel="Ctrl+Q" command="exitApplication" />
      </Tk:Menu>
      <Tk:_pack side="left" />
    </Tk:Menubutton>
    <Tk:_pack side="left" />
  </Tk:Frame>
  <Tk:_bind _1="Control-o" _2="openDocument" />
  <Tk:_bind _1="Control-q" _2="exitApplication" />
</Tk:Root>

To use the library:

require 'tkxml'

tkxml = TkXML.new(File.read('example.xml'))
tkxml.build

STATUS

At this point, TkXML is little more than an interesting experiment in encoding GUIs via markup. But it may well have the potential of becoming a productive tool if someone were inclined to further it’s development.

HISTORY

An interesting side note. TkXML is the oldest bit of redistributed Ruby code your humble author had ever writ.

COPYRIGHTS

Copyright © 2002 Rubyworks

TkXML is distributable in accordance with the BSD-2-Clause license.

See NOTICE.rdoc for details.