# Demo

**URL:** <https://www.ruby-forum.com/t/demo/196535>\
**Category:** FXRuby\
**Created:** [December 4, 2007, 8:56pm UTC](https://www.ruby-forum.com/t/demo/196535 "2007-12-04T20:56:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 4, 2007, 8:56pm UTC](https://www.ruby-forum.com/t/demo/196535/1 "2007-12-04T20:56:41Z")

</div>

I have a big favor to ask. I am new to ruby and have managed to build an  
application which manages my Option Trades.  
Now I get to the point were I want to make a GUI for my application.  
Based on all the info provide I have decided for FxRuby. Studying FxRuby  
I miss the first step documentation.

I have managed to build a demo screen with FoxGui (see below), but I am  
struggling to write a program that handles this window.

On the forum I see a lot of us (newbie’s) struggling with the first  
Fxruby steps. Would one of you please be so kind and write a little  
program using my enclose Demo Window.

Let the program handle the following actions.  
At Init move value ‘1’ to button one, ‘2’ to button ‘2’ and ‘3’ to  
button ‘3’, ‘a’ to text1, ‘b’ to text2 and ‘c’ to text3.  
On click of button1. Swap the strings from button2 and button3 and text2  
and text3.  
On click of button2. swap the strings from button1 and button3 plus  
text1 and text3.  
On click of button3. swap 1 and 2.

A picture is worth a 1000 words equals to an example hold the value of a  
book.

Thanks a million in advance.

Ernst

* * *

# source generated by foxGUIb 0.7.1

class MainWindow  
def initialize( parent)  
construct\_widget\_tree( parent)  
init if respond\_to? ‘init’  
end

def construct\_widget\_tree( parent)  
@topwin=  
FX::MainWindow.new(parent){|w|  
@mainWindow=w  
w.wdg\_name=‘mainWindow’  
w.width=532  
w.shown=true  
w.y=312  
w.height=536  
w.x=390  
FX::HorizontalFrame.new(@mainWindow){|w|  
@horizontalframe1=w  
w.wdg\_name=‘horizontalframe1’  
w.width=532  
w.height=536  
FX::VerticalFrame.new(@horizontalframe1){|w|  
@verticalframe1=w  
w.wdg\_name=‘verticalframe1’  
w.width=231  
w.height=536  
FX::Button.new(@verticalframe1){|w|  
@button1=w  
w.wdg\_name=‘button1’  
w.width=40  
w.height=21  
}  
FX::Button.new(@verticalframe1){|w|  
@button2=w  
w.wdg\_name=‘button2’  
w.width=40  
w.y=21  
w.height=21  
}  
FX::Button.new(@verticalframe1){|w|  
@button3=w  
w.wdg\_name=‘button3’  
w.width=40  
w.y=42  
w.height=21  
}  
}  
FX::VerticalFrame.new(@horizontalframe1){|w|  
@verticalframe2=w  
w.wdg\_name=‘verticalframe2’  
w.width=301  
w.height=536  
w.x=231  
FX::Text.new(@verticalframe2){|w|  
@text2=w  
w.wdg\_name=‘text2’  
w.width=301  
w.height=178  
}  
FX::Text.new(@verticalframe2){|w|  
@text4=w  
w.wdg\_name=‘text4’  
w.width=301  
w.y=178  
w.height=179  
}  
FX::Text.new(@verticalframe2){|w|  
@text5=w  
w.wdg\_name=‘text5’  
w.width=301  
w.y=357  
w.height=179  
}  
}  
}  
}  
end  
attr\_reader :topwin  
attr\_reader :mainWindow  
attr\_reader :horizontalframe1  
attr\_reader :verticalframe1  
attr\_reader :button1  
attr\_reader :button2  
attr\_reader :button3  
attr\_reader :verticalframe2  
attr\_reader :text2  
attr\_reader :text4  
attr\_reader :text5  
end

#unit test  
if **FILE** ==$0  
require ‘libGUIb16’  
app=FX::App.new  
w=MainWindow.new app  
w.topwin.show(Fox::PLACEMENT\_SCREEN)  
app.create  
app.run  
end
