I’m posting this to the correct list now.
I’m a new GUI developer that is having some difficulty understanding
the nuances of GUI development with Ruby and want to hopefully get some
my questions answered. First, let me provide my setup:
. I’m using Ruby 1.9.1 patch 243 installed from
. I’m using DialogBlocks as my GUI designer.
. I’m using wg_sugar/xrcise for compiling my xrc source files.
. I’m using Windows Vista and Netbeans 6.8 IDE for my
. I’ve created a full project template to make it easier to
my GUIs going forward using all of this setup.
My design template is segmented as follows:
My xrc source and the ruby files that handle that source are stored in
directory. My lib folder contains my main program ruby files and the
folder contains my rake tasks. The rest of the folders are pretty
self-explanatory. The start file houses the following in the first file
I’m first requiring any files I need and then loading my globals and a
wxhelper file. The wxhelper file is fairly simple in that it’s loading
of the ruby files that are listed in my UI directory for handling the
frames. In addition, any pre-init type of events that need to take
(building directories, reading configuration files, etc. are done with
WxHelper. Then I’m loading my main.rb file which houses all of the meat
my code, including the listener events. As you can see on lines 16-18
the start file, I’m starting a timer to pass threads. I believe this is
proper place to put this code, but I may be mistaken. I’ll ask
about this in a moment.
Lastly, my main.rb file handles something similar in the second file
When I’m ready to work on my GUI development, I simply design in
DialogBlocks, save my xrc, run a rake task that automatically builds my
files from xrc using xrcise, and then type ruby start to execute my GUI.
prefer this type of setup because it feels right. However, it may not
the most efficient way to design and therefore, if there is a better way
implement a design template, please let me know.
So, now that I have all of my pre-requisite mish-mosh out of the way (my
apologies for the length), you at least understand how I’m operating and
possibly answer my questions a little more easily now.
Here are my questions:
Question 1: Did I place the timer event in the right spot? I placed it
the init section of my start script. Second-guessing myself, the only
place I felt I could place it would be within the initialize section of
main.rb script but this didn’t feel right. Because my program is
with the init, I felt it should go here. If I’m mistaken, please
and explain why it shouldn’t go here.
Question 2: My program is going to be using several open socket
simultaneously and CPU processing will occur as well. Therefore, I’m
to simplify my template by incorporating threads to handle CPU/IO
I believe I understand the processes, but my biggest issue may be WHEN
HOW to implement threads in my programs. Coming from other languages
simple gui designs didn’t incorporate threading, I can understand and
appreciate the concept behind threading. I had first thought about
implementing fibers but I don’t believe this is the best thing for me to
since I’m going to be handling cpu blocking. In addition, some java
mention that even if you use a fiber, you have to have a thread to
it. So, threading is the way I want to go. I’m a newbie and novice
programmer in terms of threading and even looking over the examples, I
can’t wrap my head around it at the moment. Any help would be
with reference to my code listed above and when to use threads and also
to use them.
Question 3: I really do love DialogBlocks because it does simplify GUI
design. I read and parsed my own set of notes which I’ll outline below
post the follow-up question:
In DBLK, all top-level Frames, Dialogs and Panels become Ruby classes.
name you type in the class field within DBLK becomes the class name in
Ruby program. Likewise, for the controls “within” a container, the DBLK
class name becomes the name of a Ruby module in your program that will
used to extend the control.
How am I supposed to properly include the classes and modules within my
program template structure? Should I be placing multiple modules and
classes in the same main.rb file or should I place them in separate
and (require?/load?) them from my main.rb file? For instance, the first
class that I had which is listed in main.rb is GuiMain which is
from the main gui frame that acts as the parent container for my
application. I haven’t added any other elements yet that will become
modules or classes, so I’m just uncertain where these code bits will be
placed, or how to properly include them in my GUI. Any help concerning
would be appreciated.
Question 4: This is more of a dialogblocks question but I’m certain
who may use dialogblocks can answer it for me. The question I have
to sizers and my application as a whole. I understand the concept of
but what I don’t understand is how to properly size my Gui App depending
resolution sizes of other users’ desktops. For instance, right now I
simple 700 x 550 starting gui app. I know that if I place a vertical
into my app and a main panel into that sizer, that whenever someone
the app, it will stretch out the main panel as well. However, this
frustrating to me mainly because I’m heavily into CSS designing and I’m
always trying to optimize for different browser sizes. What is a good
starting application size (and the absolute maximum size you should
a minimum starting point, before resizing?) Or, is there a way to test
desktop resolution across all OS platforms, and determine an initial gui
starting size based on that resolution type?
These four question outlines are my biggest concerns at the moment. I’m
very fast learner, have a lot of free time to read/learn and browse api,
etc. I soak up information like a sponge which is a good thing. So,
feel free to inundate me with as much information possible about these
questions and/or other novice items that I may not know about. I like
feel of WxRuby and I’m really excited to get down into porting some of
older GUI app code over to WxRuby.
Many thanks in advance.