Gui Builders for Ruby

Discussion in 'Ruby' started by Kyle Schmitt, Mar 2, 2007.

  1. Kyle Schmitt

    Kyle Schmitt Guest

    This maybe a bit off topic, and is really more of a discussion question but...

    Are there GUI builders for Ruby that allow one to truly divorce the
    GUI from the logic? Reading the tutorials for the GUI toolkits, and
    the tutorial for foxguib, it appears the idea is make you GUI, then
    have your classes inherit the GUI class. Or worse, embed the GUI code
    directly into your classes.

    I suppose one good question would be the _right_ way to to make GUIs
    for ruby scripts. Really just inheriting the GUI class, making a
    separate gui and worker object and glue code between them?

    Admittedly I maybe looking at these tookits a bit naively as I'm just
    now writing some front ends to my utility scripts that use on a day in
    and day out basis.

    Thanks for any suggestions or comments.
    --Kyle
     
    Kyle Schmitt, Mar 2, 2007
    #1
    1. Advertising

  2. Kyle Schmitt

    Martin Boese Guest

    Have a look at Glade (ruby-libglade2).
    With glade you can draw your GUI and produce an xml file. Your ruby program
    then loads it and connect code to the handlers. That should faily divorce the
    gui and logic but I think you are limited to GTK+ and Gnome elements and I am
    unsure how portable an application can be.

    Here are some examples:
    http://ruby-gnome2.sourceforge.jp/hiki.cgi?Samples

    ...and this is a very nice program using it:
    http://www.grism.org/

    martin


    On Friday 02 March 2007 19:11, Kyle Schmitt wrote:
    > This maybe a bit off topic, and is really more of a discussion question
    > but...
    >
    > Are there GUI builders for Ruby that allow one to truly divorce the
    > GUI from the logic? Reading the tutorials for the GUI toolkits, and
    > the tutorial for foxguib, it appears the idea is make you GUI, then
    > have your classes inherit the GUI class. Or worse, embed the GUI code
    > directly into your classes.
    >
    > I suppose one good question would be the _right_ way to to make GUIs
    > for ruby scripts. Really just inheriting the GUI class, making a
    > separate gui and worker object and glue code between them?
    >
    > Admittedly I maybe looking at these tookits a bit naively as I'm just
    > now writing some front ends to my utility scripts that use on a day in
    > and day out basis.
    >
    > Thanks for any suggestions or comments.
    > --Kyle
     
    Martin Boese, Mar 3, 2007
    #2
    1. Advertising

  3. --------------enig36913D30E7BE3027C9FFF772
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable

    Kyle Schmitt wrote:
    > Reading the tutorials for the GUI toolkits, and
    > the tutorial for foxguib, it appears the idea is make you GUI, then
    > have your classes inherit the GUI class.


    I'd presume it looks so scary because doing a layered design is outside
    of the scope of those tutorials.

    Usually in my Qt code, I inherit from the GUI class into a class that
    only handles the mapping of low-level GUI events into a separate layer
    of logic actions. This gives you an extra level of indirection that lets
    you reuse the same UI code for let's say a form-input and a read-only
    variant of the same GUI, but there's nothing forcing you to put -all-
    your logic into that layer. (It's just much simpler in introductory
    tutorials - you have to admit that a clean, layered design usually takes
    a while to wrap your head around.)

    David Vallner


    --------------enig36913D30E7BE3027C9FFF772
    Content-Type: application/pgp-signature; name="signature.asc"
    Content-Description: OpenPGP digital signature
    Content-Disposition: attachment; filename="signature.asc"

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.5 (MingW32)

    iD8DBQFF6bTcy6MhrS8astoRAgyVAJ9egnu0/YJcgBEmq2A/pGP2KWjVNACfVNkq
    rtWaNfTn6COequKQJJRE8Cs=
    =wD+h
    -----END PGP SIGNATURE-----

    --------------enig36913D30E7BE3027C9FFF772--
     
    David Vallner, Mar 3, 2007
    #3
  4. On 3/2/07, Kyle Schmitt <> wrote:
    > This maybe a bit off topic, and is really more of a discussion question but...
    >
    > Are there GUI builders for Ruby that allow one to truly divorce the
    > GUI from the logic? Reading the tutorials for the GUI toolkits, and
    > the tutorial for foxguib, it appears the idea is make you GUI, then
    > have your classes inherit the GUI class. Or worse, embed the GUI code
    > directly into your classes.


    hi kyle,
    the foxGUIb docs don't suggest that the application logic classes
    inherit from the GUI classes! It suggests to extend the GUI class in a
    subclass or a seperate file by using Ruby's class extension mechanism
    to seperate manual GUI related code from autogenerated code. Whether
    you stuff your app's code into the gui class or not is left to you.

    best practice is like this:

    mydialog_guib.rb
    ------
    class MyDialog # generated by foxGUIb
    end

    mydiaog.rb
    -----
    class MyDialog < MyDialog
    #connect some event handlers to bind widgets together ...
    # provide events for the application via Observer Pattern
    end

    application.rb
    ----

    # use MyDialog here

    what you need to do to cleanly decouple gui and application is to use
    the observer pattern. there is a neat implementation of the Observer
    Pattern in RAA: Observable by Joel Vanderwarf

    hope this helps,
    -- meinrad recheis
    >
    > I suppose one good question would be the _right_ way to to make GUIs
    > for ruby scripts. Really just inheriting the GUI class, making a
    > separate gui and worker object and glue code between them?
    >
    > Admittedly I maybe looking at these tookits a bit naively as I'm just
    > now writing some front ends to my utility scripts that use on a day in
    > and day out basis.
    >
    > Thanks for any suggestions or comments.
    > --Kyle
    >
    >
     
    Meinrad Recheis, Mar 4, 2007
    #4
  5. Kyle Schmitt

    Alex Fenton Guest

    Kyle Schmitt wrote:

    > Are there GUI builders for Ruby that allow one to truly divorce the
    > GUI from the logic?


    With wxRuby you can use any of a number of free and commercial designers and save the results as XRC. It's an XML format describing the layout; you load it in Ruby and hook up the event handling etc logic there. It's a similar idea to Glade, except it gives you native widgets on Windows and OS X.

    http://en.wikipedia.org/wiki/WxWidgets#IDE_and_RAD_tools

    > I suppose one good question would be the _right_ way to to make GUIs
    > for ruby scripts. Really just inheriting the GUI class, making a
    > separate gui and worker object and glue code between them?


    I doubt there's one right way. Having a well thought-out set of application classes is a good start; unit tests can help. Beyond that strictly separating GUI layout from event handling (eg by XRC) is one strategy. But with Ruby's concise, adaptable syntax and mix-ins, writing GUI programs using just inheritance and pure ruby is worth considering. But current GUI libraries tend to betray their C/C++ derivation so GUI layout code in Ruby still ends up looking clunky.

    http://wxruby.rubyforge.org/wiki/wiki.pl?WxSugar

    alex
     
    Alex Fenton, Mar 4, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DaMoe

    The Page Builders

    DaMoe, Oct 2, 2003, in forum: HTML
    Replies:
    30
    Views:
    1,319
  2. Michael
    Replies:
    0
    Views:
    294
    Michael
    Jun 9, 2005
  3. Daniel Pitts

    Builders/Factories and Inheritance.

    Daniel Pitts, Aug 16, 2008, in forum: Java
    Replies:
    6
    Views:
    338
    Daniel Pitts
    Aug 18, 2008
  4. Replies:
    4
    Views:
    423
    Sjouke Burry
    Mar 4, 2009
  5. me

    python gui builders

    me, Nov 16, 2009, in forum: Python
    Replies:
    26
    Views:
    2,018
    Stef Mientki
    Nov 25, 2009
Loading...

Share This Page