[fxruby-users] dipping one foot into the fox

Meinrad Recheis meinrad.recheis at gmail.com
Wed Jan 28 14:51:49 EST 2009


On Wed, Jan 28, 2009 at 12:12 PM, dave L <dglnz at yahoo.com> wrote:

> Right-ho,
>
> looking at exercise 2 of the tutorial i've decided to extend what is shown
> to do this.
>                                 - Save dialog box
>                                 - Open dialog box
> got the main window setup and 1 dialog box with a generic message saying
> this hasn't been implemented yet with a close button on it.
>
> below is the code done so far for the dialog box (any place i can be
> pointed to for FAQ's on what common errors i might hit?
>

I'd suggest you read the online pickaxe or follow some tutorials to gain a
substantial base of ruby skills before continuing here. then you will know
how not to produce so many syntax errors ;)
http://www.ruby-doc.org/docs/ProgrammingRuby/


>
> Question :
> this is completely off the topic of my coding error but is related to HOW
> one goes about structuring multiple windows like this (coming from a RAD -
> Delphi background) where one has a project container folder and dialog boxes
> like this are within the application would one put the dialog window in as a
> child or have it as i have - a seperate file?
>

For a multiwindow application one typically has a MainWindow and some
DialogBoxes (which is almost the same as MainWindow). Or you can have
multiple MainWindows, or just multiple DialogBox instances.
I suggest to read the fxruby users guide:
http://www.fxruby.org/doc/book.html

>
>
>
> My code I've written tonight I could have the command done with the form
> BUT it would defeat my reason for doing this - namely understand how i do
> things in code - use GUIb to position widget etc only!
>
> TextEd_DiaBoxEx.rb code written tonight - errors are as shown below.
>
> dave at AMD3000:/spare/foxgui$ ruby TextEd_DiaBoxEx.rb
> TextEd_DiaBoxEx.rb:3: syntax error, unexpected '\n', expecting tCOLON2 or
> '[' or '.'
> TextEd_DiaBoxEx.rb:9: syntax error, unexpected kEND, expecting $end
> dave at AMD3000:/spare/foxgui$
>
> require "TextEd_DiaBox"
>
> class "TextEd_DiaBox"
>

this is not a Ruby class name here! drop the "
hth
-- henon


>
>
>   def init
>     button1.connect(SEL_COMMAND) {me.close}  #Button is clicked so close
> the dialogbox!
>
>   end
> end
>
> concentrate on this then i'll have a crack at the Open & save Dialog boxes
> of which this will be one
> actually i'd like to dynamically use this based on which button is pushed
> the user sees one of TWO panels.
> Panel 1 would have save as caption and allow the saving of text written.
> Panel 2 would have Open File caption and load the file.
> Close button would exit the app - no saving or attempting to check etc.
>
> Version 2 would do some sort of check and ask the user a question about
> saving before exiting.
>
> TextEd_DiaBox.rb source code....     Not problems
> # source generated by foxGUIb 1.0.0
>
> class DialogBox
>     def initialize( parent)
>         construct_widget_tree( parent)
>         init if respond_to? 'init'
>     end
>
>     def construct_widget_tree( parent)
>         @topwin=
>         FX::DialogBox.new(parent){|w|
>             @dialogBox=w
>             w.wdg_name='dialogBox'
>             w.width=436
>             w.shown=true
>             w.y=339
>             w.height=93
>             w.decorations=131072
>             w.title="Dialog Box"
>             w.layoutHints=768
>             w.x=268
>             FX::Label.new(@dialogBox){|w|
>                 @label1=w
>                 w.wdg_name='label1'
>                 w.text="Sample text to be displayed but not yet implemented
> as yet"
>                 w.padLeft=10
>                 w.frameStyle=20480
>                 w.font=FX::Font.new.from_s('AlArabiya
> [unknown]|90|40|5|0|0|0').to_FXFont
>                 w.width=342
>                 w.padRight=10
>                 w.height=29
>                 w.padTop=0
>                 w.layoutHints=8
>                 w.x=47
>             }
>             FX::Button.new(@dialogBox){|w|
>                 @button1=w
>                 w.wdg_name='button1'
>                 w.text="CLOSE"
>                 w.font=FX::Font.new.from_s('FreeMono
> [unknown]|140|70|5|0|0|768').to_FXFont
>                 w.width=68
>                 w.buttonButtonStyle=67108864
>                 w.y=49
>                 w.height=28
>                 w.layoutHints=40
>                 w.x=184
>             }
>         }
>     end
>     attr_reader :topwin
>     attr_reader :dialogBox
>     attr_reader :label1
>     attr_reader :button1
> end
>
> #unit test
> if __FILE__==$0
>     require 'libGUIb16'
>     app=FX::App.new
>     w=DialogBox.new app
>     w.topwin.show(Fox::PLACEMENT_SCREEN)
>     app.create
>     app.run
> end
>
>
>
> Food for the party season<http://au.rd.yahoo.com/nz/mail/tagline/lifestyle/*http://nz.lifestyle.yahoo.com/food-recipes/>- Easy recipes for Christmas entertaining on Yahoo!Xtra Lifestyle
>
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090128/6a54f79f/attachment.html>


More information about the fxruby-users mailing list