| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 
 |  
class Data_Pdf:
    """classe representant les elements data d'un objet table de reportlab """
    def __init__(self,data_lst):
        """constructeur de l'objet """
        self._data_lst = data_lst
 
    def _lst_index_elm_list (self,elmt, liste):
        """methode qui trouve les index dans une liste d'une liste d'element"""
 
        data2 = liste
        lst_index =[]
 
        while data2.count(elmt) !=0 :
 
            id1=data2.index(elmt)
 
            lst_index.append(id1)
            data2[id1]='0'
 
        return lst_index
 
    def nbr_col (self) :
        self._nbr_col = len (self._data_lst[0])
        return self._nbr_col
 
    def nbr_lign (self) :
        self._nbr_ligne = len (self._data_lst)
        return self._nbr_ligne
 
    def coord_elm (self,elmt):
        x =0
        lst_coord1 =[]
        nbr_col = self.nbr_col()
        nbr_ligne = self.nbr_lign()
        for elm in self._data_lst :
 
 
            lst_y = self._lst_index_elm_list (elmt, elm)
 
            for elm in lst_y :
                coord1 =(x,elm)
                lst_coord1.append(coord1)
            x=x+1
        return lst_coord1
 
    def coord_elm_pdf (self,elmt) :
 
 
        lst_coord1 = self.coord_elm(elmt)
        print lst_coord1
        lst_coord_pdf =[]
        for elm in lst_coord1 :
 
            x2 = nbr_col-elm[0]
            y2 = nbr_ligne-elm[1]
            coord2 =(-x2,-y2)
            lst_coord_pdf.append((elm,coord2))
 
 
        return lst_coord_pdf
        pass
    def coord_elm_col (self) :
        pass
 
 
 
 
 
 
 
 
 
 
 
data = [ [50,25,50],[100,25,25],[80,20,20],[150,10,2] ]
 
 
 
mes_data = Data_Pdf (data)
print mes_data
print mes_data.nbr_col()
print mes_data.nbr_lign()
print mes_data.coord_elm(25)
print mes_data.coord_elm(50)
print mes_data.coord_elm_pdf(25) | 
Partager