3 # vim: sw=4 ts=4 expandtab ai
7 from random import randint
9 class Out_Diag_Control(object):
10 def __init__(self, config):
11 win_width = config.get('window_width')
12 win_height = config.get('window_height')
13 self.out_ui = Out_Diag_Presentation(win_width, win_height)
15 def show(self, filelist, fullsize):
16 self.out_ui.get_data(filelist, fullsize)
22 class Out_Diag_Abstraction(object):
26 class Out_Diag_Presentation(gtk.Window):
28 def __init__(self, win_width, win_height):
29 gtk.Window.__init__(self)
30 self.width = win_width
31 self.height = win_height
32 self.set_default_size(self.width, self.height)
33 self.set_border_width(4)
34 self.connect('delete_event', gtk.main_quit)
36 scrollwind = gtk.ScrolledWindow()
37 scrollwind.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
39 self.area = gtk.DrawingArea()
40 self.area.set_size_request(win_width, win_height)
41 self.area.set_events(gtk.gdk.POINTER_MOTION_MASK |
42 gtk.gdk.POINTER_MOTION_HINT_MASK )
43 self.area.connect("expose-event", self.expose_event)
46 scrollwind.add_with_viewport(self.area)
50 def expose_event(self, widget, event):
53 x , y, width, height = event.area
54 widget.window.draw_drawable(widget.get_style().fg_gc[gtk.STATE_NORMAL], \
55 self.pixmap, x, y, x, y, width, height)
58 def build_pixmap(self):
59 self.pixmap=gtk.gdk.Pixmap(self.window, self.width, self.height)
60 cm=self.pixmap.get_colormap()
62 self.color['black']=cm.alloc_color("black")
63 self.color['white']=cm.alloc_color("white")
64 self.gc=self.pixmap.new_gc()
65 self.gc.set_foreground(self.color['white'])
66 self.pixmap.draw_rectangle(self.gc, True, 0, 0, self.width, self.height)
70 for path, size, bsize in self.filelist:
71 end_angle = (bsize*360*64)/self.fullsize
72 print start_angle, end_angle
73 gc=self.pixmap.new_gc()
74 cm=self.pixmap.get_colormap()
75 col1 = cm.alloc_color(self.rand_color())
76 gc.set_foreground(col1)
77 gc.set_line_attributes(1,gtk.gdk.LINE_SOLID,gtk.gdk.CAP_NOT_LAST,gtk.gdk.JOIN_MITER)
78 self.pixmap.draw_arc(gc, True, 0, 0, self.width, self.height, start_angle, end_angle)
79 start_angle = start_angle + end_angle
80 self.area.queue_draw()
86 return gtk.gdk.Color(r, g, b, 0)
90 gobject.timeout_add(1000, self.draw_diag)
93 def get_data(self, filelist, fullsize):
94 self.filelist = filelist
95 self.fullsize = fullsize