# Dynamic Text in FXButton

**URL:** <https://www.ruby-forum.com/t/dynamic-text-in-fxbutton/143583>\
**Category:** FXRuby\
**Created:** [July 20, 2008, 9:47pm UTC](https://www.ruby-forum.com/t/dynamic-text-in-fxbutton/143583 "2008-07-20T21:47:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [July 20, 2008, 9:47pm UTC](https://www.ruby-forum.com/t/dynamic-text-in-fxbutton/143583/1 "2008-07-20T21:47:33Z")

</div>

Is there a way to have the text in a button change when you press the  
button? For example, a button that says “Hi”, and when you click it  
says “Bye”. I can’t find how to do this.

Thanks,

Alex

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [August 2, 2008, 12:28pm UTC](https://www.ruby-forum.com/t/dynamic-text-in-fxbutton/143583/2 "2008-08-02T12:28:21Z")

</div>

Alex DeCaria wrote:

> Is there a way to have the text in a button change when you press the  
> button? For example, a button that says “Hi”, and when you click it  
> says “Bye”. I can’t find how to do this.
> 
> Thanks,
> 
> Alex

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

require ‘fox16’

include Fox

app = FXApp.new

mw= FXMainWindow.new(app, "Hello ",:width =\> 320, :height =\> 240)

button = FXButton.new(mw,“Hey”)  
button.connect(SEL\_COMMAND) do  
button.text = “Bye”  
end

app.create

mw.show(Fox::PLACEMENT\_SCREEN)

app.run  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.7 (MingW32)  
Comment: [http://getfiregpg.org](http://getfiregpg.org)

iD8DBQFIlDbBDbyapJB9FLwRAiR+AJ9xhftoZEX/pJZ+/Vf8X3BIZERrIwCbBdu9  
YuoycBuIRg5lH6ByTdk61Ck=  
=qOm9  
-----END PGP SIGNATURE-----
