FoxGUIb/FAQ

From eqqon

Jump to: navigation, search

Contents

Frequently Asked Questions

What is foxGUIb?

FoxGUIb is an interactive GUI builder and code generator for Ruby. It is the perfect tool for newbies to find out how the Fox-Toolkit works without reading the API docs. It is of course also a tool for professionals because it saves you a lot of typing and "build-cycles" when tweaking user interface look-and-feel.

Is there a foxGUIb tutorial?

Mike Parr has written a small users guide targeted at beginners.

Is foxGUIb still actively developed?

No. At the time being the author is quite busy with other projects. Therefore there is no time left for foxGUIb. I try to answer questions and fix little bugs as quickly as possible, though. If you would like to push foxGUIb beyond what it is now please drop me a mail at <meinrad dot recheis at gmail dot com> or start working by forking foxguib on github. I will gladly merge in all your contributions and fixes.

How can I help?

If you have written any useful extensions to foxGUIb / libGUIb or corrected any bugs you may fork foxguib on github. I will gladly merge in all your contributions and fixes.

foxGUIb crashes! What should I do?

First check out the file log.txt at foxGUIb's directory. It may contain useful information (i.e. exception backtrace) that may help you to solve your problem. If not, you are welcome to send in the file to <meinrad dot recheis at gmail dot com> and ask for help.

I found an annoying little bug

Please fix it and send me the patch or if you are not able to do it you may send a bug report to <meinrad dot recheis at gmail dot com>. You may fork foxguib on github. I will gladly merge in all your contributions and fixes.

Why does foxGUIb change my x, y, with or height values

Actually it does not. The underlying fox-toolkit overwrites these values. Use the layout hints LAYOUT_FIX_WIDTH, LAYOUT_FIX_HEIGHT, LAYOUT_FIX_X, LAYOUT_FIX_Y or simply LAYOUT_EXPLICIT which is a combination of all the previous. You need to set such layout hints in order to preserve the x, y, width and height values. All other kinds of layout hints will ignore them.

I get thousands of warnings when foxGUIb starts

This is a bug which is exhibited by a specific combination of FXRuby and Ruby version (FXRuby 1.6.?). The bug has already been fixed. It should not happen if you update to the latest Ruby / FXRuby version. If this is not possible you can work around by inserting the statement $VERBOSE=nil at the very first line in foxGUIb's source.

foxGUIb crashes when loading a layout

Unfortunately foxguib sometimes crashes when opening files because it tries to open a relative path like this ../../c:/file.rbin. I really should fix that soon. In the meantime, please set foxGUIb's working directory to the directory where your *.rbins reside and loading should work.

The height of the MainWindow is off by about -40px in the generated script

The main window size is fine in foxGUIb but when the exported Ruby code is executed, the main window is about 40 pixels too small in height. This is a bug in the toolkit! The read value is not the same as the set value for a main window. To work around manually resize the window after showing it.

How do I exit a modal Dialog?

Assume that dialog is your dialogbox and button is the OK or Accept button:

button.connect(Fox::SEL_COMMAND){
  dialog.handle(button, Fox::FXSEL(Fox::SEL_COMMAND, Fox::FXDialogBox::ID_ACCEPT), nil)
}

I am trying to write some event handlers and get an error ...

... like "uninitialized constant MyClass::SEL_COMMAND (NameError)"

Either prefix all of FXRuby's constants with Fox (like this: Fox::SEL_COMMAND) or include Fox at the beginning of your script.

Is it possible to skin the Fox-Toolkit?

No, it is not. However it is possible to do quite impressive design just with the color settings of widgets. foxGUIb's own GUI proves that

What is the best way to separate generated code from manual code?

First of all, you should never make manual corrections to foxGUIb generated files because this would make regeneration of the code very destructive. The correct way is to separate generated code and manual extensions in two different files. There are two main ways to do this in Ruby. Assume you have generated a class called DoneWithFoxGUIb:

_done_with_foxguib.rb:

class DoneWithFoxGUIb
# ... foxguib generated code here. do not edit!
end


1) extending the foxguib class

done_with_foxguib.rb:

require "_done_with_foxguib"
class DoneWithFoxGUIb
 def init
   # ... your extension code here. The init method gets called if it exists.
 end
end


2) deriving from the foxguib class

done_with_foxguib.rb:

require "_done_with_foxguib"
class MyDoneWithFoxGUIb < DoneWithFoxGUIb
def initialize(*args, &block)
   super
   # ... your code here
 end
end

I'm putting radios in a groupbox, but can't get mutex behaviour

Before fox12 the Groupbox widget was also a Radiobutton-mutex-controller. Since fox12 this has been changed. As a replacement I wrote a handy controller called RadioGroup which is included in libGUIb. It works like this:

#suppose you have three radiobuttons which you want to be mutually exclusive: @radio1, @radio2, @radio3
group=FX::RadioGroup.new( "group1")
group << @radio1
group << @radio2
group << @radio3
group.on_event_selected{|radioName|
    puts "#{radioName} has been selected"
}

Another even better solution would be to make use of the RadioMutex class provided by libGUIb. It derives from FX::VerticalFrame and coordinates all RadioButtons that are its direct descendants in the widget tree.

What is the best way to reuse layouts?

There are several ways of reusing a piece of layout:

  • Use copy/paste in foxguib's context menu
  • Use foxGUIb to generate parts of a layout and paste that code in your application
  • Generate a class of the layout you want to reuse (not necessarily a complete dialog) and instantiate it multiple times in your code

The latter is definitely the best approach because the single class is easier to maintain than multiple copies of its layout in foxguib or in your source.

What is libGUIb?

LibGUIb is the library behind foxGUIb which is needed by the generated sources. LibGUIb contains facades (less complicated interfaces) for every widget, extends widgets with convenience methods and adds some handy tools.

What has been changed in all the facades (== sub-classed widgets)

FoxGUIb has sub-classed most of the FXRuby widgets for easier code generation. The convention is that Fox::FXText is sub-classed 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 sub-classed widgets of course expose the standard FXRuby API. If you like to know what has been added have a look at the generated code or at libGUIb16.rb itself.

May I redistribute libGUIb with my programs?

Yes. LibGUIb has been packed into only one file for exactly this purpose. You may place libGUIb-1x.rb together with your sources or redistribute the installable libGUIb package.


I got another question

No problem. Send your question to meinrad dot recheis at gmail dot com.