ruby-ui : a user interface gem for ruby

RUBY-UI IS ALPHA SOFTWARE!

  • Duncan Mac-Vicar P. <dmacvicar@suse.de>

  • Josef Reidinger <jreidinger@suse.cz>

Introduction

ruby-ui is a library that allows you to create simple user interfaces in ruby.

but… Shoes?

ruby-ui is based on the mature libyui library from the YaST (SUSE's installer/systems management console) project. This means any user interface you write with ruby-ui can be automatically rendered with Qt, Gtk or in text mode (ncurses).

Additionally, ruby-ui provides the following features:

Examples

You can create a simple widget in ruby like this:

require 'ui'

dialog = UI.main_dialog {
  vbox {
    label "Fill in this please"
    input_field "User Name:"
    hbox {
      push_button "Ok"
      push_button "Cancel"
    }
  }
}.wait_for_event

Or you can use a Slim template:

Properties

Ruby-UI support same set of properties as libyui. To query list of properties use method #Widget#properties. Properties can be also automatic set with slim Templates. It is needed to pass correct type. For boolean true or false. For Integer Fixnum or Bignum and for String String object.

Properties example

Properties via builder

Properties in Slim

Events

There is basically three ways how to handle events. It is possible to handle it in event loop, define callbacks on widgets or combination of both approach. Events are documented in #UI::Event and its ancestor.

Events Examples

simple example with event loop

Example with event loop in block

Example where handling of clear action is moved to callback

License

  • ruby-ui is licensed under the MIT License. Mind that libyui is GPL (we will try to change that)