/
gui_agent.rb
41 lines (34 loc) · 864 Bytes
/
gui_agent.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'rubygems'
require 'wx'
require 'rinda/rinda'
MY_URI = ARGV[0] || "druby://127.0.0.1:7632"
TIME_TO_LIVE = 10
class MouseClient < Wx::App
attr_accessor :space
def on_init
frame = Wx::Frame.new(
nil, #No parent.
:size => [640, 480],
:title => "X/Y Agent"
)
frame.evt_close {exit}
drawing_area = Wx::Window.new(frame)
frame.show
timer = Wx::Timer.new(self, 55)
evt_timer(55) do
drawing_area.paint do |dc|
dc.pen = Wx::Pen.new(Wx::Colour.new(128, 128, 128), 1)
dc.draw_circle(
space.take([/^Integer:x$/, nil]).last,
space.take([/^Integer:y$/, Integer]).last,
50
)
end
end
timer.start(33)
end
end
client = MouseClient.new
DRb.start_service
client.space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))
client.main_loop