Giter VIP home page Giter VIP logo

ruby-ui's Introduction

ruby-ui : a user interface gem for ruby

RUBY-UI IS ALPHA SOFTWARE!

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:

{include:file:examples/slim_template.rb}

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

{include:file:examples/basic_properties.rb}

Properties in Slim

{include:file:examples/slim_properties.rb}

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.

Waiting for an event

You can use Dialog#wait_for_event to wait and capture the next event.

{include:file:examples/basic_event.rb}

Ruby block as an event loop

You can also provide a block to Dialog#wait_for_event and a loop will be started, passing each event as a parameter to the block.

{include:file:examples/loop_event.rb}

Example where handling of clear action is moved to callback

{include:file:examples/callback_event.rb}

License

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

ruby-ui's People

Contributors

dmacvicar avatar jreidinger avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.