From: Dave Date: 2002-01-18T04:57:20+09:00 Subject: Newbie question: RubyTk and Observer ? Greetings, Unix Sysadmin here, trying to become a decent programmer as well. In the last three months or so, after wondering how the heck to make good use of the Perl classes/objects Damian Conway's book taught me to code, I've been devouring OO analysis/design books by Booch, Jacobson, the Three Amigos and the Gang of Four. While I'm making use of OO Perl in my current project at work, I've decided that I want to learn Ruby. [ Dave and Andy: I bought the hardcopy; Too hard to read a 21-inch CRT version in bed :o) ] So what I'm doing as a first project is that old first-quarter CS staple, Conway's Life. It should be an interesting exercise in refactoring, as the first versions will be a naive, slow implementation with the universe being a 2D array of distinct Cell objects; then as I learn more I'll move to a Flyweight pattern for the cells and then a bitmapped universe, etc. etc. What I'm wondering about is how I'm going to display the results. I was thinking of RubyTk, since I've dabbled a little in Tcl/Tk, but what I can't figure out is how I can make a Tk window an Observer of my universe. Tk's event-loop model is making me scratch my head. Once I drop into Tk.mainloop, how the heck am I going to get any Life processing done? There's got to be a simpler way, but the only thing I can (naively?) think of right now is have the GUI running in one thread and the CA stuff running in another, and have a timer event set in the Tk.mainloop polling the Life universe to see if it's finished a generation and is ready to display. There's got to be something less "fraught with peril". How should I approach this? Thanks!