我试图在桌面上的不同位置多次显示图像,但我不知道该怎么做。现在我正在尝试 Wxruby,但我想知道是否还有另一种我想念的方法。
到目前为止,我几乎可以从其中一个样本中使用 wxruby 在一个位置显示一张图像:
require 'wx'
include Wx
class Warning < Wx::App
include Wx
def on_init(x = 300, y = 300)
@frame = Frame.new( nil, -1, "Application", Point.new(x,y), Size.new(50,50), FRAME_SHAPED|SIMPLE_BORDER|FRAME_NO_TASKBAR|STAY_ON_TOP)
@frame.show
@has_shape = false
@delta = [0,0]
evt_paint {on_paint}
shape = File.join( 'pathToImage' )
@bmp = Bitmap.new( Image.new(shape) )
@frame.set_client_size(@bmp.width, @bmp.height)
if PLATFORM == 'WXGTK'
# wxGTK requires that the window be created before you can
# set its shape, so delay the call to SetWindowShape until
# this event.
evt_window_create { set_window_shape }
else
# On wxMSW and wxMac the window has already been created, so go for it.
set_window_shape
end
#@frame.paint { | dc | dc.draw_bitmap(@bmp, 0, 0, true) }
end
def set_window_shape
r = Region.new(@bmp)
@has_shape = @frame.set_shape(r)
end
def on_paint
@frame.paint { | dc | dc.draw_bitmap(@bmp, 0, 0, true) }
end
end
app = Warning.new
app.main_loop