1. Home
  2. Computing & Technology
  3. Ruby

What's a Stack? What's a Flow? - -The Shoes Layout Manager

By , About.com Guide

1 of 6

The Stack

To effectively use any GUI toolkit, you have to understand its layout manager (or geometry manager). In Qt, you have HBoxes and VBoxes, in Tk you have the Packer and in Shoes you have stacks and flows. It sounds cryptic but read on--it's very simple.

A stack does just as the name implies. They stack things vertically. If you put three buttons in a stack, they'll be stacked vertically, one on top of each other. If you run out of room in the window, a scrollbar will appear on the right side of the window to allow you to view all of the elements in the window.

Note that when it's said that the buttons are "inside" of the stack, it just means they were created inside of the block passed to the stack method. In this case, the three buttons are created while inside of the block passed to the stack method, so they're "inside" of the stack.

Shoes.app :width => 200, :height => 140 do
  stack do
    button "Button 1"
    button "Button 2"
    button "Button 3"
  end
end
Explore Ruby
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Ruby
  4. GUI
  5. Shoes
  6. What's a Stack? What's a Flow? --The Shoes Layout Manager

©2009 About.com, a part of The New York Times Company.

All rights reserved.