Yeah, Shoes Has Just a Few Simple Controls

August 6th 14:44
by why

The ListBox, EditLine and Button controls.

Hello, let’s do more Shoes.

Oh and fellows: Shoes isn’t an acronym. It’s just a name. And the name is Shoes. Its pronounced just like normal shoes. Except it’s spelled Shoes. It’s not spelled in any other way. If you are Charles Dickens, you have permission to call it Shuse. But UNLESS YOU ARE CHARLES DICKENS, I beg you. Shoes. Trust me, I know what I’m doing this time!

Here’s today’s example:

name, phone, address = nil
Shoes.app do
  background "rgb(240, 245, 220)"
  stack do
    stack :margin => 10 do
      text "Name"
      name = list_box :items => ["Philarp Tremaine", "Dirk Hockeybranch"]
    end
    stack :margin => 10 do
      text "Address"
      address = edit_line
    end
    stack :margin => 10 do
      text "Phone"
      phone = edit_line
    end
    stack :margin => 10 do
      button "Save" do
        Shoes.p [name.text, address.text, phone.text]
      end
    end
  end
end

So I guess this one’s a bit boring. But the idea is to build something like an HTML form in Shoes. And here we have pairs of title text and control divided into their own little stacks. I use a stack so everything will pile up vertically.

The list_box is akin to a select box. The edit_line is the single-line text input. And, well, button. The two other Shoes controls are presently edit_box and progress, though they aren’t fully finished yet.

Last thing: Shoes.p. This is just like Kernel.p, except that it prints to the proper debug output. On Linux and OSX, this is STDOUT. On Windows, it’s DebugView. Not sure if this will stick around.

Update: Okay, Shoes r60 builds are out.

Now begin the comments …

8 comments

Mark Murphy

said on August 6th 17:42

Based on this and some of the other examples, it feels like stacks are vertical layouts of elements. The StacksAndFlows page on the wiki, though, says it is a “horizontal stack of elements”. Is that a typo? If not, what am I missing?

_why

said on August 6th 17:53

Yes, you’re absolutely right. A typo.

cdcarter

said on August 6th 21:54

Are there plans for HTML tables, or any sort of table display actually?

_why

said on August 6th 22:39

Sorry, no, the HTML support is limited and will probably go away eventually.

But you can do tables with stacks and flows. So, I’d say: write a table method that generates the stacks to do it.

evan

said on August 7th 02:09

This is totally not the place to say! But I just had to. Are you aware of Helium? (Balloon theme returns, Haskell.)

brad

said on August 7th 02:31

How about Markaby style css? The code is already quite Markabyish so it would fit nicely.

name, phone, address = nil
Shoes.app do
  background 'rgb(240, 245, 220)'
  
  style.pudding do
     margin 10
     background 'rgb(255, 255, 255)'
     text "yum-yum-yum-yum-yum"
  end
  
  stack do
    stack.pudding do
      text "Name"
      name = list_box :items => ["Philarp Tremaine", "Dirk Hockeybranch"]
    end
    stack.pudding do
      text "Address"
      address = edit_line
    end
    stack.pudding do
      text "Phone"
      phone = edit_line
    end
    stack.pudding do
      button "Save" do
        Shoes.p [name.text, address.text, phone.text]
      end
    end
  end
end

A style would be more like a block that is instance_evaled against the original object before the custom block is run and can add common content/style to all applied components.

B

Phrogz

said on August 8th 00:13

background ‘rgb(240, 245, 220)’

Oh come now, who let the quotes in? I don’t get along well with them, not after the Great Apostrophe Incident of ’98.

Couldn’t rgb be a method that returns a simple hex string or fancy-ass UberColor instance?

cdcarter

said on August 8th 09:41

_why:
I tried writing a table method and ended up having all the text elements floating on top of each other. Two questions:
* Is there a way to introspect the current window size?
* Can I give a stack or flow a border?

Comments are closed for this entry.