DEV Community

kojix2
kojix2

Posted on

Installing Ruby/Tk on Ubuntu

Ruby/Tk is an old Gem.
But it still works well.

You need some option to install Ruby/Tk on Ubuntu.

Install dependencies.(There are various other packages in Tk, so you can install them as needed. tcllib libtk-img-dev tkpng and so on.)

sudo apt install tk-dev
Enter fullscreen mode Exit fullscreen mode

Install Ruby/Tk gem.

gem install tk -- --with-tcltkversion=8.6 \
--with-tcl-lib=/usr/lib/x86_64-linux-gnu \
--with-tk-lib=/usr/lib/x86_64-linux-gnu \
--with-tcl-include=/usr/include/tcl8.6 \
--with-tk-include=/usr/include/tcl8.6 \
--enable-pthread
Enter fullscreen mode Exit fullscreen mode

If you install a new tk package, you might need to reinstall Ruby/Tk as well.

Have a nice day.

Discussion (1)

Collapse
andyobtiva profile image
Andy Maleh

Thanks for the mention.

After Tk had been extracted out of Ruby, I tended to install more conveniently using RVM:

rvm reinstall 3.0.2 --enable-shared --enable-pthread --with-tk --with-tcl

(assuming ActiveTcl was installed beforehand; and following the Ruby reinstall by gem install tk)

In any case, I provide a Ruby gem that enables a more Ruby-way of using Tk: Glimmer DSL for Tk

I recently built CryptoPunks GUI with it.

CryptoPunks GUI Screenshot