Beaon
Beaon

Reputation: 347

Appending a line of text in a Text_Box in ruby shoes

How do you append a line of text in a Text_Box in ruby shoes? I can see no way of doing this. Currently I am writing to a text file then opening that text file to get newly appended content.

Upvotes: 1

Views: 1129

Answers (3)

Rilcon42
Rilcon42

Reputation: 9763

This is a little late but you can do it like this:

require 'green_shoes'

Shoes.app do            
background "#EFC"
flow :width=>'100%', :margin=>10 do
    stack do
        title "Green shoes append example"
    end

    @j=edit_box("Data")

    stack :width=>150 do
        b=button "Click me"
        b.click{
        @j.text=  "#{@j.text} New line of text\n"
        }

    end
    end
 end

j is the name of the edit_box.

Upvotes: 0

user3194191
user3194191

Reputation: 11

You have 7 forms of Text_Box:

banner, a 48 pixel font.
title, a 34 pixel font.
subtitle, a 26 pixel font.
tagline, an 18 pixel font.
caption, a 14 pixel font.
para, a 12 pixel font.
inscription, a 10 pixel font.

To create a Text_Box of 12 pixel font you need to do that:

Shoes.app do
   @text_box_example = para "Some text \n"
   #To append line:
   @text_box_example.replace @text_box_example + "New line of text\n"
end

Upvotes: 0

peter
peter

Reputation: 42192

here two ways, one with the initialisation and one after

Shoes.app :width => 300, :height => 450 do
  @text = edit_box :width => 1.0, :height => 400, :text =>'test'
  @text.text = "test2"
end

Upvotes: 1

Related Questions