Novice needs help with FX Ruby 
Author Message
 Novice needs help with FX Ruby

Hi,

I have very limited programming experience but am trying to figure out
Ruby.  Can someone please help me decipher this simple program found
in the samples included with FXRuby: ( The tutorial located here
http://www.*-*-*.com/ ;was of some help, but I am
still not getting it)

#!/usr/bin/env ruby

require "fox"

include Fox

application = FXApp.new("Hello", "FoxTest")
application.init(ARGV)
main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)
FXButton.new(main, "&Hello, World!", nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()

1) what is this nil, nil, DECOR_ALL about?
2) FX::ID_QUIT ?
3) PLACEMENT_SCREEN  ?
4) What is contained in the Fox.so file?  How can I view its contents?

Thanks in advance



Mon, 14 Feb 2005 01:46:52 GMT  
 Novice needs help with FX Ruby
Just so you know, this is ruby, but mostly calls the the FXruby
fox gui extension to ruby.

Quote:

> Hi,

> I have very limited programming experience but am trying to figure out
> Ruby.  Can someone please help me decipher this simple program found
> in the samples included with FXRuby: ( The tutorial located here
> http://www.fxruby.org/doc/tutorial1.html  was of some help, but I am
> still not getting it)

> #!/usr/bin/env ruby

> require "fox"

> include Fox

> application = FXApp.new("Hello", "FoxTest")
> application.init(ARGV)
> main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)
> FXButton.new(main, "&Hello, World!", nil, application, FXApp::ID_QUIT)
> application.create()
> main.show(PLACEMENT_SCREEN)
> application.run()

These are all FOX specific items. Look at fox-toolkit.org for
documentation of the FOX toolkit in general and
http://www.knology.net/~lyle/fox/1.0/api/

For specific API documentation.

Quote:
> 1) what is this nil, nil, DECOR_ALL about?
> 2) FX::ID_QUIT ?
> 3) PLACEMENT_SCREEN  ?
> 4) What is contained in the Fox.so file?  How can I view its contents?

You can ask ruby itself:
ruby -rfox -e "Fox.constants.each { |con| puts con}"

Or more clearly sorted:
ruby -rfox -e "Fox.constants.sort.each { |con| puts con}"

Quote:
> Thanks in advance

--
Alan Chen
Digikata LLC
http://digikata.com


Mon, 14 Feb 2005 02:26:44 GMT  
 Novice needs help with FX Ruby

Quote:

>1) what is this nil, nil, DECOR_ALL about?

The line:

    main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)

instantiates a new FXMainWindow object and stores a reference to that
object in a local variable, "main". The first argument to
FXMainWindow.new is "application", which is a reference to the FXApp
object that you created earlier in the program. The second argument,
"Hello", is the window title. The third and fourth arguments are
references to the "big" and "mini" icons, respectively, for your
application; since we're passing in nil for both of these, the program
will just use some default icon for your operating system. The last
argument (DECOR_ALL) tells FOX that we want "all" of the decorations for
this window (e.g. minimize and maximize buttons, a close button, etc.)

Quote:
>2) FX::ID_QUIT?

The line:

    button = FXButton.new(main, "Hello, World!", nil, application,
FXApp::ID_QUIT)

instantiates a new FXButton object and stores a reference to that object
in a local variable, "button". Whenever that button generates an event
-- namely, you push it -- it will send a message to some target object.
The fourth argument of FXButton.new identifies which object is going to
get those messages; in this case it's the application. The fifth
argument indicates what identifier (a number) will be sent along with
the message; in this case, FXApp::ID_QUIT refers to a constant (ID_QUIT)
defined in the FXApp class that tells the application to shut down. So,
in other words, clicking the "Hello, World!" button will cause the
application to quit.

Quote:
>3) PLACEMENT_SCREEN?

PLACEMENT_SCREEN is just one of the placement options for the
FXMainWindow#show method, that tells it to initially place the main
window in the center of the screen. Some other commonly-used options are
PLACEMENT_CURSOR (to place it under the current cursor position) and
PLACEMENT_MAXIMIZED (i.e. window is initially maximized).

Quote:
>4) What is contained in the Fox.so file?  How can I view its contents?

Not sure exactly what you mean. As the tutorial states, the "fox.so"
file is just a shared library that Ruby can load dynamically.

A good source of introductory material about all this stuff is the FOX
web site, found here:

    http://www.fox-toolkit.org

Click on the "Documentation" link on the left side of the home page, and
then start from the top!

Hope this helps,

Lyle



Mon, 14 Feb 2005 04:22:08 GMT  
 Novice needs help with FX Ruby
All the ruby talk recently about what language after ruby, the
Abelson/Sussman book ("Structure and Interpretation of Computer
Programs"), the PragProg/Haskell conversation etc. has gotten me in
the mood to try some Scheme in order to expand my programming
repetoir somewhat.  Is there a canonical place to get an interpreter
for windows, or will any of the ones I see from Google suffice?

I'm essentially going to go through the Abelson book and self-direct
study is as if it were a class, so really I just need something that
will work with the examples therein, and is usable enough to do the
problems posed.

Offline replies appreciated.

=====
--
Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com



Mon, 14 Feb 2005 04:59:00 GMT  
 Novice needs help with FX Ruby
Quote:

> All the ruby talk recently about what language after ruby, the
> Abelson/Sussman book ("Structure and Interpretation of Computer
> Programs"), the PragProg/Haskell conversation etc. has gotten me in
> the mood to try some Scheme in order to expand my programming
> repetoir somewhat.  Is there a canonical place to get an interpreter
> for windows, or will any of the ones I see from Google suffice?

> I'm essentially going to go through the Abelson book and self-direct
> study is as if it were a class, so really I just need something that
> will work with the examples therein, and is usable enough to do the
> problems posed.

> Offline replies appreciated.

> =====
> --
> Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

> Yahoo IM: michael_s_campbell

> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com

Just open up the GOOGLE search engine and type SCHEME for WINDOWS and I
am sure you will get some sites.

BX



Mon, 14 Feb 2005 06:26:21 GMT  
 Novice needs help with FX Ruby

Quote:

> repetoir somewhat.  Is there a canonical place to get an interpreter
> for windows, or will any of the ones I see from Google suffice?

Scheme has no canonical interpreter. Try MzScheme, I recall it works fine
on windows, and it's the one I used on my tour of the fine book. ;)

  -- Nikodemus



Mon, 14 Feb 2005 14:55:19 GMT  
 Novice needs help with FX Ruby
You might find something here: http://www.schemers.org/

Quote:

> All the ruby talk recently about what language after ruby, the
> Abelson/Sussman book ("Structure and Interpretation of Computer
> Programs"), the PragProg/Haskell conversation etc. has gotten me in
> the mood to try some Scheme in order to expand my programming
> repetoir somewhat.  Is there a canonical place to get an interpreter
> for windows, or will any of the ones I see from Google suffice?

> I'm essentially going to go through the Abelson book and self-direct
> study is as if it were a class, so really I just need something that
> will work with the examples therein, and is usable enough to do the
> problems posed.

> Offline replies appreciated.

> =====
> --
> Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

> Yahoo IM: michael_s_campbell

> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com

--
Dr. Nathaniel Pryce, Technical Director, B13media Ltd.
Studio 3a, 22-24 Highbury Grove, London N5 2EA, UK
http://www.b13media.com


Mon, 14 Feb 2005 18:57:05 GMT  
 Novice needs help with FX Ruby

Quote:


> > repetoir somewhat.  Is there a canonical place to get an interpreter
> > for windows, or will any of the ones I see from Google suffice?

> Scheme has no canonical interpreter. Try MzScheme, I recall it works fine
> on windows, and it's the one I used on my tour of the fine book. ;)

>   -- Nikodemus

I'de second that.

DrScheme/PLT scheme/MzScheme (http://www.plt-scheme.org/) has the most
extensive libraries and the most user friendly tools and documentation
that I have found. Others that I have examined and abandoned: Chez
Scheme, MIT Scheme, 3dScheme and Scheme48. You might also have a look
at scsh (http://www.scsh.net/) which is awesome for scripting.

-pp



Tue, 15 Feb 2005 04:39:52 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. FX RUBY Dialog print

2. Drag and Drop example for FX/Ruby?

3. Yet another FX/Ruby question

4. FX/Ruby status line

5. Does FX/Ruby have some standard icons?

6. Core dumps with FX/Ruby tables

7. Fun with FX ruby....

8. Problems installing FX/Ruby

9. Novice Needs help with piping

10. Novice needs help with running a script through a pipe

11. RB Novice needs help

12. Novice needs help with SQL (Max,Min, etc) queries on RealDBs

 

 
Powered by phpBB® Forum Software