如何在 FXRuby 中获取互联网图像?
因此,让我以我是 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
so let me preface this with the fact that I am a beginner at ruby and FXruby. I would like to know how I can fetch images by using a URL. This is the code I used when getting them off my desktop:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那应该是
而不是
That should be
and not
只需执行:
然后
然后像对待任何其他
文件
一样对待它Just do a:
then
Then treat it as you would treat any other
File