Exemple #1
0
 def _get_max_number_width(self, context, numbers):
     """\brief return width of numbers colon
     \param context - cairo context
     \param numbers - list of numbers, number values to calculate maximum width of
     """
     context.select_font_face(self._family, self._slant, self._weight)
     context.set_font_size(self._size)
     return max(map(lambda a: context.text_extents(format_number(a, max_after_comma = 6))[2], numbers))
Exemple #2
0
 def _draw_horizontal_numbers(self, context, y, xx, data, max_x):
     """\brief 
     \param context - cairo context
     \param y - Y coordinate in cairo context
     \param xx - list of floats, X coordinates in cairo context
     \param data - list of floats, numbers to draw
     \param max_x - float
     """
     self._draw_horizontal_text_elements(context, y, xx, map(lambda a: format_number(a), data), max_x)
 def update_account_list(self):
     """update list of properties and statistics of selected account
     """
     if not self._parent.connected():
         return
     cacc = self._parent.model.get_current_account()
     if cacc == None:
         self.account_list.update_rows([])
         return
     stats = self._parent.model.list_account_statistics(cacc['id']).fetchall()
     self.account_list.update_rows(map(lambda a: (a['parameter_name'], (format_number(a['value']) if isinstance(a['value'], (int, float)) else a['value'])), stats))
Exemple #4
0
 def _draw_vertical_colon_numbers(self, context, left_x, y_coordinates, numbers):
     """\brief 
     \param context - cairo context
     \param left_x - X coordinate of left top corner of colon
     \param y_coordinates - coordinates of the middle of each text
     \param numbers - list of numbers, numbers to draw
     """
     if len(y_coordinates) != len(numbers):
         raise od_exception_parameter_error(u'length of y_coordinates and numbers parameters must be same')
     context.select_font_face(self._family, self._slant, self._weight)
     context.set_font_size(self._size)
     context.set_source_rgb(*self._color)
     fextent = context.font_extents()
     for y_cord, nmb in zip(y_coordinates, numbers):
         context.move_to(left_x, y_cord - (fextent[2] / 2.) + fextent[0])
         context.show_text(format_number(nmb, 6))
 def update_statistics(self):
     if not self._parent.connected():
         return
     cac = self._parent.get_model().get_current_account()
     if cac == None:
         self.flush_statistics()
         return
     stats = self._parent.get_model().list_account_statistics(cac['id']).fetchall() 
     statsh = {}
     for val in stats:
         statsh[val['parameter_name']] = val['value']
     for name in statistics_names:
         if statsh.has_key(name):
             obj = self._parent.window.builder.get_object(name)
             obj.set_text(format_number(statsh[name]))
         else:
             self._parent.window.builder.get_object(name).set_text('None')
 def add_clicked(self, button):
     """\brief 
     \param button
     """
     if self.check_entry_ready():
         try:
             aid = self._parent.model.create_account_in_out(self.account.get_value(),
                                                            self.datetime.get_datetime(),
                                                            self.amount.get_value(),
                                                            self.comment.get_text(self.comment.get_start_iter(), self.comment.get_end_iter()))
             acc = self._parent.model.get_account(self.account.get_value())
             self.list.add_row((aid, acc['name'], self.datetime.get_datetime().date().isoformat(), format_number(self.amount.get_value())))
         except od_exception_db_integrity_error:
             pass
 def update(self, ):
     """\brief update posible account fields and list of withdrawalls
     """
     if self._parent.connected():
         accs = self._parent.model.list_accounts(['name'])
         self.account.update_answers(map(lambda a: (a['id'], a['name']), accs))
         cacc = self._parent.model.get_current_account()
         if cacc != None:
             self.account.set_value(cacc['id'])
         withdr = self._parent.model.list_view_account_in_out().fetchall()
         self.list.update_rows(map(lambda a: (a['id'], a['account_name'], a['datetime'].date().isoformat(), format_number(a['money_count'])) , withdr))
 def update_accounts_list(self):
     """update list of accounts"""
     try:
         self.accounts_list.set_odd_color(self._parent.settings.get_key('interface.odd_color'))
         self.accounts_list.set_even_color(self._parent.settings.get_key('interface.even_color'))
     except od_exception_config_key_error:
         pass
     if self._parent.connected():
         self.accounts_list.update_rows(map(lambda a: (a['account_id'], a["name"], format_number(a["first_money"]), format_number(a["current_money"]), a["money_name"]), self._parent.model.list_view_accounts(["name"]).fetchall()))
     else:
         self.accounts_list.make_model()
 def update(self):
     try:
         self.deals_view.set_odd_color(self._parent.settings.get_key('interface.odd_color'))
         self.deals_view.set_even_color(self._parent.settings.get_key('interface.even_color'))
     except od_exception_config_key_error:
         pass
     if not self._parent.connected():
         self.deals_view.make_model() # clean list of deals
         return
     self._parent.deals_filter.prepare_filter()
     self.deals_view.update_rows(map(lambda a: (a["deal_id"], a["date_formated"], a["time_formated"], a["paper_name"], a["direction_formated"], a["price_formated"], a["count"], a["volume_formated"], format_number(a['net_before']), format_number(a['net_after']), format_number(a["commission"]), a["user_attributes_formated"]),  self._parent.deals_filter.get_data(self.sort_order)))