Beginner question

View: New views
7 Messages — Rating Filter:   Alert me  

Beginner question

by Benjamin Sebastian Kolz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi everybody,

I just started working with FXRuby and I maybe somebody can help me with a problem.

Just for fun, I wrote a quiz game in Ruby, but up to now it is only running in a DOS window.

To get it a little bit more attractive, I wanted FXRuby to present the questions in a window
and open a field for the user to type in the answer. The answer should then be sent to the main program
as a string variable "response".

I've tried it like this, following the "hello"-example that comes with FX Ruby...

application = FXApp.new("Hello", "FoxTest")
main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)
FXButton.new(main, frage, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p1, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p2, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p3, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p4, nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()


# p1,p2,p3 and p4 are the variables that contain the answer possibilties
# frage is the question


Now, everything is displayed but I don't know how to give the user the chance to type the answer into a text field
and then this should be sent to the main program... any idea?

Ah, and the program works with a while-loop and after the first run I get an error:
"attempted to create more than one FXApp instance (RunTimeError)"
Does anyone know what s the problem here?

Thank you for all answers!


Posteingang immer voll? Der erste Speicher, der mitwächst: Unbegrenzter Speicher bei Windows Live Hotmail!
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Beginner question

by Meinrad Recheis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Jun 20, 2009 at 5:54 PM, Benjamin Sebastian Kolz <benjaminrub-upf@...> wrote:

Hi everybody,

I just started working with FXRuby and I maybe somebody can help me with a problem.

Just for fun, I wrote a quiz game in Ruby, but up to now it is only running in a DOS window.

To get it a little bit more attractive, I wanted FXRuby to present the questions in a window
and open a field for the user to type in the answer. The answer should then be sent to the main program
as a string variable "response".

I've tried it like this, following the "hello"-example that comes with FX Ruby...

application = FXApp.new("Hello", "FoxTest")
main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)
FXButton.new(main, frage, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p1, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p2, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p3, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p4, nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()

from here on FXApp takes over program control. you need to call your code via event handlers. Check out the connect function. 



# p1,p2,p3 and p4 are the variables that contain the answer possibilties
# frage is the question


Now, everything is displayed but I don't know how to give the user the chance to type the answer into a text field
and then this should be sent to the main program... any idea?

Add a FXTextField for entering the answer. Then bind your code that evaluates the answer to a button event handler like this:

button.connect(SEL_COMMAND) { 
// do something here
}


Ah, and the program works with a while-loop and after the first run I get an error:
"attempted to create more than one FXApp instance (RunTimeError)"
Does anyone know what s the problem here?

You can only have one FXApp instance. When you start FXApp it starts the "GUI-Thread" or others might call it the message loop and calls your code from there. So if you want to have something executed in a FXRuby application you either register event handlers to your buttons and textfield events or start a separate thread for non GUI related things.

you don't need the while loop, the FXApp has its own main loop.

hth,
-- Henon 

-------
Git# --> Git for .NET



_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Beginner question

by Benjamin Sebastian Kolz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Thank you for your response!

Do you know if there is any FXRuby turorial which starts at the beginning and explains the commands with details?
I bought the book "FX Ruby: Create Lean and Mean GUIs with Ruby", but its quite difficult for me to follow the commands.
I would need a tutorial that explains step by step the command with examples... is there any?

Thanks for your answers...

ps: if somebody would like to talk from time to time about ruby questions or about FXRuby codes/problems, feel free to add me to the
MSN messenger.



Date: Sat, 20 Jun 2009 21:46:12 +0200
From: meinrad.recheis@...
To: fxruby-users@...
Subject: Re: [fxruby-users] Beginner question

On Sat, Jun 20, 2009 at 5:54 PM, Benjamin Sebastian Kolz <benjaminrub-upf@...> wrote:

Hi everybody,

I just started working with FXRuby and I maybe somebody can help me with a problem.

Just for fun, I wrote a quiz game in Ruby, but up to now it is only running in a DOS window.

To get it a little bit more attractive, I wanted FXRuby to present the questions in a window
and open a field for the user to type in the answer. The answer should then be sent to the main program
as a string variable "response".

I've tried it like this, following the "hello"-example that comes with FX Ruby...

application = FXApp.new("Hello", "FoxTest")
main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)
FXButton.new(main, frage, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p1, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p2, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p3, nil, application, FXApp::ID_QUIT)
FXButton.new(main, p4, nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()

from here on FXApp takes over program control. you need to call your code via event handlers. Check out the connect function. 



# p1,p2,p3 and p4 are the variables that contain the answer possibilties
# frage is the question


Now, everything is displayed but I don't know how to give the user the chance to type the answer into a text field
and then this should be sent to the main program... any idea?

Add a FXTextField for entering the answer. Then bind your code that evaluates the answer to a button event handler like this:

button.connect(SEL_COMMAND) { 
// do something here
}


Ah, and the program works with a while-loop and after the first run I get an error:
"attempted to create more than one FXApp instance (RunTimeError)"
Does anyone know what s the problem here?

You can only have one FXApp instance. When you start FXApp it starts the "GUI-Thread" or others might call it the message loop and calls your code from there. So if you want to have something executed in a FXRuby application you either register event handlers to your buttons and textfield events or start a separate thread for non GUI related things.

you don't need the while loop, the FXApp has its own main loop.

hth,
-- Henon 

-------
Git# --> Git for .NET




Surfen - optimiert für MSN. Hol Dir die neue Version des Internet Explorers - kostenlos!
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Beginner question

by Meinrad Recheis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Jun 21, 2009 at 7:34 PM, Benjamin Sebastian Kolz <benjaminrub-upf@...> wrote:

Thank you for your response!

Do you know if there is any FXRuby turorial which starts at the beginning and explains the commands with details?
I bought the book "FX Ruby: Create Lean and Mean GUIs with Ruby", but its quite difficult for me to follow the commands.
I would need a tutorial that explains step by step the command with examples... is there any?

Thanks for your answers...

you might want to play around with FoxGUIb which will help you understand how to build fxruby GUIs. there is also an accompanying users guide that is targeted on beginners

http://fox-tool.rubyforge.org/ <--- foxguib home
http://www.mikeparr.info/rubyguib/foxguibhome.htm <--- users guide

hth,
-- Henon



--
Git# --> Git for .NET




_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Parent Message unknown Re: Beginner question

by dglnz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Meinrad,

I for one would like more tutorials on using fxGUIb.

and how to use some of the other controls like matrix (presume it's a table type widgit and with little help info within each popup ? button within event manager doesn't help me much either - or is fxRI the one i need??).


I must admit i am not the brightest programmer and what might seem self explaitory to some is likely to be hard for me to interpret.

I learn best by doing but as of late haven't had an itch to scratch so to speak.

but have wanted to dabble with fxGUIb lately but - lacking good help/pointers and what i'm after is _very_ basic things like capturing the enter keypress. To get a response into a label (but later have it call a sqlite3 Select function) and have data servered up.

think there is a data awear widget but being very much a novice I've not looked round much.
 
any pointers to better or more fleshed out tutorials?

rdgs,

Dave.


--- On Mon, 22/6/09, Meinrad Recheis <meinrad.recheis@...> wrote:

> From: Meinrad Recheis <meinrad.recheis@...>
> Subject: Re: [fxruby-users] Beginner question
> To: fxruby-users@...
> Received: Monday, 22 June, 2009, 5:55 AM
> On Sun, Jun
> 21, 2009 at 7:34 PM, Benjamin Sebastian Kolz <benjaminrub-upf@...>
> wrote:
>
>
>
>
>
>
>
> Thank you for your response!
>
> Do you know if there is any FXRuby turorial which starts at
> the beginning and explains the commands with details?
> I bought the book "FX Ruby: Create Lean and Mean GUIs
> with Ruby", but its quite difficult for me to follow
> the commands.
>
> I would need a tutorial that explains step by step the
> command with examples... is there any?
>
> Thanks for your answers...
>
> you might want to play around with FoxGUIb which will help
> you understand how to build fxruby GUIs. there is also an
> accompanying users guide that is targeted on beginners
>
>
> http://fox-tool.rubyforge.org/ <---
> foxguib home
> http://www.mikeparr.info/rubyguib/foxguibhome.htm <---
> users guide
>
>
> hth,
> -- Henon
>
>
>
> --Git# -->
> Git for .NET
>
>
>
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> fxruby-users mailing list
> fxruby-users@...
> http://rubyforge.org/mailman/listinfo/fxruby-users


     
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Beginner question

by Meinrad Recheis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 22, 2009 at 2:02 AM, dave L <dglnz@...> wrote:

Meinrad,

I for one would like more tutorials on using fxGUIb.

and how to use some of the other controls like matrix (presume it's a table type widgit and with little help info within each popup ? button within event manager doesn't help me much either - or is fxRI the one i need??).


I must admit i am not the brightest programmer and what might seem self explaitory to some is likely to be hard for me to interpret.

I learn best by doing but as of late haven't had an itch to scratch so to speak.

but have wanted to dabble with fxGUIb lately but - lacking good help/pointers and what i'm after is _very_ basic things like capturing the enter keypress. To get a response into a label (but later have it call a sqlite3 Select function) and have data servered up.

think there is a data awear widget but being very much a novice I've not looked round much.

any pointers to better or more fleshed out tutorials?

rdgs,

Dave.

Sorry there are no other tuts that I know of about foxGUIb. I like hacking code and don't like writing tutorials ;) .... I suggest you read the FXRuby guide and/or Lyles book.
FoxGUIb is a tool I wrote to help me and my co-workers with GUI creation. I made it open source since I felt others will find it useful AS IT IS with all its limitations and problems but I have other goals now and would like to move on.

If you have any questions about fxruby or guib, you are welcome to ask here on the list. 
Regards,
-- Henon

--
Git# --> Git for .NET



_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

Re: Beginner question

by dglnz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Still it's very useful and many thanks for making it - Dave.


From: Meinrad Recheis <meinrad.recheis@...>
To: fxruby-users@...
Sent: Monday, 22 June, 2009 5:22:40 PM
Subject: Re: [fxruby-users] Beginner question

On Mon, Jun 22, 2009 at 2:02 AM, dave L <dglnz@...> wrote:

Meinrad,

I for one would like more tutorials on using fxGUIb.

and how to use some of the other controls like matrix (presume it's a table type widgit and with little help info within each popup ? button within event manager doesn't help me much either - or is fxRI the one i need??).


I must admit i am not the brightest programmer and what might seem self explaitory to some is likely to be hard for me to interpret.

I learn best by doing but as of late haven't had an itch to scratch so to speak.

but have wanted to dabble with fxGUIb lately but - lacking good help/pointers and what i'm after is _very_ basic things like capturing the enter keypress. To get a response into a label (but later have it call a sqlite3 Select function) and have data servered up.

think there is a data awear widget but being very much a novice I've not looked round much.

any pointers to better or more fleshed out tutorials?

rdgs,

Dave.

Sorry there are no other tuts that I know of about foxGUIb. I like hacking code and don't like writing tutorials ;) .... I suggest you read the FXRuby guide and/or Lyles book.
FoxGUIb is a tool I wrote to help me and my co-workers with GUI creation. I made it open source since I felt others will find it useful AS IT IS with all its limitations and problems but I have other goals now and would like to move on.

If you have any questions about fxruby or guib, you are welcome to ask here on the list. 
Regards,
-- Henon

--
Git# --> Git for .NET



Email slow, clunky, unreliable? Switch to Yahoo!Xtra Mail, New Zealand's new email address.
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users