|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Beginner questionHi 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 questionOn Sat, Jun 20, 2009 at 5:54 PM, Benjamin Sebastian Kolz <benjaminrub-upf@...> wrote:
from here on FXApp takes over program control. you need to call your code via event handlers. Check out the connect function.
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 }
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 questionThank 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:
from here on FXApp takes over program control. you need to call your code via event handlers. Check out the connect function.
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 }
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 questionOn Sun, Jun 21, 2009 at 7:34 PM, Benjamin Sebastian Kolz <benjaminrub-upf@...> wrote: Git# --> Git for .NET
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 -- _______________________________________________ fxruby-users mailing list fxruby-users@... http://rubyforge.org/mailman/listinfo/fxruby-users |
|
|
|
|
|
Re: Beginner questionOn Mon, Jun 22, 2009 at 2:02 AM, dave L <dglnz@...> wrote: Git# --> Git for .NET
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 -- _______________________________________________ fxruby-users mailing list fxruby-users@... http://rubyforge.org/mailman/listinfo/fxruby-users |
|
|
Re: Beginner questionStill 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: Git# --> Git for .NET
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 -- 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 |
| Free embeddable forum powered by Nabble | Forum Help |