FxRuby

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

On 12/4/07, Ernst T. [email protected] wrote:

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.

What “forum” are you talking about?

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.

The code is difficult to follow because it’s not using the standard
FXRuby API. If you’re asking how to change the label text for an
FXButton or FXTextField widget, however, you can use:

@button1.text = “1”
@button2.text = “2”
@button3.text = “3”
@text1.text = “a”
@text2.text = “b”
@text3.text = “c”

I am assuming that what your code calls FX::Button and FX::Text are
the same things as FXButton and FXText (or maybe FXTextField).

On click of button1. Swap the strings from button2 and button3 and text2
and text3.

@button1.connect(SEL_COMMAND) do
tmp = @button2.text
@button2.text = @button3.text
@button3.text = tmp
tmp = @text2.text
@text2.text = @text3.text
@text3.text = tmp
end

On click of button2. swap the strings from button1 and button3 plus
text1 and text3.

@button2.connect(SEL_COMMAND) do
tmp = @button1.text
@button1.text = @button3.text
@button3.text = tmp
tmp = @text1.text
@text1.text = @text3.text
@text3.text = tmp
end

On click of button3. swap 1 and 2.

@button3.connect(SEL_COMMAND) do
tmp = @button1.text
@button1.text = @button2.text
@button2.text = tmp
tmp = @text1.text
@text1.text = @text2.text
@text2.text = tmp
end

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

I need to remember that one.

Thanks a million in advance.

Hope this helps. I would also recommend subscribing to the FXRuby
Users mailing list. The information can be found on the FXRuby Home
Page, at http://www.fxruby.org.

Thank you Lyle for you help.

I have my little demo working. I have included the working code.

You said I was using the standard Fxruby API. That could be true; but I
did not realize it. I generated the MainWindow class code with FOXGuiB.
I was under the presumption that this was giving me FxRuby code.

I found your mail list on fxruby.org that is a great help.

As always in full appreciation of all the help I am getting from the
Ruby Seniors!

Thanks,
Ernst

require ‘fox16’
include Fox
#require ‘c:\rubydev\ch06\monitor\demo.rb’
require ‘demo’
STDOUT.sync = true
class MainWindow
def init
@button1.text = “1”
@button2.text = “2”
@button3.text = “3”
@text2.text = “a”
@text4.text = “b”
@text5.text = “c”
@button1.connect(SEL_COMMAND) do
tmp = @button2.text
@button2.text = @button3.text
@button3.text = tmp
tmp = @text4.text
@text4.text = @text5.text
@text5.text = tmp
end
@button2.connect(SEL_COMMAND) do
tmp = @button1.text
@button1.text = @button3.text
@button3.text = tmp
tmp = @text2.text
@text2.text = @text5.text
@text5.text = tmp
end
@button3.connect(SEL_COMMAND) do
tmp = @button1.text
@button1.text = @button2.text
@button2.text = tmp
tmp = @text2.text
@text2.text = @text4.text
@text4.text = tmp
end

end
end
require ‘libGUIb16’
app=FX::App.new
w=MainWindow.new app
w.topwin.show(Fox::PLACEMENT_SCREEN)
app.create
app.run

On 12/5/07, Lyle J. [email protected] wrote:
[…]

I am assuming that what your code calls FX::Button and FX::Text are
the same things as FXButton and FXText (or maybe FXTextField).

Yes, it can be assumed. FoxGUIb has subclassed most of the FXRuby
widgets. The convention is that Fox::FXText is subclassed by FX::Text
and Fox::FXTextField by FX::TextField. What has been added by libGUIb
are just convenience constructors and other convenience stuff. But the
subclassed widgets of course expose the standard FXRuby API. No big
deal.

– Henon