1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

How Can Shoes Have Buttons?

By

4 of 4

A Graphical 'top' Frontend
How Can Shoes Have Buttons?

A button can be used to grab text from an external command and display it as a para. The top command on Linux is used to show the CPU and memory utilization of all the processes running on the system. If you're not using Linux, you can replace the top command with any other command (including one of your Ruby scripts) to be displayed in the window.

The only thing different about this example is the font settings for the para. This is for two reasons. Firstly, a mono-space font must be used or the table displayed by the top command won't be formatted correctly. Secondly, a smaller font must be used or it won't all fit in the window.

Shoes.app :width => 600, :height => 400 do
  stack do
    button "What's eat up all of my memory?" do
      @p.clear do
        para `top -b -n1`, :font => 'Cou rier 12px'
      end
    end

    @p = flow
  end
end
See More About
  1. About.com
  2. Technology
  3. Ruby
  4. Graphical User Interfaces
  5. Shoes
  6. A Graphical 'top' Frontend

©2014 About.com. All rights reserved.