root/branch/ggpolo/umitInventory/itg-integration/run-integrated.py @ 1021

Revision 1021, 4.3 kB (checked in by ggpolo, 6 years ago)

Changed how line_filter updates is changed and updated through several modules (cleaner and better way now), added CategoryFilter? for doing filter based on current graph display, added more functionaly to DataGrabber? and some other minor changes in ITG

Line 
1# Copyright (C) 2007 Insecure.Com LLC.
2#
3# Authors: Guilherme Polo <ggpolo@gmail.com>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18# USA
19
20import gtk
21import random
22
23from DataGrabber import DataGrabber
24from TLGraph import InteractiveGraph
25from TLBarDisplay import TLSelected
26from GraphToolbar import GraphControllerTB
27from CategoryFilter import FilterBox
28from Connector import Connector
29
30# sample data for graph
31m = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Out",
32      "Nov", "Dec" ]
33
34"""
35ToDO: - This is for all modules that will change line_filter:
36           Get max value based on active lines.
37           
38      - Better alignment, and etc, a lot of things =)
39"""
40
41class TLEventsTree(gtk.HBox):
42    def __init__(self):
43        gtk.HBox.__init__(self)
44       
45        scrollw = gtk.ScrolledWindow()
46
47        self.treestore = gtk.TreeStore(str)
48
49        for parent in range(5):
50            p = self.treestore.append(None, ['parent %d' % parent])
51
52            for child in range(4):
53                self.treestore.append(p, ['child %d of parent %d' % (child, parent)])   
54
55        self.treeview = gtk.TreeView(self.treestore)
56        self.tcolumn = gtk.TreeViewColumn("Events Listing (%d)" % len(self.treestore))
57        self.treeview.append_column(self.tcolumn)
58
59        cell = gtk.CellRendererText()
60        self.tcolumn.pack_start(cell, True)
61        self.tcolumn.add_attribute(cell, 'text', 0)
62
63        scrollw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
64        scrollw.add_with_viewport(self.treeview)
65        scrollw.set_size_request(170, -1)
66
67        self.add(scrollw)
68
69
70class win(gtk.Window):
71    def __init__(self):
72        gtk.Window.__init__(self)
73
74        self.connector = Connector()
75       
76        filter = { }
77        filter[0] = (True, "Changes Sum")
78        max, start, evts = DataGrabber().changes_in_year_by_week(2007)       
79       
80        # graph
81        self.graph = InteractiveGraph(evts, start, max, 
82                                      y_label='Number of events', 
83                                      vdiv_labels=m, filter=filter,
84                                      connector=self.connector)
85               
86        self.graphtb = GraphControllerTB(self.graph, self.connector)
87        self.filterbtns = FilterBox(filter=filter, connector=self.connector)
88        self.graph.draw_dashed_vert = True
89        # categories label
90        self.viewing_lbl = gtk.Label("Viewing categories")
91       
92        self.tlsel = TLSelected()
93        self.tree = TLEventsTree()
94        self.tview = gtk.TextView()
95
96        self.__layout()
97       
98   
99    def __layout(self):
100        """
101        Layout widgets
102        """
103        main_vbox = gtk.VBox()
104        filterbox = gtk.HBox()
105        left_vbox = gtk.VBox()
106        paned = gtk.HPaned()
107        swtv = gtk.ScrolledWindow()
108
109        # filter
110        filterbox.pack_start(self.viewing_lbl, False, False, 0)
111        filterbox.pack_start(self.filterbtns, False, False, 0)
112
113        tlselbox = gtk.HBox()
114        tlselbox.pack_start(self.tlsel, False, False, 0)
115        left_vbox.pack_start(tlselbox, False, False, 0)
116        left_vbox.pack_start(self.tree, True, True, 0)
117
118        swtv.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
119        swtv.add(self.tview)
120
121        paned.add1(left_vbox)
122        paned.add2(swtv)
123
124        main_vbox.pack_start(self.graphtb, False, False, 0)
125        main_vbox.pack_start(filterbox, False, False, 0)
126        main_vbox.pack_start(self.graph, False, False, 0)
127        main_vbox.pack_start(paned, True, True, 0)
128
129        self.add(main_vbox)
130
131
132if __name__ == "__main__":
133    w = win()
134    w.show_all()
135    w.connect('delete-event', lambda *args:gtk.main_quit())
136    gtk.main()
137
Note: See TracBrowser for help on using the browser.