Example #1
0
 def edit(self,widget):
     self.treeView.set_model(self.create_model())
     model=self.treeView.get_model()
     edit.edit(self.fname)
     #print 1
     
     update_list.main(self.fname)
       
     self.treeView.set_model(self.create_model())
     model=self.treeView.get_model()
     '''print 1
     for i in model:
         for j in i:
           print j,
         print
     print 2
     '''
     self.graphs(1)
     self.graphs(2)
     stats.update(self.fname)
     stats.treeView.set_model(stats.create_model(self))
     try:
       viewer.update(self,'')
       viewer.treeView.set_model(viewer.create_model(self))
     except AttributeError:
       pass
Example #2
0
 def changed_item_years(self,widget):
     #activated when combobox value holding years is changed
   
     #creates a file(if not present) and opens it and reads its contents
     self.fname=app.data_location+str(widget.get_active_text())+'_'+self.combobox.get_active_text()
     f=open(self.fname,'a')
     f.close()
     f=open(self.fname,'r')
     x=f.readlines()
     f.close()
     #print 1
     update_list.main(self.fname)
     
     try:
       self.treeView.set_model(self.create_model())
       #model=self.treeView.get_model()
     except AttributeError:
       pass
     self.graphs(1)
     self.graphs(2)
     stats.update(self.fname)
     stats.treeView.set_model(stats.create_model(self))
     try:
       viewer.update(self,'')
       viewer.treeView.set_model(viewer.create_model(self))
     except AttributeError:
       pass
Example #3
0
    def changed_item(self,widget):
        #activated when combobox value holding months is changed
        #self.yy='2012'
        a= widget.get_active_text()
        
        try:
          #print type(self.combobox2.get_active_text())
          self.fname=app.data_location+self.combobox2.get_active_text()+'_'+a
          #print self.fname
          
          f=open(self.fname,'a')
          f.close()
          f=open(self.fname,'r')
          x=f.readlines()
          f.close()
        #print 1
          update_list.main(self.fname)
        except AttributeError:
          f=open(app.data_location+str(self.yy)+'_'+str(self.months[self.mm]),'a')
          f.close()
          update_list.main(app.data_location+str(self.yy)+'_'+self.combobox.get_active_text())
          pass
        
        try:
          self.treeView.set_model(self.create_model())
          #model=self.treeView.get_model()
        except AttributeError:
          pass
        
        #del self.line
        self.graphs(1)
        self.graphs(2)
        
        try:
          stats.update(self.fname)
          stats.treeView.set_model(stats.create_model(self))
        
        
          viewer.update(self,self.fname)
          viewer.treeView.set_model(viewer.create_model(self))
        except AttributeError:
          pass

        
        
        
      
          viewer.treeView.set_model(viewer.create_model(self))
        except AttributeError:
          pass
Example #4
0
 def on_activated(self,widget):
   #single click on the treeView
   
   model=widget.get_model()
   #b= self.treeView.get_selection()
   b=self.treeView.get_cursor()
   row=0
   for i in b[0]:
     row= int(i)
     
  
     
   x=app.data_location+str(self.combobox2.get_active_text())+'_'+ model[row][0]
   #print x
   viewer.update(self,x)
   viewer.treeView.set_model(viewer.create_model(self))
Example #5
0
    def __init__(self):
        
        app.data_location='/home/'+getpass.getuser()+'/.expensemanager/data/'
        dest_dir = os.path.join(app.data_location[0:-5],'data/')
        try:
          f=open(app.data_location+'years','r')
          f.readlines()
          f.close()
        except :
          #script_dir = os.path.dirname(os.path.abspath(__file__))
          #dest_dir = os.path.join(app.data_location)        
          #print type(dest_dir), dest_dir
          #print 1
          try:
	      #print 2
              os.makedirs(dest_dir)
          except OSError:
              pass 
        
        
        self.window=gtk.Window()
        self.window.set_default_size(1220,658)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.connect("delete_event",self.terminate)
        self.window.set_title("Expense Manager")
        
        
        vbox = gtk.VBox(False)
        
        hbox = gtk.HBox()
        settings=(gtk.Button()).get_settings()
        settings.set_property("gtk-button-images",True)
        button1 = gtk.Button(stock=gtk.STOCK_EDIT)


        button1.connect('clicked',self.edit)
        
        button2 = gtk.Button(stock=gtk.STOCK_ADD)
        button2.connect('clicked',self.gocl)
        
        
        
        #liststore for months
        liststore = gtk.ListStore(str)
        self.months=["JAN",'FEB','MAR','APR','MAY','JUNE','JULY','AUG','SEPT','OCT','NOV','DEC']
        for i in self.months:
          liststore.append([i])
        cell = gtk.CellRendererText()
        self.combobox = gtk.ComboBox(liststore)
        self.combobox.pack_start(cell, True)
        self.combobox.add_attribute(cell, "text", 0)
        self.combobox.connect('changed',self.changed_item)
        
        
        now=datetime.datetime.now()
        self.mm=now.month-1
        self.dd=now.day
        self.yy=now.year
        #self.yy='2012'
        self.combobox.set_active(self.mm)
        a= self.combobox.get_active_text()
        #dest_dir = os.path.join(/home/+get,getpass.getuser() 'data')        
        self.fname=app.data_location+str(self.yy)+'_'+a

        
        
        
        
        try:
          f=open(app.data_location+'years','r')
          f.close()
        except :
          f=open(app.data_location+'years','w')
          f.write(str(self.yy)+'\n')
          f.close()
          
        
        #hbox.add(button1)
        hbox.pack_start(button2,False)
        hbox.pack_start(button1,False)
        #hbox.add(button4)
        self.select_years()
        hbox.pack_end(self.combobox2,False)
        hbox.pack_end(self.combobox,False)
        button5=gtk.Button(stock=gtk.STOCK_ABOUT)
        button5.connect('clicked',self.about)
        #hbox.pack_end(buttmon5,False)
        vbox.pack_start(hbox, False)        #hbox contains the add/stats/edit etc buttons/comboboxes
        hbox2=gtk.HBox()
        hbox2.pack_end(button5,False)         #button5 is the about button
        label_user=gtk.Label('    Welcome,    '+getpass.getuser().title()+'.')
        hbox2.pack_start(label_user,False)
        vbox.pack_end(hbox2,False)        #hbox2 holds only the about button
        
        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)        
        
        
        store = self.create_model()

        self.treeView = gtk.TreeView(store)
        #tvc=gtk.TreeViewColumn()
        self.treeView.set_rules_hint(True)
        self.treeView.connect('cursor-changed',self.on_activated)
        sw.add(self.treeView)        
        
        
        pane=gtk.HPaned()
        pane.pack1(sw)#,resize=True, shrink=True)
        
        #self.sw_graphs=gtk.ScrolledWindow()
        #self.sw_graphs.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        #self.sw_graphs.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)     
        
        
        self.f = plt.figure(dpi=75,facecolor='w')
        #self.f.patch.set_alpha(0.95)
        self.f.subplots_adjust(left = 0.08,bottom=0.1,top = 0.9,right=0.95,wspace=0.25,hspace=0.25)
        self.canvas = FigureCanvas(self.f)
        
        self.line1=[]
        self.line1b=[]
        self.line2=[]
        
        self.graphs(1)
        self.graphs(2)
        
        
        #self.sw_graphs.add_with_viewport(self.canvas)
        
        frame=gtk.Frame()
        frame.add(self.canvas)
        
        pane_rightPane=gtk.VPaned()
        pane_stats_viewer=gtk.HPaned()

        
        
        
        viewer_sw = gtk.ScrolledWindow()
        viewer_sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        viewer_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)     
        viewer_sw.add(viewer.treeView)
        
        x=app.data_location+str(self.yy)+'_'+ str(self.months[self.mm])+' '+str(self.dd)
        #print x
        viewer.update(self,x)
        viewer.main(self)
        
        stats_sw = gtk.ScrolledWindow()
        
        stats_sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        stats_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   
        stats.main(self,self.fname)
        stats_sw.add(stats.treeView)
        
        
        pane_stats_viewer.add1(stats_sw)
        pane_stats_viewer.set_position(182)
        pane_stats_viewer.add2(viewer_sw)
        
        pane_rightPane.add1(frame)
        pane_rightPane.set_position(390)
        pane_rightPane.add2(pane_stats_viewer)
        
        
        pane.pack2(pane_rightPane,resize=True, shrink=False)
        pane.set_position(590)
        #pane.compute_position(1120, True, False)
        #pane.queue_resize()
        vbox.pack_start(pane)        
        
        
        
        self.create_columns(self.treeView)
        
        self.window.add(vbox)
        
        self.window.show_all()