From: Massimiliano Mirra Date: 2002-07-21T04:30:48+09:00 Subject: Re: GUI's and the Rouge, Part II On Sun, Jul 21, 2002 at 02:00:47AM +0900, Tom Sawyer wrote: > point. by retaining execution, such that the gui is a spawned processes, > we retain the ability to modify it "on-the-fly". just think of all the > neat tricks we can do with that! no longer are we limited to just the > event model of the gui's engine. I've done something like that in the past from irb with: Thread.new { Gtk.main } > you may wonder how other aspects of avar as a label get designated. well > since avar was extended to be a label it gained a few things that allow > us to do that: myobj.avar.style={:color=>'red'}, That last one defies your purpose because it mixes model and presentation (a lot). Have you thought about automatic code generation? Rather than having GUI code mixed in the model (implicitly or explicitly), what about, given a model class, automatically generating a class that in turn automatically generates the appropriate GUI? Something like... class MyModel def initialize @avar = "" @another = 0 end def avar @avar end def avar=(value) @avar=value end def another @another end def another=(value) @another=value end end setter_getter_pairs = [ [:avar, :avar=], [:another, :another] ] MyGui = GuiFactory.new(MyModel, setter_getter_pairs) my_instance = MyModel.new my_instance_gui = MyGui.new(my_instance, parent_widget) Also consider chances like... my_instance_gui = MyGui.new(my_instance, parent_widget, stylesheet) I've defined avar= and another= explicitly. Remember that when you are calling myobj.var=something, for GUI purposes you probably don't want to catch the assignment of whatever variable(s) get assigned within the var=() method of myobj, but rather the symmetrical value returned by the var() method (think of a class that stores the time in milliseconds internally but gets it from and tells it to the rest of the world in form of a string "Sunday 4, Mar..."). My .$02. Massimiliano