IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

Problème Pil : AttributeError: 'tuple' object has no attribute '


Sujet :

Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2013
    Messages : 9
    Par défaut Problème Pil : AttributeError: 'tuple' object has no attribute '
    Bonjour à tous.
    J'ai un problème et il faut à tout pris que j'arrive a le résoudre au plus vite!!!
    Dans ma fonction qui me permet de revenir a la valeur de la variable précédente, j'ai une erreur qui survient lors de la modification de la valeur du tableau:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Exception in Tkinter callback 
    Traceback (most recent call last): 
    File "C:\Python33\lib\tkinter\__init__.py", line 1442, in __call__ 
    return self.func(*args) 
    File "C:\Users\nom\Desktop\ISN Modificateur Image\Image deforme.py", line 643, in Precedant 
    image2 = image1.resize([int(half*t) for t in image1.size]) 
    AttributeError: 'tuple' object has no attribute 'resize'
    voici le code de ma fonction :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    def Precedant(): 
     
    global image1 
    global P 
    P = P-1 
     
     
    if (L>w) and (H>h) and (P>=0): 
     
    image1 = tableau[P] 
    image2 = image1.resize([int(half*t) for t in image1.size]) 
    imageP = ImageTk.PhotoImage(image2) 
    imageL = Tk.Label(image=imageP) 
    imageL.image = imageP 
    imageL.pack() 
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w) 
     
    if (L<=w) and (H<=h) and (P>=0): 
    image1 = tableau[P] 
    imageP = ImageTk.PhotoImage(image1) 
    imageL = Tk.Label(image=imageP) 
    imageL.image = imageP 
    imageL.pack() 
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w) 
     
    else: 
    P = 0
    Avez-vous une solution a mon problème ???
    Merci d'avance =)!!

  2. #2
    Expert éminent
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 741
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 741
    Par défaut
    Salut,
    Citation Envoyé par shooter7223fr Voir le message
    Avez-vous une solution a mon problème ???
    image1 est récupéré de tableau[P]. Votre code ne montre pas comment est construit "tableau".

    D'après le message 'File "C:\Users\nom\Desktop\ISN Modificateur Image\Image deforme.py", line 643, in Precedant' => votre script contient déjà 643 lignes.
    Pas grand monde ira essayer de le comprendre si vous le postez (en tout cas pas moi). Essayez de revoir votre programme pour le découper en module avec des fonctions qui ne trafiquent pas de variables globales. Cela permettra d'avoir des bouts de code plus petits, testable indépendamment les uns des autres,... En plus si vous voulez de l'aide, vous pourrez poster un code réduit pour montrer ce qu'il se passe sans avoir à poster le reste (et éviter au lecteur d'avoir à se palucher l'ensemble du code).
    Bon courage,
    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  3. #3
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2013
    Messages : 9
    Par défaut
    Citation Envoyé par wiztricks Voir le message
    Salut,


    image1 est récupéré de tableau[P]. Votre code ne montre pas comment est construit "tableau".

    D'après le message 'File "C:\Users\nom\Desktop\ISN Modificateur Image\Image deforme.py", line 643, in Precedant' => votre script contient déjà 643 lignes.
    Pas grand monde ira essayer de le comprendre si vous le postez (en tout cas pas moi). Essayez de revoir votre programme pour le découper en module avec des fonctions qui ne trafiquent pas de variables globales. Cela permettra d'avoir des bouts de code plus petits, testable indépendamment les uns des autres,... En plus si vous voulez de l'aide, vous pourrez poster un code réduit pour montrer ce qu'il se passe sans avoir à poster le reste (et éviter au lecteur d'avoir à se palucher l'ensemble du code).
    Bon courage,
    - W

    oui vous avez raison, voila donc mon code en totalité:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    def boutons():
    #Bouton ouvrire image
    boutonOuvriImage = Button(fenetre, text = 'Ouvrir Image', command=ouvrir,width=20)
     
    #Bouton ouvrir Musique
    boutonOuvriMusic = Button(fenetre, text = 'Ouvrir Votre Musique', command=ouvrirMusic,width=17)
     
    #Bouton Sauvegarde
    boutonSauvegarde = Button(fenetre, text = 'Sauvegarder Image', command=Sauvegarde,width=20)
     
    #Bouton pour le player
    boutonPlay = Button(fenetre, text = 'Play', command=play)
    boutonPause = Button(fenetre, text = 'Pause',command=pause)
    boutonStop = Button(fenetre, text = 'Stop' ,command=stop)
     
    #Bouton pour l'éditeur
    boutonFiltreNoir = Button(fenetre, text = 'Filtrer en Noir', command=FiltreNoir,width=15)
    boutonFiltreNegatif = Button(fenetre, text = 'Filtrer en Negatif', command=FiltreNegatif,width=15)
    boutonFiltreSepia = Button(fenetre, text = 'Filtrer en Sepia', command=FiltreSepia,width=15)
    boutonFiltreVert = Button(fenetre, text = 'Filtrer en Vert' ,command=filtre_vert,width=15)
    boutonFiltreRouge = Button(fenetre, text = 'Filtrer en Rouge' ,command=filtre_rouge,width=15)
    boutonFiltreBleu = Button(fenetre, text = 'Filtrer en Bleu' ,command=filtre_bleu,width=15)
    boutonFiltreAl = Button(fenetre, text = 'Filtre Aléatoire' ,command=filtre_Al,width=20)
     
    boutonRetourner = Button(fenetre, text = 'Retourner l\'image', command=Retourner,width=15)
    boutonMiroir = Button(fenetre, text = 'Effet Miroir', command=Miroir,width=15)
     
    boutonMiroirColle = Button(fenetre, text = 'Miroir Colle', command=MiroirColle,width=15)
    boutonRetournerColle = Button(fenetre, text = 'Retourner Colle', command=RetournerColle,width=15)
     
    boutonImageOrigine = Button(fenetre, text = 'Retour à l\'image originale', command=ImageOrigine,width=20)
    boutonPrecedant = Button(fenetre, text = 'Précédant', command=Precedant,width=15)
    boutonSuivant = Button(fenetre, text ='Suivant', command=Suivant,width=15)
     
    #Affichier les boutons
    boutonOuvriImage.pack(side=Tk.TOP)
    boutonImageOrigine.pack(side=Tk.TOP)
    boutonFiltreAl.pack(side=Tk.TOP)
    boutonSauvegarde.pack(side=Tk.TOP)
     
    boutonOuvriMusic.pack()
    boutonPlay.pack()
    boutonPause.pack()
    boutonStop.pack()
     
    boutonFiltreNoir.pack()
    boutonFiltreNegatif.pack()
    boutonFiltreSepia.pack()
    boutonFiltreBleu.pack()
    boutonFiltreRouge.pack()
    boutonFiltreVert.pack()
     
    boutonRetourner.pack()
    boutonMiroir.pack()
    boutonMiroirColle.pack()
    boutonRetournerColle.pack()
     
    boutonPrecedant.pack()
    boutonSuivant.pack()
     
     
     
     
    #Placement des boutons 
    boutonOuvriMusic.place(relx=1, x=-2, y=2, anchor=Tk.NE,)
    boutonPlay.place(relx=1, x=-100, y=60, anchor=Tk.NE)
    boutonPause.place(relx=1, x=-46, y=60, anchor=Tk.NE)
    boutonStop.place(relx=1, x=-2, y=60, anchor=Tk.NE)
     
    boutonFiltreNoir.place(x=0)
    boutonFiltreNegatif.place(x=0, y=30)
    boutonFiltreSepia.place(x=0, y=60)
    boutonFiltreBleu.place(x=125,y=0)
    boutonFiltreRouge.place(x=125,y=30)
    boutonFiltreVert.place(x=125,y=60)
     
     
    boutonRetourner.place(x=250,y=0)
    boutonMiroir.place(x=250,y=30)
    boutonMiroirColle.place(x=250,y=60)
    boutonRetournerColle.place(x=375,y=0)
     
    boutonPrecedant.place(relx=1, x=-380, y=2, anchor=Tk.NE)
    boutonSuivant.place(relx=1, x=-260, y=2, anchor=Tk.NE)
     
     
    #########################Menu déroulant###########################################
    # Dans cette fonction nous créons la bar de menu de notre interface avec toutes #
    # les options du programme pour modifier vos image #
    ##################################################################################
    def menubar():
    menu = Menu(fenetre)
    fichiermenu = Menu(menu)
    # liste du menu fichier
    fichiermenu.add_command(label='Ouvrir Image', command=ouvrir)
    fichiermenu.add_command(label='Ouvrir Votre musique', command=ouvrirMusic)
    fichiermenu.add_command(label='Sauvegarder Image', command=Sauvegarde)
    fichiermenu.add_command(label='quitter', command=fenetre.quit)
    # creation menu fichier
    menu.add_cascade(label='fichier', menu=fichiermenu)
     
    edit = Menu(menu)
    #Liste du menu editer
    edit.add_command(label='Filtrer en Noir', command=FiltreNoir)
    edit.add_command(label='Filtrer en Negatif', command=FiltreNegatif)
    edit.add_command(label='Filtrer en Sepia', command=FiltreSepia)
     
    edit.add_command(label='Miroir Colle', command=MiroirColle)
    edit.add_command(label='Retourner Colle', command=RetournerColle)
    #creatipn menu editer
    menu.add_cascade(label='Editer',menu=edit)
     
    fenetre.config(menu=menu)
     
     
    ##########################Ouverture et modification de l'image##############################
     
    ###Ouverture de l'image###
    def ouvrir():
     
    image = filedialog.askopenfile('r')
    global image1
    image1 = Image.open(image.name)
    global imageOrigine
    imageOrigine = image1
     
    global L,H
    (L,H) = image1.size
    if (L>=w) and (H>=h):
     
    image2 = image1.resize([int(half*t) for t in image1.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
     
    imageP = ImageTk.PhotoImage(image1)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
    tableau[0] = image1
     
    ###Fonction de modification##
     
    #Retour à l'image Origininal 
    def ImageOrigine():
     
    if (L>=w) and (H>=h):
     
    image2 = imageOrigine.resize([int(half*t) for t in imageOrigine.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageOrigine)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageOrigine
     
    global P
    P = 0
    global Ps
    Ps = P
     
    #Filtrer l'image alléatoirement
    def filtre_Al():
    filtreAl = randint(1,6)
     
    if (filtreAl == 1):
    FiltreNoir()
     
    if (filtreAl == 2):
    FiltreNegatif ()
     
    if (filtreAl == 3):
    FiltreSepia()
     
    if (filtreAl == 4):
    filtre_rouge()
     
    if (filtreAl == 5):
    filtre_vert()
     
    if (filtreAl == 6):
    filtre_bleu()
     
    filtreAl = 0
     
     
     
    #Application du Filtre noir 
    def FiltreNoir():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
     
    G = int(((p[0]+p[1]+p[2])/3))
     
    imageM.putpixel ((x,y) ,(G,G,G))
     
    if (L>w) and (H>h):
     
    imageM = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(imageM)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
    #Application du Filtre negatif
    def FiltreNegatif ():
     
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    R = 255-p[0]
    G = 255-p[1]
    B = 255-p[2] 
    imageM.putpixel ((x,y) ,(R,G,B))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
     
    #Application du Filtre sepia
    def FiltreSepia():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    R = (25756 * p[0] + 50397 * p[1] + 12386 * p[2]) >> 16
    G = (22872 * p[0] + 44958 * p[1] + 11010 * p[2]) >> 16;
    B = (17826 * p[0] + 34996 * p[1] + 8585 * p[2]) >> 16;
     
    if R < 0: R = 0
    if R > 255: R = 255
     
    if G < 0: G = 0
    if G > 255: G = 255
     
    if B < 0: B = 0
    if B > 255: B = 255
    imageM.putpixel ((x,y) ,(R,G,B))
     
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
    #Application du Filtre vert
    def filtre_vert():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ((x,y) ,(0,p[1],0))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Application du Filtre bleu
    def filtre_bleu():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ((x,y) ,(0,0,p[2]))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
     
    global image1
    image1 = imageM
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Application du Filtre rouge
    def filtre_rouge():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ((x,y) ,(p[0],0,0))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Retournement de l'image
    def Retourner():
     
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ( ( x,-y+H-1) ,p)
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
     
    #Application de l'effet miroir
    def Miroir():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ( ( -x+L-1,y) ,p) 
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Modification des pixels
    def MiroirColle():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
     
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel((-x+L-1,y) ,p)
    imageM.putpixel((x,y) ,p)
     
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
    def RetournerColle():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
     
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel((x,-y+H-1) ,p)
    imageM.putpixel((x,y) ,p)
     
    if (L>w) and (H>h):
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    def Precedant():
     
    global image1
    global P
    P = P-1
     
     
    if (L>w) and (H>h) and (P>=0):
     
    image1 = tableau[P]
    image2 = image1.resize([int(half*t) for t in image1.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    if (L<=w) and (H<=h) and (P>=0):
    image1 = tableau[P]
    imageP = ImageTk.PhotoImage(image1)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    P = 0
     
     
    def Suivant():
    global image1
    global P
     
    if(P<Ps):
     
    P = P+1
    image1 = tableau[P]
    imageP = ImageTk.PhotoImage(image1)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h,width=w)
     
    else:
    P = Ps
    ###Sauvegarder image###
    def Sauvegarde():
     
    jpg = options = {}
    options['defaultextension'] = '.jpg'
     
    DossierSauvegarde = filedialog.asksaveasfile('w',**jpg)
     
    imageM.save( DossierSauvegarde.name)
     
     
     
     
    ################################Player########################################
     
    #Musique de base pour l'ambiance
    def musicBase():
    mixer.music.load('Intermission.mp3')
    textMusic = Label(fenetre, text = 'Intermission-Offspring')
    textMusic.pack()
    textMusic.place(relx=1, x=-2, y=30, anchor=Tk.NE)
     
    #Musique de l'utilisateur pour l'ambiance 
    def ouvrirMusic():
    # ouvrir la music qui sera par la suite jouer et classer
    fichier_music = filedialog.askopenfile('r')
    mixer.music.load(fichier_music.name)
    textMusic = Label(fenetre, text = fichier_music.name)
    textMusic.pack()
    textMusic.place(relx=1, x=-2, y=30, anchor=Tk.NE)
     
    def play():
    #Lecture de la musique
    play = mixer.music.play()
    play
     
    def stop():
    #arret de la musique 
    stop = mixer.music.stop()
    stop
     
    def pause():
    #Mise en pause de la musique
    pause = mixer.music.pause()
    pause
     
    #####################Actualisation le la fenetre############################# 
    def actualiser():
    fenetre.mainloop()
     
     
    #############################################################################
    # Programme principal #
    #############################################################################
    mixer.init() 
    fenetre = Tk.Tk()
    w,h = fenetre.winfo_screenwidth(), fenetre.winfo_screenheight()
    fenetre.title('Super Editor') 
    fenetre.geometry("%dx%d+0+0" % (w, h))
    half = 0.2
     
    P = 0
    tableau = []
    for i in range(1000): 
    tableau.append((0,100))
     
     
    boutons()
    musicBase()
    menubar()
    actualiser()
     
    #### Variables ####

  4. #4
    Membre Expert Avatar de PauseKawa
    Homme Profil pro
    Technicien Help Desk, maintenance, réseau, système et +
    Inscrit en
    Juin 2006
    Messages
    2 725
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Technicien Help Desk, maintenance, réseau, système et +
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2006
    Messages : 2 725
    Par défaut
    Citation Envoyé par wiztricks Voir le message
    D'après le message 'File "C:\Users\nom\Desktop\ISN Modificateur Image\Image deforme.py", line 643, in Precedant' => votre script contient déjà 643 lignes.
    Pas grand monde ira essayer de le comprendre si vous le postez (en tout cas pas moi).
    Surtout si vous n'utilisez pas la balise code...
    Sélectionnez votre code et cliquez sur le # au dessus du texte.

  5. #5
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2013
    Messages : 9
    Par défaut
    Citation Envoyé par PauseKawa Voir le message
    Surtout si vous n'utilisez pas la balise code...
    Sélectionnez votre code et cliquez sur le # au dessus du texte.
    Escusez-moi mais je ne comprends pas ou vous voulez en venir ??

    mon problème apparais a cette ligne si :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    image1 = tableau[P] 
    image2 = image1.resize([int(half*t) for t in image1.size]) 
     
    image2 = image1.resize([int(half*t) for t in image1.size]) 
    AttributeError: 'tuple' object has no attribute 'resize'
    dans la fonction : Precedant

    comment pourrais-je convertir la variable pour pouvoir lui attribuer un 'resize' ??? svp ^_^

  6. #6
    Expert confirmé

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 307
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 307
    Par défaut
    Ce que PauseKawa te dit c'est d'éditer ton post contenant ton code en entier et de mettre ce code entre des balises code, soit sélectionner tout le code et cliquer sur le #

    Pour l'erreur, ajoute cette ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    image1 = tableau[P]
    print(image1)              # celle-ci
    image2 = image1.resize([int(half*t) for t in image1.size])
    et regarde ce qu'il en sort.

  7. #7
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2013
    Messages : 9
    Par défaut
    Citation Envoyé par VinsS Voir le message
    Ce que PauseKawa te dit c'est d'éditer ton post contenant ton code en entier et de mettre ce code entre des balises code, soit sélectionner tout le code et cliquer sur le #

    Pour l'erreur, ajoute cette ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    image1 = tableau[P]
    print(image1)              # celle-ci
    image2 = image1.resize([int(half*t) for t in image1.size])
    et regarde ce qu'il en sort.
    Merci ^^ voila donc mon code ^^ :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    def boutons():
    #Bouton ouvrire image
    boutonOuvriImage = Button(fenetre, text = 'Ouvrir Image', command=ouvrir,width=20)
     
    #Bouton ouvrir Musique
    boutonOuvriMusic = Button(fenetre, text = 'Ouvrir Votre Musique', command=ouvrirMusic,width=17)
     
    #Bouton Sauvegarde
    boutonSauvegarde = Button(fenetre, text = 'Sauvegarder Image', command=Sauvegarde,width=20)
     
    #Bouton pour le player
    boutonPlay = Button(fenetre, text = 'Play', command=play)
    boutonPause = Button(fenetre, text = 'Pause',command=pause)
    boutonStop = Button(fenetre, text = 'Stop' ,command=stop)
     
    #Bouton pour l'éditeur
    boutonFiltreNoir = Button(fenetre, text = 'Filtrer en Noir', command=FiltreNoir,width=15)
    boutonFiltreNegatif = Button(fenetre, text = 'Filtrer en Negatif', command=FiltreNegatif,width=15)
    boutonFiltreSepia = Button(fenetre, text = 'Filtrer en Sepia', command=FiltreSepia,width=15)
    boutonFiltreVert = Button(fenetre, text = 'Filtrer en Vert' ,command=filtre_vert,width=15)
    boutonFiltreRouge = Button(fenetre, text = 'Filtrer en Rouge' ,command=filtre_rouge,width=15)
    boutonFiltreBleu = Button(fenetre, text = 'Filtrer en Bleu' ,command=filtre_bleu,width=15)
    boutonFiltreAl = Button(fenetre, text = 'Filtre Aléatoire' ,command=filtre_Al,width=20)
     
    boutonRetourner = Button(fenetre, text = 'Retourner l\'image', command=Retourner,width=15)
    boutonMiroir = Button(fenetre, text = 'Effet Miroir', command=Miroir,width=15)
     
    boutonMiroirColle = Button(fenetre, text = 'Miroir Colle', command=MiroirColle,width=15)
    boutonRetournerColle = Button(fenetre, text = 'Retourner Colle', command=RetournerColle,width=15)
     
    boutonImageOrigine = Button(fenetre, text = 'Retour à l\'image originale', command=ImageOrigine,width=20)
    boutonPrecedant = Button(fenetre, text = 'Précédant', command=Precedant,width=15)
    boutonSuivant = Button(fenetre, text ='Suivant', command=Suivant,width=15)
     
    #Affichier les boutons
    boutonOuvriImage.pack(side=Tk.TOP)
    boutonImageOrigine.pack(side=Tk.TOP)
    boutonFiltreAl.pack(side=Tk.TOP)
    boutonSauvegarde.pack(side=Tk.TOP)
     
    boutonOuvriMusic.pack()
    boutonPlay.pack()
    boutonPause.pack()
    boutonStop.pack()
     
    boutonFiltreNoir.pack()
    boutonFiltreNegatif.pack()
    boutonFiltreSepia.pack()
    boutonFiltreBleu.pack()
    boutonFiltreRouge.pack()
    boutonFiltreVert.pack()
     
    boutonRetourner.pack()
    boutonMiroir.pack()
    boutonMiroirColle.pack()
    boutonRetournerColle.pack()
     
    boutonPrecedant.pack()
    boutonSuivant.pack()
     
     
     
     
    #Placement des boutons 
    boutonOuvriMusic.place(relx=1, x=-2, y=2, anchor=Tk.NE,)
    boutonPlay.place(relx=1, x=-100, y=60, anchor=Tk.NE)
    boutonPause.place(relx=1, x=-46, y=60, anchor=Tk.NE)
    boutonStop.place(relx=1, x=-2, y=60, anchor=Tk.NE)
     
    boutonFiltreNoir.place(x=0)
    boutonFiltreNegatif.place(x=0, y=30)
    boutonFiltreSepia.place(x=0, y=60)
    boutonFiltreBleu.place(x=125,y=0)
    boutonFiltreRouge.place(x=125,y=30)
    boutonFiltreVert.place(x=125,y=60)
     
     
    boutonRetourner.place(x=250,y=0)
    boutonMiroir.place(x=250,y=30)
    boutonMiroirColle.place(x=250,y=60)
    boutonRetournerColle.place(x=375,y=0)
     
    boutonPrecedant.place(relx=1, x=-380, y=2, anchor=Tk.NE)
    boutonSuivant.place(relx=1, x=-260, y=2, anchor=Tk.NE)
     
     
    #########################Menu déroulant###########################################
    # Dans cette fonction nous créons la bar de menu de notre interface avec toutes #
    # les options du programme pour modifier vos image #
    ##################################################################################
    def menubar():
    menu = Menu(fenetre)
    fichiermenu = Menu(menu)
    # liste du menu fichier
    fichiermenu.add_command(label='Ouvrir Image', command=ouvrir)
    fichiermenu.add_command(label='Ouvrir Votre musique', command=ouvrirMusic)
    fichiermenu.add_command(label='Sauvegarder Image', command=Sauvegarde)
    fichiermenu.add_command(label='quitter', command=fenetre.quit)
    # creation menu fichier
    menu.add_cascade(label='fichier', menu=fichiermenu)
     
    edit = Menu(menu)
    #Liste du menu editer
    edit.add_command(label='Filtrer en Noir', command=FiltreNoir)
    edit.add_command(label='Filtrer en Negatif', command=FiltreNegatif)
    edit.add_command(label='Filtrer en Sepia', command=FiltreSepia)
     
    edit.add_command(label='Miroir Colle', command=MiroirColle)
    edit.add_command(label='Retourner Colle', command=RetournerColle)
    #creatipn menu editer
    menu.add_cascade(label='Editer',menu=edit)
     
    fenetre.config(menu=menu)
     
     
    ##########################Ouverture et modification de l'image##############################
     
    ###Ouverture de l'image###
    def ouvrir():
     
    image = filedialog.askopenfile('r')
    global image1
    image1 = Image.open(image.name)
    global imageOrigine
    imageOrigine = image1
     
    global L,H
    (L,H) = image1.size
    if (L>=w) and (H>=h):
     
    image2 = image1.resize([int(half*t) for t in image1.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
     
    imageP = ImageTk.PhotoImage(image1)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
    tableau[0] = image1
     
    ###Fonction de modification##
     
    #Retour à l'image Origininal 
    def ImageOrigine():
     
    if (L>=w) and (H>=h):
     
    image2 = imageOrigine.resize([int(half*t) for t in imageOrigine.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageOrigine)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageOrigine
     
    global P
    P = 0
    global Ps
    Ps = P
     
    #Filtrer l'image alléatoirement
    def filtre_Al():
    filtreAl = randint(1,6)
     
    if (filtreAl == 1):
    FiltreNoir()
     
    if (filtreAl == 2):
    FiltreNegatif ()
     
    if (filtreAl == 3):
    FiltreSepia()
     
    if (filtreAl == 4):
    filtre_rouge()
     
    if (filtreAl == 5):
    filtre_vert()
     
    if (filtreAl == 6):
    filtre_bleu()
     
    filtreAl = 0
     
     
     
    #Application du Filtre noir 
    def FiltreNoir():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
     
    G = int(((p[0]+p[1]+p[2])/3))
     
    imageM.putpixel ((x,y) ,(G,G,G))
     
    if (L>w) and (H>h):
     
    imageM = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(imageM)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
    #Application du Filtre negatif
    def FiltreNegatif ():
     
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    R = 255-p[0]
    G = 255-p[1]
    B = 255-p[2] 
    imageM.putpixel ((x,y) ,(R,G,B))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
     
    #Application du Filtre sepia
    def FiltreSepia():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    R = (25756 * p[0] + 50397 * p[1] + 12386 * p[2]) >> 16
    G = (22872 * p[0] + 44958 * p[1] + 11010 * p[2]) >> 16;
    B = (17826 * p[0] + 34996 * p[1] + 8585 * p[2]) >> 16;
     
    if R < 0: R = 0
    if R > 255: R = 255
     
    if G < 0: G = 0
    if G > 255: G = 255
     
    if B < 0: B = 0
    if B > 255: B = 255
    imageM.putpixel ((x,y) ,(R,G,B))
     
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
    #Application du Filtre vert
    def filtre_vert():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ((x,y) ,(0,p[1],0))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Application du Filtre bleu
    def filtre_bleu():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ((x,y) ,(0,0,p[2]))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
     
    global image1
    image1 = imageM
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Application du Filtre rouge
    def filtre_rouge():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ((x,y) ,(p[0],0,0))
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Retournement de l'image
    def Retourner():
     
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ( ( x,-y+H-1) ,p)
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
     
    #Application de l'effet miroir
    def Miroir():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel ( ( -x+L-1,y) ,p) 
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    #Modification des pixels
    def MiroirColle():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
     
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel((-x+L-1,y) ,p)
    imageM.putpixel((x,y) ,p)
     
     
    if (L>w) and (H>h):
     
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
    def RetournerColle():
     
    global imageM
    imageM = Image.new('RGB',(L,H))
     
    for y in range (0,H,1):
    for x in range (0,L,1):
    p = image1.getpixel((x,y))
    imageM.putpixel((x,-y+H-1) ,p)
    imageM.putpixel((x,y) ,p)
     
    if (L>w) and (H>h):
    image2 = imageM.resize([int(half*t) for t in imageM.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    imageMP = ImageTk.PhotoImage(imageM)
    imageML = Tk.Label(image=imageMP)
    imageML.image = imageMP
    imageML.pack()
    imageML.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    global image1
    image1 = imageM
     
     
    global P
    P = 1+P
    global Ps
    Ps = P
     
    global tableau
    tableau[P] = imageM
     
     
     
    def Precedant():
     
    global image1
    global P
    P = P-1
     
     
    if (L>w) and (H>h) and (P>=0):
     
    image1 = tableau[P]
    image2 = image1.resize([int(half*t) for t in image1.size])
    imageP = ImageTk.PhotoImage(image2)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    if (L<=w) and (H<=h) and (P>=0):
    image1 = tableau[P]
    imageP = ImageTk.PhotoImage(image1)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h-100,width=w)
     
    else:
    P = 0
     
     
    def Suivant():
    global image1
    global P
     
    if(P<Ps):
     
    P = P+1
    image1 = tableau[P]
    imageP = ImageTk.PhotoImage(image1)
    imageL = Tk.Label(image=imageP)
    imageL.image = imageP
    imageL.pack()
    imageL.place(relx=1, x=-670, y=120, anchor=Tk.N,height=h,width=w)
     
    else:
    P = Ps
    ###Sauvegarder image###
    def Sauvegarde():
     
    jpg = options = {}
    options['defaultextension'] = '.jpg'
     
    DossierSauvegarde = filedialog.asksaveasfile('w',**jpg)
     
    imageM.save( DossierSauvegarde.name)
     
     
     
     
    ################################Player########################################
     
    #Musique de base pour l'ambiance
    def musicBase():
    mixer.music.load('Intermission.mp3')
    textMusic = Label(fenetre, text = 'Intermission-Offspring')
    textMusic.pack()
    textMusic.place(relx=1, x=-2, y=30, anchor=Tk.NE)
     
    #Musique de l'utilisateur pour l'ambiance 
    def ouvrirMusic():
    # ouvrir la music qui sera par la suite jouer et classer
    fichier_music = filedialog.askopenfile('r')
    mixer.music.load(fichier_music.name)
    textMusic = Label(fenetre, text = fichier_music.name)
    textMusic.pack()
    textMusic.place(relx=1, x=-2, y=30, anchor=Tk.NE)
     
    def play():
    #Lecture de la musique
    play = mixer.music.play()
    play
     
    def stop():
    #arret de la musique 
    stop = mixer.music.stop()
    stop
     
    def pause():
    #Mise en pause de la musique
    pause = mixer.music.pause()
    pause
     
    #####################Actualisation le la fenetre############################# 
    def actualiser():
    fenetre.mainloop()
     
     
    #############################################################################
    # Programme principal #
    #############################################################################
    mixer.init() 
    fenetre = Tk.Tk()
    w,h = fenetre.winfo_screenwidth(), fenetre.winfo_screenheight()
    fenetre.title('Super Editor') 
    fenetre.geometry("%dx%d+0+0" % (w, h))
    half = 0.2
     
    P = 0
    tableau = []
    for i in range(1000): 
    tableau.append((0,100))
     
     
    boutons()
    musicBase()
    menubar()
    actualiser()
     
    #### Variables ####

  8. #8
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2013
    Messages : 9
    Par défaut
    Citation Envoyé par VinsS Voir le message

    Pour l'erreur, ajoute cette ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    image1 = tableau[P]
    print(image1)              # celle-ci
    image2 = image1.resize([int(half*t) for t in image1.size])
    et regarde ce qu'il en sort.
    voila se que m'indique la console :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    (0, 100)
    Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Python33\lib\tkinter\__init__.py", line 1442, in __call__
        return self.func(*args)
      File "C:\Users\Thomas\Desktop\ISN Modificateur Image\Image deforme.py", line 645, in Precedant
        image2 = image1.resize([int(half*t) for t in image1.size])
    AttributeError: 'tuple' object has no attribute 'resize'
    alors qu'il devrait y avoir :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <JpegImagePlugin.JpegImageFile image mode=RGB size=288x384 at 0x3D08F98>
    c'est juste un exemple

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Python 3.X] Problème avec Tkinter: AttributeError: 'function' object has no attribute 'tk'
    Par Ziph0n dans le forum Général Python
    Réponses: 1
    Dernier message: 01/02/2015, 16h41
  2. AttributeError "nonetype" object has no attribute
    Par Invité dans le forum Général Python
    Réponses: 2
    Dernier message: 14/12/2010, 20h49
  3. Selenium - AttributeError: 'module' object has no attribute
    Par bender1979 dans le forum Général Python
    Réponses: 4
    Dernier message: 09/11/2010, 22h03
  4. Probleme : AttributeError: 'tuple' object has no attribute
    Par MrGecko dans le forum Général Python
    Réponses: 1
    Dernier message: 27/05/2007, 09h59
  5. Réponses: 2
    Dernier message: 26/05/2006, 14h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo