Exemple #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
Exemple #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
Exemple #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
Exemple #4
0
 def graphs(self,option):        
     # when option==1, the first graph, self.a is redrawn
     # when option==2, the second graph, self.c is redrawn
   #self.f.text(0.5,0.92,'',fontsize=14)
   #self.f.text(0.5,0.92,self.combobox.get_active_text()+' '+self.combobox2.get_active_text(),fontsize=14,horizontalalignment='center')
   
   #print self.get_suptitle()
   matplotlib.rc('xtick', labelsize=11) 
   matplotlib.rc('ytick', labelsize=11) 
   try:
     if option==1:
       self.a = self.f.add_subplot(221)
       self.a.patch.set_color('black')
       self.a.patch.set_alpha(0.05)
       #print self.a.get_yticks()
       self.a.yaxis.grid('True')
       #print self.combobox.get_active_text()
       self.a.set_xlabel(self.combobox.get_active_text()+' '+self.combobox2.get_active_text(),fontsize=12)
       #print self.a.get_xlabel()
       self.a.set_ylabel('Daily Expense',fontsize=12)
       model=self.treeView.get_model()
       total_list=[0]
       counter=0 
       for i in model:
         for j in i:
           counter+=1
           if counter%7==0:
             total_list.append(j)
           #print j, type(j),
         #print '\n' 
       #print range(len(total_list))
       #print total_list
       if max(total_list)==0:
         M=1
       else:
         M=max(total_list)+0.1*max(total_list)
       self.a.set_ylim(0,M)
       self.a.set_xlim(1,len(total_list)-1)
       days=[]
       for i in range(len(total_list)):
         if i%2!=0:
           days.append(i)
       self.a.set_xticks(days)
       self.a.set_xticklabels(days,fontsize=9)
       
       #print total_list, len(total_list)        
       #total_list.append(100)
       while len(self.line1)!=0:
         l=self.line1.pop(0)
         l.remove()
       total_list.append(0)
       #self.a.set_antialiased(False)
       #print total_list
       self.line1=self.a.fill(total_list,'blue',alpha=0.6)
       self.canvas.draw()
       
     
       #print line
       
       
       self.b=self.f.add_subplot(222)
       self.b.patch.set_color('black')
       self.b.patch.set_alpha(0.05)
       self.b.yaxis.grid('True')
       self.b.set_xlabel('Categories',fontsize=12)
       self.b.set_ylabel('Category Expense',fontsize=12)
       total_list=[0]
       counter=0
       #print 1
       stats.update(self.fname)
       counter=0
       cat=[]
       for i in stats.create_model(self):
         for j in i:
           counter+=1
           if counter%2==0:
             total_list.append(j)
           else:
             cat.append(j)
       
       del total_list[-1]
       del cat[-1]
       #print cat
       #print total_list
       #print 'sfdf'
       if max(total_list)==0:
         M=1
       else:
         M=max(total_list)+0.1*max(total_list)
       self.b.set_ylim(0,M)
       self.b.set_xlim(0.5,5.5)
       self.b.set_xticks([1,2,3,4,5])
       self.b.set_xticklabels(cat,fontsize=9)
       
       #print total_list, len(total_list)        
       #total_list.append(100)
       
       
       while len(self.line1b)!=0:
         l2=self.line1b.pop(0)
         l2.remove()
         
       #self.line1b=[]
       #print 3
       total_list.append(0)
       #self.a.set_antialiased(False)
       #print total_list
       self.line1b=self.b.fill(total_list,'yellow',alpha=0.6)
       self.canvas.draw()
       
       
       
     
     else:
       
       self.c = self.f.add_subplot(212)        
       self.c.patch.set_color('black')
       self.c.patch.set_alpha(0.05)
       self.c.yaxis.grid('True')
       self.c.set_xlabel(self.combobox2.get_active_text(),fontsize=12)
       self.c.set_ylabel('Monthly Expense',fontsize=12)
       
       self.c.set_xlim(0,13)
       self.c.set_xticks(range(1,13))
       #self.c.set_xticks(range(5))
       #for i in max(monthly_totals_list):
         
       #print self.c.get_yticks()
       
       self.c.set_xticklabels(self.months,fontsize=11)
       year=self.combobox2.get_active_text()
       monthly_totals_list=[0]
       
       for i in range(12):
         cost=0
         s=year+'_'+str(self.months[i])
         #print s
         try:
           f=open(app.data_location+s,'r')
           s=f.readlines()
           f.close()
           
           #print 0
           for i in s:
             #print i[19:22]
             #print i
             cost+=float(i[19:27].strip())
             #print cost,
           
         except IOError:
           #print 2
           pass
         #print cost
         monthly_totals_list.append(cost)
       #print 
       
       if max(monthly_totals_list)==0:
         M=1
       else:
         M=max(monthly_totals_list)+0.1*max(monthly_totals_list)
       self.c.set_ylim(0,M)
       
       while len(self.line2)!=0:
         l=self.line2.pop(0)
         l.remove()
       monthly_totals_list.append(0)
       self.line2=self.c.fill(monthly_totals_list,'green',alpha=0.6)
       self.canvas.draw()
       
       ##print line
     
     
   except AttributeError:
     pass