Tuesday, March 30, 2010

FXRuby 'FRAME' type examples

I created a good working UI using foxGUIb 1.0.0 for an app that I've wanted to create for a while now.  The problem I have with the source code generated is that it's hard to customise.  When something doesn't look quite right, I'm competing with several layers for clarity and what I see in the generated source code doesn't match what I see built with the tool.

I gave up trying to make it work for me and decided to just start from scratch with plain FXRuby.  I'm using the foxGUIb layout as my 'spec' or template to build the app using simpler code.  The problem now, of course, is that I don't know FXRuby and am learning it as I go.  Google is my friend, coupled with the many examples available from the FXRuby docs.

While working with FXGroupBox, I was trying to figure out what the different frameStyle types did. e.g. FRAME_GROOVE, FRAME_LINE,  FRAME_RAISED, FRAME_RIDGE,  FRAME_SUNKEN, FRAME_THICK, and FRAME_NORMAL

Google turned up this example from the "FXRuby: Create Lean and Mean GUIs with Ruby" book.  I love online examples! =)

Can you find the error in the code?

Tuesday, March 2, 2010

Enabling checkboxes in FXRuby

While playing around with FXRuby, I tried to create a form window where you could have an "Include All?" check box at the top that automatically enables/disables all the other options (check boxes) below.

This turned out to be non-obvious to code for a non-programmer like me. None of the FXRuby examples include code that does something like this. Google didn't help and neither did the FXRuby book. (Although in all fairness, I only skimmed through the book and didn't read the whole thing.)

I posted a request for some help to the FXRuby forum and a kind soul wrote up an example to do just that. Rather than include the sample code in an email, he posted it online at: http://pastebin.com/rPKJLC9r

I'd never heard of Pastebin.com until now. Seems like a cool place to drop random chunks of code that you can have others look over and help you get working. I posted the link here so I can remember where to find it next time.

Oh, and the FXRuby code example was perfect. Just what I needed. The sample code was an over-simplified version of what I needed to do but it was enough to help me understand the relationship between the objects and commands.