From: Phlip Date: 2004-09-01T12:15:23+09:00 Subject: Re: widget modifs after calls to Tk.mainloop Nicolas Decoster wrote: > I guess this is not possible, since for Tcl/Tk the event loop is started > when the shell is started while for irb it is started only after _full_ > widgets settings. Following up HN's answer... The most majorly awesome way to do this is out of a unit test. If you write GUI code thru unit tests, you can display a window in a tested state, by temporarily operating mainloop(). class TestGrapher < Test::Unit::TestCase def setup() @canvas = TkCanvas.new() @canvas.configure('width', 600) @canvas.configure('height', 600) @canvas.grid() return @canvas end def teardown() @canvas.destroy() if @canvas end def maybeMainloop(reveal = false) if reveal then Tk.mainloop() Tk.restart() @canvas = nil end end .... def test_twoNodes() svg = generateSvg( 'digraph aGraph { a [label=""]; b [label=""]; }') putSvgIntoCanvas(svg, @canvas) all = @canvas.find_all() assert_equal(all.size(), 2) assert_equal(all[0].class.name(), 'TkcOval') assert_equal(all[1].class.name(), 'TkcOval') maybeMainloop # true end .... end That's not complete - it illustrates a test that creates a canvas, optionally displays it, exits mainloop, restarts, and optionally destroys the canvas. Decomment maybeMainloop # true to see a canvas. (Also take out the stuff that doesn't work - it's too complex to copy in here.) Using this technique, you can put one of HN's or your experiments into a test case. Writing unit tests to write features is just like running IRB, except much better. All your features leave a trail of tests, and running them over and over again keeps your bug rate low. -- Phlip http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces