From: Lyle Johnson Date: 2001-08-16T00:12:26+09:00 Subject: [ruby-talk:19784] Re: The GUI poll is in, and the results aresurprising > Please don't forget what Ruby is all about in this discussion! I think > that the basic principles and idioms of Ruby should be respected in the > GUI that is made the "standard" for Ruby. I absolutely agree. > FXRuby is IMO only a wrapper around a reasonable C++ Gui interface. It > isn't Ruby either. E.g. to declare message identifiers: > > ID_CANVAS, ID_CLEAR, ID_LAST = enum(FXMainWindow::ID_LAST, 3) > > That is plain C++ style (or something) coding. Too many techinal > detais (not VHLL). Why not the Ruby way?: > > identifier :ID_CANVAS, ID_CLEAR I see where you're coming from, but note that the message identifiers for FOX aren't just randomly generated numbers. It is significant that when you derive your class from (say) FXMainWindow, that your derived class's message identifiers don't clash with those already defined in the base class; that's why we usually start the numbering where the base class left off (FXMainWindow::ID_LAST, or whatever). > What about: > > @contents = FXHorizontalFrame.new(self, > LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0) > > Yuck! What was that 5th zero about again? Most of the constructor arguments for FOX widgets are *optional* (with reasonable default values). For the case you mentioned (FXHorizontalFrame), only the first argument (the parent container widget) is required: @contents = FXHorizontalFrame.new(self) and the remaining arguments can either be left at their default values, or specified in subsequent method calls: @contents = FXHorizontalFrame.new(self) @contents.setLayoutHints(LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y) If some future version of Ruby supports keyword arguments, the situation will be even better. > Gtk, I think, it a little cleaner about mapping concepts to the Ruby > Language. I can do "class MyApp < Gtk::Window". Gtk/Ruby uses > assignment methods so that you can do "@buttonbox.border = 10". This is > very intuitive, and its the Ruby way. It also has very few methods > that takes more tthan 1 or 2 arguments. Most things are configured > through methods. You can do this with FXRuby, too: aLabel = FXLabel.new(parent, "Label Text") aLabel.text = "Different Text" aLabel.font = FXFont.new(getApp(), "Courier", 10) aLabel.justify = JUSTIFY_RIGHT > Gtk is ported to windows. The Ruby/Gtk/Windows combo should be possible > with a little effort. Great! Would you tell me where I can download binaries for Ruby/GTK on Windows that work with the latest Ruby installer (version 1.6.4-2) for Windows? > I wish for a GUI API that: > > - Assumes defaults for everything except the basic requirement. Everything > else should be setable through methods. E.g. Label.new('Press me'). > Border, color, font, and everything else should not be arguments to > constructors. Never. FXRuby widgets' attributes are often passed in to their constructors, but almost always as optional arguments (see above). In any case, those attributes can be changed after the fact using method calls. > - Uses Ruby concepts to the full extends. No win.set_border(40) when > you can handle it with win.border = 40. Use of attribute declerator > methods whenever applicable in the line of attr_*. You can already do this with FXRuby. I went to a lot of trouble to make it so. > - Allows inheriting classes to create windows or other widgets with > special keyboard/mouse handling. You can do this with FXRuby. It's not very fancy, but see the "scribble" program in the FXRuby distribution for one example of catching mouse events, etc. > For now, I think Gtk is the best canditate (having not tried Qt). In any > case, I want pure ruby style interfaces before portability. With matz > have designed such a great language, it would be a shame to waste it on > ugly APIs. A lot of Java's success comes from it's coherent, > comprehensible and consistent API. There is "one way" to do things, and > they stick to it. I'd like the same thing to happen in the Ruby world. I think Ruby/GTK is a fine toolkit, too, but the Windows support (for GTK+ itself, not the Ruby interface to it) seems to be a little shaky. A lot of the non-"facts" about FOX and FXRuby that you stated in your post indicate that you're not very familiar with it. FXRuby isn't "done" yet, by the way. I don't know if it's appropriate to include it in the "standard" distribution or not, but I'll certainly help out if I can. I agree whole-heartedly that a lot of the stuff that FXRuby inherits from its C++ lineage is *very* out of place in Ruby, and I hope to improve on that. The biggest eyesore (in my opinion) is the whole issue of mapping messages (i.e. signals/events) to handlers (i.e. callbacks). I like how it's done in Ruby/Tk and Ruby/GTK, where you can just attach a code block, and it's a safe bet that FXRuby will move in this direction too.