因此,让我以我是 ruby 和 FXruby 的初学者的事实作为开头。我想知道如何使用 URL 获取图像。这是我将它们从桌面上取下时使用的代码:
require 'rubygems'
require 'fox16'
include Fox
class Image_Viewer <FXMainWindow
def initialize(app)
super(app, "Image Viewer", :opts => DECOR_ALL, :width => 500, :height => 450)
@pic = File.open("/Users/AdamAshwal/Desktop/image.jpg", "rb")
@pic2 = FXJPGImage.new(app, @pic.read)
FXImageFrame.new(self, @pic2)
end
def create
super
self.show(PLACEMENT_SCREEN)
end
end
app = FXApp.new
mainwin = Image_Viewer.new(app)
app.create
app.run