librelist archives

« back to archive

Is it possible to change/update a button text? green_shoes

Is it possible to change/update a button text? green_shoes

From:
Jakob Gaardsted
Date:
2014-09-14 @ 19:15
Subject: is it possible to change a button text? green_shoes

Hi - I try to update the button text on a button,
but it doesn't seem to be possible?
(full code below)

e.g.
            @board[0][0].height -= 3    # Works!
            @board[0][0].text  = "hej"  # No effect?
            @board[0][0].name = "hej"  # Aborts app?!

From the documentation, it's not quite clear to me if it's even possible..
  I try to change 'text' and 'name'.
I'm allowed to update 'text' attribute, but on-screen see no change.
If I try to update 'name' instead, my app aborts.

Is it supposed to be possible, or maybe a limitation of green_shoes?
I notice that green_shoes lists a lot of missing styles..?

I'm trying to pick a GUI toolkit for ruby. Tempted by the suggested
ease of Shoes, but in doubts about 'it being too small (tiny..)'.
  Not being able to change the text on a gui button suggests
I should maybe go for a bigger gui toolkit? (e.g. visualruby?)

Thank you in advance, Jakob Gaardsted.

Fuller code/context:
require 'green_shoes'

Shoes.app {
  border green, strokewidth: 5
  title "Tic Tac Toe:"
  @board = Array.new(3) {Array.new(3)}

  3.times { |i|
    stack width:'32%',align: 'center' do
      border yellow, strokewidth: 5

      3.times { |j|
        border blue, strokewidth: 5

        flow do
          border red, strokewidth: 5
          zz = button "X"+i.to_s+j.to_s, height: 120, width: '98%'
          @board[i][j] = zz

          zz.click {
            @board[0][0].height -= 3    # Works!
            @board[0][0].text  = "hej"  # No effect?
            #@board[0][0].name = "hej"  # Aborts app?!
          }
        end # flow

      }
    end
  }

}

Re: [shoes] Is it possible to change/update a button text? green_shoes

From:
peter marien
Date:
2014-09-14 @ 22:14
Hello Jakob, Green Shoes is based on GTK2, so you can use the methods of
GTK2 if you extract the GTK2 object like this


require 'green_shoes'

Shoes.app do
  @btn = button('old text ') {|btn|alert('Hello, World!')}

  button 'Change!' do |btn|
    @btn.real.set_label("new")
  end

end

2014-09-14 21:15 GMT+02:00 Jakob Gaardsted <jgaardsted@gmail.com>:

> Subject: is it possible to change a button text? green_shoes
>
> Hi - I try to update the button text on a button,
> but it doesn't seem to be possible?
> (full code below)
>
> e.g.
>             @board[0][0].height -= 3    # Works!
>             @board[0][0].text  = "hej"  # No effect?
>             @board[0][0].name = "hej"  # Aborts app?!
>
> From the documentation, it's not quite clear to me if it's even possible..
>   I try to change 'text' and 'name'.
> I'm allowed to update 'text' attribute, but on-screen see no change.
> If I try to update 'name' instead, my app aborts.
>
> Is it supposed to be possible, or maybe a limitation of green_shoes?
> I notice that green_shoes lists a lot of missing styles..?
>
> I'm trying to pick a GUI toolkit for ruby. Tempted by the suggested
> ease of Shoes, but in doubts about 'it being too small (tiny..)'.
>   Not being able to change the text on a gui button suggests
> I should maybe go for a bigger gui toolkit? (e.g. visualruby?)
>
> Thank you in advance, Jakob Gaardsted.
>
> Fuller code/context:
> require 'green_shoes'
>
> Shoes.app {
>   border green, strokewidth: 5
>   title "Tic Tac Toe:"
>   @board = Array.new(3) {Array.new(3)}
>
>   3.times { |i|
>     stack width:'32%',align: 'center' do
>       border yellow, strokewidth: 5
>
>       3.times { |j|
>         border blue, strokewidth: 5
>
>         flow do
>           border red, strokewidth: 5
>           zz = button "X"+i.to_s+j.to_s, height: 120, width: '98%'
>           @board[i][j] = zz
>
>           zz.click {
>             @board[0][0].height -= 3    # Works!
>             @board[0][0].text  = "hej"  # No effect?
>             #@board[0][0].name = "hej"  # Aborts app?!
>           }
>         end # flow
>
>       }
>     end
>   }
>
> }
>
>
>
>