I’m trying to write a small FXRuby program that will
capture 6 pictures from a web source and place them as
buttons on my window. After that I want to have the
buttons to update with a new picture once every second
or so.
This is the work in progress I have a small
explanation below
=========== BEGIN CODE ==============
#!/usr/bin/env ruby
require “fox”
require “cam.rb”
include Fox
include Cam
class TestWindow < FXMainWindow
def initialize(app)
@app = app
# Invoke the base class initialize first
super(@app, “Test”, nil, nil, DECOR_ALL, 0,
0,640,480)
@picture_matrix = FXMatrix.new(self, 2,
LAYOUT_TOP|LAYOUT_FILL_ROW)
@photo_array = []
(1..6).each do |j|
@photo_array[j] = FXButton.new(@picture_matrix,
“photo #{j}”, create_photo_icon(j), app,
FXApp::ID_QUIT, ICON_UNDER_TEXT|JUSTIFY_BOTTOM)
#@photo_array[j] = FXImage.new
end
end
def create
super
show(PLACEMENT_SCREEN)
@photo1Thread = Thread.new(@photo_array[1]) do
photo1|
while true
photo1=FXButton.new(@picture_matrix, "photo
1", create_photo_icon(1), @app, FXApp::ID_QUIT,
ICON_UNDER_TEXT|JUSTIFY_BOTTOM)
sleep(1)
end
end
end
def create_photo_icon(i)
getImageData(i) #This saves a picture capture as
“photo#{i}.jpg” (it’s in the cam module)
p i
icon=FXJPGIcon.new(@app,File.open(“photo#{i}.jpg”,“rb”).read)
icon.scale(120,150)
return icon
end
end
def run
application = FXApp.new(“DirList”, “FoxTest”)
application.init(ARGV)
TestWindow.new(application)
application.create
application.run
end
run
======END CODE==========
in the create method is a thred that is supped to be
updating button 1 every second, (It will hopefully be
expanded to all 6 buttons an a round-robin fasion)
But the picture on the button is not updating and I
can’t figure out why. I’ve tried everything like
repaints and refreses and it simply ignores the new
button information. Why? Can anyone help?
-Thanks
Joshua
···
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!