Map Tk to WxRuby

Hello,

I try to map a Tk to Wx for the simple animation example below. The code
for Wx is way too long. Can anyone help me to come up with the shorter
code for wx? Either in WxRuby or WxPython would be fine. Wonder is there
a script out there (or an easier or convenient way) to map Tk script to
Wx script for both WxPython and WxRuby?

-Quan Nguyen

############################################################################
Except from “Scipting Languages by Examples”
" In the example of “sun_moving” in section 4.3.1, we have shown that we
can create a simple moving object in Tk with only few lines of code.
Yes, with a mere few lines of code we can create and emulate the moving
circles to animate the sun coming toward us. The complete Ruby and
Python code in Tk are re-displayed below. How can we repeat the same
function in Wx? The example may not be fair for comparision purpose but
it will highlight the different characteristics of Tk and Wx. One thing
for sure is that it will take a lot more lines of code in Wx script. "
##############################################################################
#!/usr/bin/python #Python: sun coming with Tk
4.3.1

from Tkinter import *

mw=Tk()
c=Canvas(mw,width=300,height=300)
c.pack()

for i in range(1000):
x0,x1=i/2,i+i/2
c.create_oval(x0, x0, x1, x1, fill=‘red’)
c.update()

mainloop()
##############################################################################
#!/usr/bin/ruby #Ruby: sun coming with Tk 4.3.1

require ‘tk’
c,k = TkCanvas.new.pack,0

TkAfter.new(1,1000,proc{TkcOval.new(c,k0.5,k0.5,k1.5,k1.5,‘fill’=>‘red’);
k+=1}).start

Tk.mainloop


#!/usr/bin/ruby #wxRuby: sun coming with Wx
require ‘wx’ #

class MyApp < Wx::App #
def on_init #
frame = Wx::Frame.new(nil, :size => [300, 300]) #
canvas = Wx::Panel.new(frame, :size => [300, 300]) #
frame.show

buffer = Wx::Bitmap.new(300, 300)      #storage buffer

canvas.evt_paint do |event|        #evt_paint
  canvas.paint do |dc|        #
    buffer.draw do |buf_dc|        #dump buffer out
      dc.blit(0, 0, 300, 300, buf_dc, 0, 0)    #start bitmap writing
    end            #
  end            #
end              #

100.times do |i|          #timng loop
  buffer.draw do |dcx|        #clear bg trails
    dcx.draw_rectangle(0, 0, 300, 300)    #
  end            #

  buffer.draw do |dcy|        #drawing into buffer
    dcy.brush = Wx::RED_BRUSH      #
    dcy.draw_circle(2*i,2*i, i)      #
  end            #

  canvas.refresh          #refresh
  canvas.update          #
  sleep 0.1            #

end              #

end #
end #

app = MyApp.new #
app.main_loop #

#############################################################################