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

Tkinter Python Discussion :

passer une fonction en variable


Sujet :

Tkinter Python

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Points : 79
    Points
    79
    Par défaut passer une fonction en variable
    Bonjour,

    Je suis débutant en python, je suis sur la version 2.7.3
    j'utilise Tkinter.

    j'ai fait une fonction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    def test_resolution():
        #system('xrandr -q | grep "Screen 0" | cut -c38-47') #Kubuntu 14.04 LTS x64
        system('xrandr -q | grep "Screen 0" | cut -c34-44') #Kubuntu 12.04 LTS x64

    Mais je n'arrive pas a passer ma fonction en variable
    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
     
    r = (test_resolution()
    print "r : ", r
    if r=="1920 x 1080":
        print "Resolution = 1920 x 1080"
        i = 4
        n = 4
    if r=="3286 x 1080":
        print "Resolution = 3286 x 1080"
        i = 3
        n = 3
    if r=="5264 x 1050":
        print "Resolution = 5264 x 1050"
        i =2
        n = 2
    ça marche pas.
    Comment dois-je faire ?

    Merci.
    Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
    DreamPlug | 512 mo ram | SSD 16 GO | Linux debian 2.6.39.4 | armv5tel | Lamp | PHP 5.3.3-7 | Apache 2.2.16 | Mysql 14.14

  2. #2
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 046
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 046
    Points : 1 376
    Points
    1 376
    Par défaut
    La fonction ne retourne rien ...

  3. #3
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 281
    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 281
    Points : 36 768
    Points
    36 768
    Par défaut
    Salut,

    Je suis désolé mais je ne comprends pas du tout ce que vous essayez de faire.
    Ceci dit si vous utilisez Tk, vous pouvez récupérer calculer résolution de l'écran via les méthodes .winfo_screenwidth(), winfo_screenheight() et .winfo_screenmmwidth(), winfo_screenmmheight().
    Regardez ce que retourne Google pour des exemples.

    note: la résolution est un nombre de pixels par unité de surface (exprimé en "inch").

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Points : 79
    Points
    79
    Par défaut
    Bonsoir,

    Oui la fonction répond :
    Quand je fait ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    import Tkinter as tkinter
    fenetre = tkinter.Tk()
    width = fenetre.winfo_screenwidth()
    height = fenetre.winfo_screenheight()
    print width, height
    r = width , height
    j'ai ce message qui s'affiche :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Traceback (most recent call last):
      File "fenetre-image-7.py", line 619, in <module>
        panel1 = tk.Label(fenetre, image=image1)
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2478, in __init__
        Widget.__init__(self, master, 'label', cnf, kw)
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1977, in __init__
        (widgetName, self._w) + extra + self._options(cnf))
    _tkinter.TclError: image "pyimage1" doesn't exist
    La ligne 619 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    panel1 = tk.Label(fenetre, image=image1)
    Je ne trouve pas la raison de ce message.
    Et quand je retire le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    import Tkinter as tkinter
    fenetre = tkinter.Tk()
    width = fenetre.winfo_screenwidth()
    height = fenetre.winfo_screenheight()
    print width, height
    r = width , height
    mon appli fonctionne, mais j'ai pas la résolution ??

    wiztricks à ecrit :
    Je suis désolé mais je ne comprends pas du tout ce que vous essayez de faire
    J'essaie de connaitre la résolution. En fonction de la solution, au démarrage de l'appli, j'affiche une autre image redimentionné.

    Merci.
    Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
    DreamPlug | 512 mo ram | SSD 16 GO | Linux debian 2.6.39.4 | armv5tel | Lamp | PHP 5.3.3-7 | Apache 2.2.16 | Mysql 14.14

  5. #5
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 281
    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 281
    Points : 36 768
    Points
    36 768
    Par défaut
    Salut,

    Citation Envoyé par xunil2003 Voir le message
    Bonsoir,

    Oui la fonction répond :
    Vous confondez l'appel de la "fonction affiche" et la "fonction retourne".

    Citation Envoyé par xunil2003 Voir le message
    Quand je fait ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    import Tkinter as tkinter
    fenetre = tkinter.Tk()
    width = fenetre.winfo_screenwidth()
    height = fenetre.winfo_screenheight()
    print width, height
    r = width , height
    j'ai ce message qui s'affiche :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Traceback (most recent call last):
      File "fenetre-image-7.py", line 619, in <module>
        panel1 = tk.Label(fenetre, image=image1)
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2478, in __init__
        Widget.__init__(self, master, 'label', cnf, kw)
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1977, in __init__
        (widgetName, self._w) + extra + self._options(cnf))
    _tkinter.TclError: image "pyimage1" doesn't exist
    La ligne 619 :
    Si lorsque vous exécutez:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    import Tkinter as tkinter
    fenetre = tkinter.Tk()
    width = fenetre.winfo_screenwidth()
    height = fenetre.winfo_screenheight()
    print width, height
    r = width , height
    vous avez une erreur à la ligne 619 du script "fenetre-image-7.py", c'est que vous avez fait autre chose...

    Sans un minimum de rigueur pour "dire ce que vous faites" et "faire ce que vous avez dit", pas facile de vous aider...

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Points : 79
    Points
    79
    Par défaut
    Bonjour wiztricks,

    Mon appli est une télécommande lan.
    Je voudrais détecter la résolution au démarrage de l'appli et en fonction de la résolution détecté, afficher les images redimensionnées pour cette résolution.
    Le code ne passe pas en entier, pour l'envoier par mail, il me faut votre adresse mail.
    Je n'ai pas trouvé la raison du message d'erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Traceback (most recent call last):
      File "fenetre-image-7.py", line 619, in <module>
        panel1 = tk.Label(fenetre, image=image1)
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2478, in __init__
        Widget.__init__(self, master, 'label', cnf, kw)
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1977, in __init__
        (widgetName, self._w) + extra + self._options(cnf))
    _tkinter.TclError: image "pyimage1" doesn't exist
    avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    width = fenetre.winfo_screenwidth()
    height = fenetre.winfo_screenheight()
    Merci.
    Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
    DreamPlug | 512 mo ram | SSD 16 GO | Linux debian 2.6.39.4 | armv5tel | Lamp | PHP 5.3.3-7 | Apache 2.2.16 | Mysql 14.14

  7. #7
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 281
    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 281
    Points : 36 768
    Points
    36 768
    Par défaut
    Salut,

    La cause la plus probable est que vous ayez lancé plusieurs instances de Tk, i.e. effectué plusieurs fois "tkinter.Tk()" dans votre code.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  8. #8
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Points : 79
    Points
    79
    Par défaut
    Re,

    Non j'ai qu'une instance dans le code.
    j'ai vérifié en effectuant une recherche avec kate.

    Merci.
    Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
    DreamPlug | 512 mo ram | SSD 16 GO | Linux debian 2.6.39.4 | armv5tel | Lamp | PHP 5.3.3-7 | Apache 2.2.16 | Mysql 14.14

  9. #9
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Points : 79
    Points
    79
    Par défaut
    Re,

    Voici le 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
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    #!/usr/bin/PYTHON
    # -*-coding:utf-8 -*
     
    from Tkinter import*
    import os
    import Tkinter as tk
    from PIL import Image, ImageTk
    from os import system
    from os.path import expanduser
    from os.path import join
    from os.path import exists
    import urllib2
     
     
    #---------- Configuration ----------
    code_tlc = 'xxxxxxxx' # Code télécommande
    appui = "true" # Pour un appui prolongé
    appui_long = 'false'
    appui_cour = 'true'
    repeat= "<n>" # Pour un appui répété
    boitier = "hd2.freebox.fr" # Pour commander le deuxième boitier.
    # doc : http://ng.babeuk.net/index.php/General
     
     
    #def test_resolution():
        #system('xrandr -q | grep "Screen 0" | cut -c38-47')
        #system('xrandr -q | grep "Screen 0" | cut -c34-44') #Kubuntu 12.04 LTS x64 
     
     
     
    import Tkinter as tkinter
    fenetre = tkinter.Tk()
    width_1 = fenetre.winfo_screenwidth()
    height_1 = fenetre.winfo_screenheight()
    #width_1 = fenetre.winfo_screenmmwidth()
    #height_1 = fenetre.winfo_screenmmheight()
    print width_1, height_1
    r = width_1 , height_1
     
     
    if r==(1920, 1080):
        print "Resolution = 1920 x 1080"
        print "PC portable msi natalie."
        print "essai n° 1"
        i = 4
        n = 4
    if r=="1920 x 1080":
        print "Resolution = 1920 x 1080"
        print "PC portable msi natalie."
        print "essai n° 1-2"
        i = 4
        n = 4
    if r==(3286, 1080):
        print "Resolution = 3286 x 1080"
        print "PC portable medion natalie."
        print "essai n° 2"
    if r==(5264, 1050):
        print "Resolution = 5264 x 1050"
        print "PC fixe bureau asus laurent."
        print "essai n° 3"
    if r==5:
        print "Quitter"
        quit()
    else:
        print("nErreur de saissi ou choix incorrect")
     
    print
    #i = 4
    #n = 4
    print "r : ", r 
    print "i : ", i 
    print "n : ", n
    print  
     
     
    def resolution():
      title="Telecommande Freebox V5"
      fenetre = tk.Tk()
      fenetre.resizable(0,0) # Non redimensionnable
      #fenetre.resizable(width=False, height=False)# bloquer le redimensionnement
      fenetre.title(title)
      #fenetre.geometry("800x600+300+150")
      #fenetre.configure(width = 300, height = 150)
      #fenetre.wm_iconbitmap('icone_telecommande_freebox_v5.ico')
      return fenetre
     
     
    def add_button(panel, image_button, x, y, command=None):
      #button2 = tk.Button(panel, image=image_button, width=image_button.width(), height=image_button.height(), bd=0, command=command)
      button2 = tk.Button(panel, image=image_button, width=image_button.width()-2, height=image_button.height()-2, bd=0, command=command, highlightthickness=0, padx=0, pady=0, relief=tk.FLAT)
      #button2 = tk.Button(panel, image=image_button, width=image_button.width()-2, height=image_button.height()-2, bd=0, command=command, padx=0, pady=0)
      button2.place(x=x, y=y)
      #print x
      #print y
     
    def add_image(url_image):
      image_button = Image.open(url_image)
      return ImageTk.PhotoImage(image_button)
     
     
    def verif_fichier_cfg():
        #---------- Chemin du home directory courant ----------
     
        home = expanduser('~/')  
        print "Le compte utilisateur est : ",(home)
        print "" 
     
        #---------- Indique le chemin complet au fichier depuis le home directory courant ----------
        chemin = join(home, ".test2/config.cfg")
        print "Le chemin complet au fichier de configuration cfg est :",chemin
        print ""
     
        #---------- création du repertire si il n'existe pas ----------
        rep = join(home, ".test2")
        if not exists(rep):
        print "Le répertoire",rep, " n'existé pas."
        print "Création du répertoire",rep
        os.mkdir(rep)
        print ""   	
        else:
        print "Le répertoire",rep, "existe."
        print ""
     
     
        #---------- création du fichier si il n'existe pas ----------
        #import os
        #chemin = home,.kcalorie
        if not exists(chemin):    #remplacer chemin par le chemin complet
        print "Le fichier",chemin, " n'existé pas."
        print "Création du fichier",chemin
        print "" 
        fichier = open(chemin,'wb')
        fichier.close()  
        else:
        print "Le fichier",chemin, "existe déja."
        print ""  
        verif_fichier_cfg() # Exécute la fonction : verif_fichier_cfg
     
    def initialiser (root):
        #labelValider.config(text = "")
        reponse1.delete (0, END)
        reponse2.delete (0, END)
     
     
    def configuration():
        global reponse1, reponse2
        import Tkinter
        root = Toplevel(fenetre)
        texte1 = Label(root, text = 'nBoitier n° :')
        reponse1 = Entry(root) 
        affichage = Label(root, width=30)
        saisie1=Label(root, text='Vous êtes sur le boitier n° :')
        texte1.pack()
        reponse1.pack()
        texte2 = Label(root, text = 'nCode télécommande :')
        reponse2 = Entry(root)
        texte3 = Label(root, text = ' ')
        bouton2 = Button(root, text ='Valider', command=modif_cfg)
        home = expanduser('~')
        path = join(home, ".test2")
        chemin = join(path, "config.cfg")
        config_file = open(chemin,'r')
        file_content = config_file.read()
        config_file.close()
        if ";" in file_content : 
        datas = file_content.split(';')
        reponse1.delete(0,END)
        reponse1.insert(0,datas[0])
        reponse2.delete(0,END)
        reponse2.insert(0,datas[1])
        affichage = Label(root, width=30)
        saisie2=Label(root, text='nVous êtes sur le boitier n° :')
        texte2.pack()
        reponse2.pack()
        texte3.pack()
        bouton2.pack()
        saisie2.pack()
        affichage.pack()
        root.mainloop() 
     
     
    def modif_cfg():
        global reponse1, reponse2
        home = expanduser('~')
        path = join(home, ".test2")
        chemin = join(path, "config.cfg")
        parameters = list()
        parameters.append(reponse1.get())
        parameters.append(reponse2.get())
        file_content = ";".join(parameters)
        config_file = open(chemin,'wb')
        config_file.write(file_content)
        config_file.close()
        print "nouveau : "+file_content
     
        #---------- Chemin du home directory courant ----------
    #    from os.path import expanduser
    #    home = expanduser('~/')  
    #    print "Compte utilisateur : ",(home)
    #    print ""
     
        #---------- Indique le chemin complet au fichier depuis le home directory courant ----------
    #    from os.path import expanduser
    #    import os
    #    chemin = join(home, ".test2/config.cfg")
    #    print "Chemin complet au fichier de configuration cfg :",chemin
    #    print ""
     
        #---------- création d'un dictionnaire ----------
    #    import pickle
    #    #box = {freebox_hd:reponse.get()}
    #    #box = {36:'Indre',30:'Gard',75:'Paris'}
    #    box = { test }
    #    print "box :", box
     
    #    test1 = reponse1.get() # on recupere le texte saisi et le met 
    #    test2 = reponse2.get() # on recupere le texte saisi et le met 
    #    #test['text'] = reponse.get()
    #    print "reponse1.get() :", reponse1.get() # on recupere et affiche le texte saisi1
    #    print "reponse2.get() :", reponse2.get() # on recupere et affiche le texte saisi2
     
     
        # enregistrement du dictionnaire dans un fichier
        #Fichier = open(chemin,'wb')
    #    Fichier = open(chemin, "w") # écrase tout !
    #    Fichier.write( test1,test2 )
    #    Fichier.close()
     
     
    def get_parameters():
        home = expanduser('~')
        path = join(home, ".test2")
        chemin = join(path, "config.cfg")
     
        config_file = open(chemin,'r')
        file_content = config_file.read()
        config_file.close()
     
        if ";" in file_content : 
    	datas = file_content.split(';')
    	return datas
     
        return None
     
    def touche_Cote_Droit_R():
        print "Touche R"
        datas = get_parameters()
        if datas is not None :
          system('curl "http://hd'+datas[0]+'.freebox.fr/pub/remote_control?code='+datas[0]+'&key=????????????????&long=false"')
        #exit(0)
     
    def touche_Rond_Rouge_B():
        print "Touche B"
        url = "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=red&long=false"
        try:
          response = urllib2.urlopen(url, timeout=1)
          response.read()
        except urllib2.HTTPError as e:
          print e.code
          erreur_http()
        except urllib2.URLError as e:
          print e.args
          erreur_url(str(e.args))
        #exit(0)
     
    def touche_Rond_Jaune_Y():
        print "Touche Y"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=yellow&long=false"')
        #exit(0)
     
    def touche_Rond_Vert_A():
        print "Touche A"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=green&long=false"')
        #exit(0)
     
    def touche_Rond_Bleu_X():
        print "Touche X"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=blue&long=false"')
        #exit(0)
     
    def touche_Select():
        print "Touche Select"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=?????????????&long=false"')
        #exit(0)
     
    def touche_On_Off():
        print "touche On/Off"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=power&long=false"')
        #exit(0)
     
    def touche_liste():
        print "Touche_Liste"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=list&long=false"')
        #exit(0)
     
    def touche_TV():
        print "Touche TV"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=tv&long=false"')
        #exit(0) 
     
    def touche_1():
        print "Touche 1"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=1&long=false"')
        #exit(0)
     
    def touche_2():
        print "Touche 2"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=2&long=false"')
        #exit(0)
     
    def touche_3():
        print "Touche 3"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=3&long=false"')
        #exit(0)
     
    def touche_INFO():
        print "Touche INFO"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=info&long=false"')
        #exit(0)
     
    def touche_4():
        print "Touche 4"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=4&long=false"')
        #exit(0)
     
    def touche_5():
        print "Touche 5"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=5&long=false"')
        #exit(0)
     
     
    def touche_6():
        print "Touche 6"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=6&long=false"')
        #exit(0)
     
    def touche_MAIL():
        print "Touche MAIL"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=mail&long=false"')
        #exit(0)
     
    def touche_7():
        print "Touche 7"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=7&long=false"')
        #exit(0)
     
    def touche_8():
        print "Touche 8"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=8&long=false"')
        #exit(0)
     
    def touche_9():
        print "Touche 9"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=9&long=false"')
        #exit(0)
     
    def touche_Back():
        print "Touche Back"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=back&long=false"')
        #exit(0)
     
    def touche_0():
        print "Touche 0"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=0&long=false"')
        #exit(0)
     
    def touche_Swap():
        print "Touche Swap"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=swap&long=false"')
        #exit(0)
     
    def touche_HELP():
        print "Touche HELP"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=help&long=false"')
        #exit(0)
     
    def touche_0():
        print "Touche 0"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=0&long=false"')
        #exit(0)
     
    def touche_PIP():
        print "Touche PIP"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=pip&long=false"')
        #exit(0)
     
    def touche_volume_plus():
        print "Touche volume +"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=vol_inc&long=false"')
        #exit(0)
     
    def touche_volume_moins():
        print "Touche volume -"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=vol_dec&long=false"')
        #exit(0)
     
    def touche_fleche_gauche():
        print "Touche fleche gauche"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=left&long=false"')
        #exit(0)
     
    def touche_fleche_haut():
        print "Touche fleche haut"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=up&long=false"')
        #exit(0) 
     
    def touche_OK():
        print "Touche Ok"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=ok&long=false"')
        #system("firefox")
        #exit(0) 
     
    def touche_fleche_bas():
        print "Touche fleche bas"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=down&long=false"')
        #exit(0) 
     
    def touche_fleche_droite():
        print "Touche fleche droite"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=right&long=false"')
        #exit(0)
     
     
    def touche_programme_plus():
        print "Touche Programme +"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=prgm_inc&long=false"')
        #exit(0)
     
    def touche_programme_moins():
        print "Touche Programme -"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=prgm_dec&long=false"')
        #exit(0)
     
    def touche_mute():
        print "Touche mute"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=mute&long=false"')
        #exit(0)
     
    def touche_free():
        print "Touche Free"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=home&long=false"')
        #exit(0)
     
    def touche_rec():
        print "Touche Programme rec"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=rec&long=false"')
        #exit(0)    
     
    def touche_retour_arriere(): # (<<)
        print "Touche Retour_arriere (<<)"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=bwd&long=false"')
        #exit(0)     
     
    def touche_precedent(): #  (|<<)
        print "Touche precedent (|<<)"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=prev&long=false"')
        #exit(0)    
     
    def touche_lecture_pause():
        print "Touche Lecture pause (>II)"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=play&long=false"')
        #exit(0) 
     
    def touche_Stop():
        print "Touche Stop ([])"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=stop&long=false"')
        #exit(0) 
     
    def touche_avance_rapide(): # (>>)
        print "Touche Avance rapide (>>)"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=fwd&long=false"')
        #exit(0)     
     
    def touche_suivant(): #  (|>>)
        print "Touche Lecture suivant (|>>)"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=next&long=false"')
        #exit(0)     
     
     
    def touche_Start():
        print "Touche Start"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=rec&long=false"')
        #exit(0) 
     
    def touche_directionnel_haut():
        print "Touche directionnel haut"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=rec&long=false"')
        #exit(0) 
     
    def touche_directionnel_gauche():
        print "Touche directionnel gauche"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=rec&long=false"')
        #exit(0)
     
    def touche_directionnel_droite():
        print "Touche directionnel droite"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=rec&long=false"')
        #exit(0)
     
    def touche_directionnel_bas():
        print "Touche directionnel bas"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=rec&long=false"')
        #exit(0)
     
    def touche_L():
        print "Touche L"
        system('curl "http://hd1.freebox.fr/pub/remote_control?code=43578145&key=L&long=false"')
        #exit(0)
     
    def touche_quitter():
        print "Touche Programme quitter"
        quit()
        #exit(0) 
     
    if __name__ == '__main__' : 
     
     
      fenetre = resolution()
     
      # pick a .gif image file you have in the working directory
      #'telecommande-freebox-hd-1_' ,i, '.jpg'
      nom_fichier = "telecommande-freebox-hd-1_%s.jpg" % i
      print nom_fichier
     
      image = Image.open(nom_fichier)
      image1 = ImageTk.PhotoImage(image)
      w = image1.width()
      h = image1.height()
     
     
      fenetre.geometry("%dx%d+0+0" % (w, h))
     
      # tk.Frame has no image argument
      # so use a label as a panel/frame
      panel1 = tk.Label(fenetre, image=image1)
      panel1.pack(side='top', fill='both', expand='yes')
     
     
      nom_fichier_bouton_R = "bt-R_%s.jpg" % i
      print nom_fichier_bouton_R
      image_bouton_R = add_image(nom_fichier_bouton_R)
     
      nom_fichier_bouton_B = "bt-B-rouge_%s.jpg" % i
      print nom_fichier_bouton_B
      image_bouton_B = add_image(nom_fichier_bouton_B)
     
      nom_fichier_bouton_Y = "bt-Y-jaune_%s.jpg" % i
      print nom_fichier_bouton_Y
      image_bouton_Y = add_image(nom_fichier_bouton_Y)
     
      nom_fichier_bouton_A = "bt-A-vert_%s.jpg" % i
      print nom_fichier_bouton_A
      image_bouton_A = add_image(nom_fichier_bouton_A)
     
      nom_fichier_bouton_X = "bt-X-bleu_%s.jpg" % i
      print nom_fichier_bouton_X
      image_bouton_X = add_image(nom_fichier_bouton_X)
     
      nom_fichier_bouton_select = "bt-select_%s.jpg" % i
      print nom_fichier_bouton_select
      image_bouton_select = add_image(nom_fichier_bouton_select)
     
      nom_fichier_bouton_on_off = "bt-on_off_%s.jpg" % i
      print nom_fichier_bouton_on_off
      image_bouton_on_off = add_image(nom_fichier_bouton_on_off)
     
      nom_fichier_bouton_list = "bt-list_%s.jpg" % i
      print nom_fichier_bouton_list
      image_bouton_list = add_image(nom_fichier_bouton_list)
     
      nom_fichier_bouton_tv = "bt-tv_%s.jpg" % i
      print nom_fichier_bouton_tv
      image_bouton_tv = add_image(nom_fichier_bouton_tv)
     
      nom_fichier_bouton_1 = "bt-1_%s.jpg" % i
      print nom_fichier_bouton_1
      image_bouton_1 = add_image(nom_fichier_bouton_1)
     
      nom_fichier_bouton_2 = "bt-2_%s.jpg" % i
      print nom_fichier_bouton_2
      image_bouton_2 = add_image(nom_fichier_bouton_2)
     
      nom_fichier_bouton_3 = "bt-3_%s.jpg" % i
      print nom_fichier_bouton_3
      image_bouton_3 = add_image(nom_fichier_bouton_3)
     
      nom_fichier_bouton_4 = "bt-4_%s.jpg" % i
      print nom_fichier_bouton_4
      image_bouton_4 = add_image(nom_fichier_bouton_4)
     
      nom_fichier_bouton_5 = "bt-5_%s.jpg" % i
      print nom_fichier_bouton_5
      image_bouton_5 = add_image(nom_fichier_bouton_5)
     
      nom_fichier_bouton_6 = "bt-6_%s.jpg" % i
      print nom_fichier_bouton_6
      image_bouton_6 = add_image(nom_fichier_bouton_6)
     
      nom_fichier_bouton_7 = "bt-7_%s.jpg" % i
      print nom_fichier_bouton_7
      image_bouton_7 = add_image(nom_fichier_bouton_7)
     
      nom_fichier_bouton_8 = "bt-8_%s.jpg" % i
      print nom_fichier_bouton_8
      image_bouton_8 = add_image(nom_fichier_bouton_8)
     
      nom_fichier_bouton_9 = "bt-9_%s.jpg" % i
      print nom_fichier_bouton_9
      image_bouton_9 = add_image(nom_fichier_bouton_9)
     
      nom_fichier_bouton_0 = "bt-0_%s.jpg" % i
      print nom_fichier_bouton_0
      image_bouton_0 = add_image(nom_fichier_bouton_0)
     
      nom_fichier_bouton_info = "bt-INFO_%s.jpg" % i
      print nom_fichier_bouton_info
      image_bouton_info = add_image(nom_fichier_bouton_info)
     
      nom_fichier_bouton_mail = "bt-MAIL_%s.jpg" % i
      print nom_fichier_bouton_mail
      image_bouton_mail = add_image(nom_fichier_bouton_mail)
     
      nom_fichier_bouton_help = "bt-HELP_%s.jpg" % i
      print nom_fichier_bouton_help
      image_bouton_help = add_image(nom_fichier_bouton_help)
     
      nom_fichier_bouton_back = "bt-Back_%s.jpg" % i
      print nom_fichier_bouton_back
      image_bouton_Back = add_image(nom_fichier_bouton_back)
     
      nom_fichier_bouton_swap = "bt-Swap_%s.jpg" % i
      print nom_fichier_bouton_swap
      image_bouton_Swap = add_image(nom_fichier_bouton_swap)
     
      nom_fichier_bouton_pip = "bt-Swap_%s.jpg" % i
      print nom_fichier_bouton_pip
      image_bouton_PIP = add_image(nom_fichier_bouton_pip)
     
      nom_fichier_bouton_volume_plus = "bt-volume-plus_%s.jpg" % i
      print nom_fichier_bouton_volume_plus
      image_bouton_vol_plus = add_image(nom_fichier_bouton_volume_plus)
     
      nom_fichier_bouton_volume_moins = "bt-volume-moins_%s.jpg" % i
      print nom_fichier_bouton_volume_moins
      image_bouton_vol_moins = add_image(nom_fichier_bouton_volume_moins)
     
      nom_fichier_bouton_fleche_haut = "bt-fleche-haut_%s.jpg" % i
      print nom_fichier_bouton_fleche_haut
      image_bouton_fleche_haut = add_image(nom_fichier_bouton_fleche_haut)
     
      nom_fichier_bouton_fleche_gauche = "bt-fleche-gauche_%s.jpg" % i
      print nom_fichier_bouton_fleche_gauche
      image_bouton_fleche_gauche = add_image(nom_fichier_bouton_fleche_gauche)
     
      nom_fichier_bouton_ok = "bt-ok_%s.jpg" % i
      print nom_fichier_bouton_ok
      image_bouton_ok = add_image(nom_fichier_bouton_ok)
     
      nom_fichier_bouton_fleche_droite = "bt-fleche-droite_%s.jpg" % i
      print nom_fichier_bouton_fleche_droite
      image_bouton_fleche_droite = add_image(nom_fichier_bouton_fleche_droite)
     
      nom_fichier_bouton_fleche_bas = "bt-fleche-bas_%s.jpg" % i
      print nom_fichier_bouton_fleche_bas
      image_bouton_fleche_bas = add_image(nom_fichier_bouton_fleche_bas)
     
      nom_fichier_bouton_programmes_plus = "bt-programmes-plus_%s.jpg" % i
      print nom_fichier_bouton_programmes_plus
      image_bouton_prog_plus = add_image(nom_fichier_bouton_programmes_plus)
     
      nom_fichier_bouton_programmes_moins = "bt-programmes-moins_%s.jpg" % i
      print nom_fichier_bouton_programmes_moins
      image_bouton_prog_moins = add_image(nom_fichier_bouton_programmes_moins)
     
      nom_fichier_bouton_mute = "bt-mute_%s.jpg" % i
      print nom_fichier_bouton_mute
      image_bouton_mute = add_image(nom_fichier_bouton_mute)
     
      nom_fichier_bouton_free = "bt-free_%s.jpg" % i
      print nom_fichier_bouton_free
      image_bouton_free = add_image(nom_fichier_bouton_free)
     
      nom_fichier_bouton_rec = "bt-rec_%s.jpg" % i
      print nom_fichier_bouton_rec
      image_bouton_rec = add_image(nom_fichier_bouton_rec)
     
      nom_fichier_bouton_retour_arriere = "bt-retour-arriere_%s.jpg" % i
      print nom_fichier_bouton_retour_arriere
      image_bouton_retour_arriere = add_image(nom_fichier_bouton_retour_arriere)
     
      nom_fichier_bouton_lecture_pause = "bt-lecture-pause_%s.jpg" % i
      print nom_fichier_bouton_lecture_pause
      image_bouton_lecture_pause = add_image(nom_fichier_bouton_lecture_pause)
     
      nom_fichier_bouton_stop = "bt-stop_%s.jpg" % i
      print nom_fichier_bouton_stop
      image_bouton_stop = add_image(nom_fichier_bouton_stop)
     
      nom_fichier_bouton_avance_rapide = "bt-avance-rapide_%s.jpg" % i
      print nom_fichier_bouton_avance_rapide
      image_bouton_avance_rapide = add_image(nom_fichier_bouton_avance_rapide)
     
      nom_fichier_bouton_precedent = "bt-precedent_%s.jpg" % i
      print nom_fichier_bouton_precedent
      image_bouton_precedent = add_image(nom_fichier_bouton_precedent)
     
      nom_fichier_bouton_suivant = "bt-suivant_%s.jpg" % i
      print nom_fichier_bouton_suivant
      image_bouton_suivant = add_image(nom_fichier_bouton_suivant)
     
      nom_fichier_bouton_start = "bt-start_%s.jpg" % i
      print nom_fichier_bouton_start
      image_bouton_start = add_image(nom_fichier_bouton_start)
     
      nom_fichier_bouton_directionnel_haut = "bt-directionnel_haut_%s.jpg" % i
      print nom_fichier_bouton_directionnel_haut
      image_bouton_directionnel_haut = add_image(nom_fichier_bouton_directionnel_haut)
     
      nom_fichier_bouton_directionnel_gauche = "bt-directionnel_gauche_%s.jpg" % i
      print nom_fichier_bouton_directionnel_gauche
      image_bouton_directionnel_gauche = add_image(nom_fichier_bouton_directionnel_gauche)
     
      nom_fichier_bouton_directionnel_droite = "bt-directionnel_droite_%s.jpg" % i
      print nom_fichier_bouton_directionnel_droite
      image_bouton_directionnel_droite = add_image(nom_fichier_bouton_directionnel_droite)
     
      nom_fichier_bouton_directionnel_bas = "bt-directionnel_bas_%s.jpg" % i
      print nom_fichier_bouton_directionnel_bas
      image_bouton_directionnel_bas = add_image(nom_fichier_bouton_directionnel_bas)
     
      nom_fichier_bouton_L = "bt-L_%s.jpg" % i
      print nom_fichier_bouton_L
      image_bouton_L = add_image(nom_fichier_bouton_L)
     
     
    if n==resolution:
        print("0 - Résolution : (1920 x 1080)")
        print "partie non terminé"
    if n==1:
        print("1 - Résolution : (800 x 600)")
        print "partie non terminé"
    if n==2:
        print("2 - Résolution : ( 1920 x 1080)")
        print "partie non terminé"
    if n==3:
        print("3 - Résolution : (3286 x 1080)")
        add_button(panel=panel1, image_button=image_bouton_R, x=0, y=64, command=touche_Cote_Droit_R)
        add_button(panel=panel1, image_button=image_bouton_R, x=0, y=64, command=touche_Cote_Droit_R)
        add_button(panel=panel1, image_button=image_bouton_B, x=103, y=41, command=touche_Rond_Rouge_B)
        add_button(panel=panel1, image_button=image_bouton_Y, x=50, y=94, command=touche_Rond_Jaune_Y)
        add_button(panel=panel1, image_button=image_bouton_A, x=153, y=94, command=touche_Rond_Vert_A)  
        add_button(panel=panel1, image_button=image_bouton_X, x=99, y=145, command=touche_Rond_Bleu_X)
        add_button(panel=panel1, image_button=image_bouton_select, x=35, y=170, command=touche_Select)
        add_button(panel=panel1, image_button=image_bouton_on_off, x=28, y=234, command=touche_On_Off)
        add_button(panel=panel1, image_button=image_bouton_list, x=100, y=244, command=touche_liste)
        add_button(panel=panel1, image_button=image_bouton_tv, x=188, y=237, command=touche_TV)
        add_button(panel=panel1, image_button=image_bouton_1, x=32, y=286, command=touche_1) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_2, x=82, y=285, command=touche_2) 
        add_button(panel=panel1, image_button=image_bouton_3, x=134, y=286, command=touche_3) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_info, x=185, y=286, command=touche_INFO)
        add_button(panel=panel1, image_button=image_bouton_4, x=32, y=321, command=touche_4) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_5, x=85, y=319, command=touche_5) 
        add_button(panel=panel1, image_button=image_bouton_6, x=136, y=320, command=touche_6) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_mail, x=187, y=321, command=touche_MAIL)
        add_button(panel=panel1, image_button=image_bouton_7, x=34, y=355, command=touche_7) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_8, x=85, y=355, command=touche_8) 
        add_button(panel=panel1, image_button=image_bouton_9, x=134, y=355, command=touche_9) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_help, x=187, y=355, command=touche_HELP)
        add_button(panel=panel1, image_button=image_bouton_Back, x=34, y=388, command=touche_Back)
        add_button(panel=panel1, image_button=image_bouton_0, x=84, y=387, command=touche_0)
        add_button(panel=panel1, image_button=image_bouton_Swap, x=134, y=388, command=touche_Swap)
        add_button(panel=panel1, image_button=image_bouton_PIP, x=187, y=388, command=touche_PIP)
        add_button(panel=panel1, image_button=image_bouton_vol_plus, x=30, y=445, command=touche_volume_plus)
        add_button(panel=panel1, image_button=image_bouton_vol_moins, x=30, y=502, command=touche_volume_moins)
        add_button(panel=panel1, image_button=image_bouton_fleche_haut, x=104, y=436, command=touche_fleche_haut)
        add_button(panel=panel1, image_button=image_bouton_fleche_gauche, x=71, y=473, command=touche_fleche_gauche)
        add_button(panel=panel1, image_button=image_bouton_ok, x=108, y=475, command=touche_OK)
        add_button(panel=panel1, image_button=image_bouton_fleche_droite, x=146, y=472, command=touche_fleche_droite)
        add_button(panel=panel1, image_button=image_bouton_fleche_bas, x=104, y=514, command=touche_fleche_bas)
     
        add_button(panel=panel1, image_button=image_bouton_prog_plus, x=196, y=445, command=touche_programme_plus)
        add_button(panel=panel1, image_button=image_bouton_prog_moins, x=197, y=501, command=touche_programme_moins)
        add_button(panel=panel1, image_button=image_bouton_mute, x=29, y=564, command=touche_mute)
        add_button(panel=panel1, image_button=image_bouton_free, x=95, y=565, command=touche_free)
        add_button(panel=panel1, image_button=image_bouton_rec, x=185, y=564, command=touche_rec)
     
        add_button(panel=panel1, image_button=image_bouton_retour_arriere, x=29, y=604, command=touche_retour_arriere)
        add_button(panel=panel1, image_button=image_bouton_lecture_pause, x=82, y=618, command=touche_lecture_pause)
        add_button(panel=panel1, image_button=image_bouton_stop, x=134, y=618, command=touche_Stop)
        add_button(panel=panel1, image_button=image_bouton_avance_rapide, x=186, y=604, command=touche_avance_rapide)
        add_button(panel=panel1, image_button=image_bouton_precedent, x=29, y=646, command=touche_precedent)
        add_button(panel=panel1, image_button=image_bouton_suivant, x=186, y=646, command=touche_suivant)
     
        add_button(panel=panel1, image_button=image_bouton_start, x=32, y=684, command=touche_Start)
     
        add_button(panel=panel1, image_button=image_bouton_directionnel_haut, x=107, y=717, command=touche_directionnel_haut)
        add_button(panel=panel1, image_button=image_bouton_directionnel_gauche, x=62, y=759, command=touche_directionnel_gauche)
        add_button(panel=panel1, image_button=image_bouton_directionnel_droite, x=144, y=757, command=touche_directionnel_droite)
        add_button(panel=panel1, image_button=image_bouton_directionnel_bas, x=108, y=794, command=touche_directionnel_bas)
     
        add_button(panel=panel1, image_button=image_bouton_L, x=0, y=720, command=touche_L)
        # save the panel's image from 'garbage collection'
        panel1.image = image1
    if n==4:
        #print("4 - Résolution : (1920 x 1080)")
        #------------------------------------------- x = largeur - y hauteur ------------------------
        add_button(panel=panel1, image_button=image_bouton_R, x=0, y=47, command=touche_Cote_Droit_R)
        add_button(panel=panel1, image_button=image_bouton_B, x=74, y=29, command=touche_Rond_Rouge_B)
        add_button(panel=panel1, image_button=image_bouton_Y, x=35, y=70, command=touche_Rond_Jaune_Y)
        add_button(panel=panel1, image_button=image_bouton_A, x=111, y=70, command=touche_Rond_Vert_A)  
        add_button(panel=panel1, image_button=image_bouton_X, x=73, y=106, command=touche_Rond_Bleu_X)
        add_button(panel=panel1, image_button=image_bouton_select, x=26, y=125, command=touche_Select)
        add_button(panel=panel1, image_button=image_bouton_on_off, x=22, y=170, command=touche_On_Off)
        add_button(panel=panel1, image_button=image_bouton_list, x=73, y=178, command=touche_liste)
        add_button(panel=panel1, image_button=image_bouton_tv, x=130, y=167, command=touche_TV)
        add_button(panel=panel1, image_button=image_bouton_1, x=22, y=206, command=touche_1) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_2, x=59, y=206, command=touche_2) 
        add_button(panel=panel1, image_button=image_bouton_3, x=96, y=206, command=touche_3) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_info, x=132, y=206, command=touche_INFO)
        add_button(panel=panel1, image_button=image_bouton_4, x=22, y=230, command=touche_4) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_5, x=59, y=230, command=touche_5) 
        add_button(panel=panel1, image_button=image_bouton_6, x=96, y=230, command=touche_6) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_mail, x=131, y=230, command=touche_MAIL)
        add_button(panel=panel1, image_button=image_bouton_7, x=23, y=254, command=touche_7) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_8, x=59, y=254, command=touche_8) 
        add_button(panel=panel1, image_button=image_bouton_9, x=96, y=254, command=touche_9) #x=140, y=170
        add_button(panel=panel1, image_button=image_bouton_help, x=131, y=254, command=touche_HELP)
        add_button(panel=panel1, image_button=image_bouton_Back, x=22, y=278, command=touche_Back)
        add_button(panel=panel1, image_button=image_bouton_0, x=59, y=278, command=touche_0)
        add_button(panel=panel1, image_button=image_bouton_Swap, x=96, y=278, command=touche_Swap)
        add_button(panel=panel1, image_button=image_bouton_PIP, x=132, y=278, command=touche_PIP)
        add_button(panel=panel1, image_button=image_bouton_vol_plus, x=21, y=320, command=touche_volume_plus)
        add_button(panel=panel1, image_button=image_bouton_vol_moins, x=21, y=361, command=touche_volume_moins)
        add_button(panel=panel1, image_button=image_bouton_fleche_haut, x=75, y=312, command=touche_fleche_haut)
        add_button(panel=panel1, image_button=image_bouton_fleche_gauche, x=48, y=341, command=touche_fleche_gauche)
        add_button(panel=panel1, image_button=image_bouton_ok, x=77, y=341, command=touche_OK)
        add_button(panel=panel1, image_button=image_bouton_fleche_droite, x=107, y=343, command=touche_fleche_droite)
        add_button(panel=panel1, image_button=image_bouton_fleche_bas, x=75, y=371, command=touche_fleche_bas)
     
        add_button(panel=panel1, image_button=image_bouton_prog_plus, x=140, y=320, command=touche_programme_plus)
        add_button(panel=panel1, image_button=image_bouton_prog_moins, x=140, y=361, command=touche_programme_moins)
        add_button(panel=panel1, image_button=image_bouton_mute, x=21, y=406, command=touche_mute)
        add_button(panel=panel1, image_button=image_bouton_free, x=67, y=406, command=touche_free) #ok
        add_button(panel=panel1, image_button=image_bouton_rec, x=133, y=407, command=touche_rec) #OK
     
        add_button(panel=panel1, image_button=image_bouton_retour_arriere, x=21, y=438, command=touche_retour_arriere) #OK
        add_button(panel=panel1, image_button=image_bouton_lecture_pause, x=59, y=447, command=touche_lecture_pause) #OK
        add_button(panel=panel1, image_button=image_bouton_stop, x=96, y=447, command=touche_Stop) #OK
        add_button(panel=panel1, image_button=image_bouton_avance_rapide, x=134, y=438, command=touche_avance_rapide)
        add_button(panel=panel1, image_button=image_bouton_precedent, x=21, y=466, command=touche_precedent)
        add_button(panel=panel1, image_button=image_bouton_suivant, x=134, y=465, command=touche_suivant)
        #------------------------------------------- x = largeur - y hauteur ------------------------
        add_button(panel=panel1, image_button=image_bouton_start, x=26, y=494, command=touche_Start)
     
        add_button(panel=panel1, image_button=image_bouton_directionnel_haut, x=78, y=515, command=touche_directionnel_haut)
        add_button(panel=panel1, image_button=image_bouton_directionnel_gauche, x=44, y=548, command=touche_directionnel_gauche)
        add_button(panel=panel1, image_button=image_bouton_directionnel_droite, x=106, y=548, command=touche_directionnel_droite)
        add_button(panel=panel1, image_button=image_bouton_directionnel_bas, x=79, y=577, command=touche_directionnel_bas)
     
        add_button(panel=panel1, image_button=image_bouton_L, x=0, y=525, command=touche_L)
        # save the panel's image from 'garbage collection'
        panel1.image = image1
    if n==5:
        print "Quitter"
        exit()
     
     
     
     
     
    def donothing():
       filewin = Toplevel(fenetre)
       button = Button(filewin, text="Do nothing button")
       button.pack()
     
    def test():
       filewin = Toplevel(fenetre)
       button = Button(filewin, text="Do nothing button")
       button.pack()
     
     
     
    from Tkinter import *
     
    def donothing():
        filewin = Toplevel(fenetre)
        button = Button(filewin, text="Do nothing button")
        button.pack()
     
     
     
    def parametre():
        filewin = Toplevel(fenetre)
        button = Button(filewin, text="Do nothing button")
        button.pack()
     
    def test2():
        filewin = Toplevel(fenetre)
        button = Button(filewin, text="Do nothing button")
        button.pack()
     
     
     
     
    def aide1():
        #from Tkinter import *
        root = Toplevel(fenetre)
        photo = PhotoImage(file='telecommande-freebox-hd-help1.gif')
        button = Button(root, image=photo)
        button.pack()
        Label(root, text="toto").pack()
        root.mainloop()
     
     
    def aide2():
        from PIL import Image, ImageTk  
        import  Tkinter as Tk  
        root = Toplevel(fenetre)
        #photo = PhotoImage(file='telecommande-freebox-hd-help2.jpg')
        #button = Button(root, image=photo)
     
        #root = Tk.Tk()  
     
        image = Image.open("telecommande-freebox-hd-help2.jpg")  
        photo = ImageTk.PhotoImage(image)  
     
        canvas = Tk.Canvas(root, width = image.size[0], height = image.size[1])  
        canvas.create_image(0,0, anchor = Tk.NW, image=photo) 
        canvas.pack()  
        root.mainloop() 
     
     
    def aide3():
        #from Tkinter import *
        root = Toplevel(fenetre)
        #photo = PhotoImage(file='telecommande-freebox-hd-help3.png')
        import Tkinter 
        import Image, ImageTk
        im = Image.open('telecommande-freebox-hd-help3.png')
        tkimage = ImageTk.PhotoImage(im)
        Tkinter.Label(root, image=tkimage).pack()
     
        # make canvas the size of the image
        c = tk.Canvas(width=tkimage.width(), height=tkimage.height())
        c.pack()
     
        #button = Button(root, image=img)
        #button.pack()
        #Label(root, text="toto").pack()
        root.mainloop()    
     
    def a_propos():
        filewin = Toplevel(fenetre)
        #root = tk.Tk()
        tex1 = Label(filewin, text='n Telecommande Freebox V5', fg='black')
        tex1.pack()
        tex2 = Label(filewin, text='Version 1.0.0', fg='black')
        tex2.pack()
        tex4 = Label(filewin, text='n A Propos', fg='black')
        tex4.pack()
        tex5 = Label(filewin, text='Telecommande pour Freebox V5n Logiciel Version 1.0.0', fg='black')
        tex5.pack()
        tex6 = Label(filewin, text='(c) 2014', fg='black')
        tex6.pack()
        tex7 = Label(filewin, text='n Auteurn Dorvaux Laurent', fg='black')
        tex7.pack() 
        tex8 = Label(filewin, text='n Remerciementn Gullivarn', fg='black')
        tex8.pack()
        tex9 = Label(filewin, text='Licence : GPLn', fg='black')
        tex9.pack()
        bouton=Button(filewin,text='OK',command=filewin.destroy)     
        bouton.pack()
        print "nnnn"
        #root.mainloop()  
     
    def fermer():
        fenetre.destroy() # Quitte le programme
     
    def erreur_url(args):
        filewin = Toplevel(fenetre)
        tex1 = Label(filewin, text=args, fg="black")
        tex1.pack()
        button = Button(filewin, text="Ok",command=filewin.destroy) 
        button.pack() 
     
    def erreur_http():
        filewin = Toplevel(fenetre)
        tex1 = Label(filewin, text="n Aucun reseau trouvé", fg="black")
        tex1.pack()
        button = Button(filewin, text="Ok",command=filewin.destroy) 
        button.pack() 
     
     
    def fenetre_telecommande():
        #fenetre = Toplevel(fenetre)
     
        bouton1 = Button(fenetre,text="R",command=touche_Cote_Droit_R)
        bouton1.pack()
     
        bouton2 = Button(fenetre,text="B",command=touche_Rond_Rouge_B)
        bouton2.pack()
     
        bouton3 = Button(fenetre,text="Y",command=touche_Rond_Jaune_Y)
        bouton3.pack()
     
        bouton4 = Button(fenetre,text="X",command=touche_Rond_Bleu_X)
        bouton4.pack()
     
        bouton5 = Button(fenetre,text="Y",command=touche_Rond_Jaune_Y)
        bouton5.pack()
     
        bouton6 = Button(fenetre,text="Marche/Arret",command=touche_On_Off)
        bouton6.pack()
     
        bouton7 = Button(fenetre,text="Liste",command=touche_liste)
        bouton7.pack()
     
        bouton8 = Button(fenetre,text="Tv",command=touche_TV)
        bouton8.pack()
     
        bouton9 = Button(fenetre,text="1",command=touche_1)
        bouton9.pack()
     
        bouton10 = Button(fenetre,text="2",command=touche_2)
        bouton10.pack()
     
        bouton11 = Button(fenetre,text="3",command=touche_3)
        bouton11.pack()
     
        boutonINFO = Button(fenetre,text="INFO",command=touche_INFO)
        boutonINFO.pack()
     
        bouton12 = Button(fenetre,text="4",command=touche_4)
        bouton12.pack()
     
        bouton13 = Button(fenetre,text="5",command=touche_5)
        bouton13.pack()
     
        bouton14 = Button(fenetre,text="6",command=touche_6)
        bouton14.pack()
     
        boutonMAIL = Button(fenetre,text="MAIL",command=touche_MAIL)
        boutonMAIL.pack()
     
        bouton15 = Button(fenetre,text="7",command=touche_7)
        bouton15.pack()
     
        bouton16 = Button(fenetre,text="8",command=touche_8)
        bouton16.pack()
     
        bouton17 = Button(fenetre,text="9",command=touche_9)
        bouton17.pack()
     
        bouton18 = Button(fenetre,text="0",command=touche_0)
        bouton18.pack()
     
        boutonHELP = Button(fenetre,text="HELP",command=touche_HELP)
        boutonHELP.pack()
     
        boutonBack = Button(fenetre,text="Back",command=touche_Back) #la touche jaune en dessous du 7
        boutonBack.pack()
     
        bouton18 = Button(fenetre,text="0",command=touche_0)
        bouton18.pack()
     
        boutonSwap = Button(fenetre,text="Swap",command=touche_Swap) #la touche en dessous du 9 
        boutonSwap.pack()
     
        boutonPIP = Button(fenetre,text="PIP",command=touche_PIP) #la touche en dessous du HELP
        boutonPIP.pack()
     
        bouton19 = Button(fenetre,text="Volume +",command=touche_volume_plus)
        bouton19.pack()
     
        bouton20 = Button(fenetre,text="Volume -",command=touche_volume_moins)
        bouton20.pack()
     
        bouton21 = Button(fenetre,text="Fleche_gauche",command=touche_fleche_gauche)
        bouton21.pack()
     
        bouton22 = Button(fenetre,text="Fleche haut",command=touche_fleche_haut)
        bouton22.pack()
     
        bouton23 = Button(fenetre,text="Touche OK",command=touche_OK)
        bouton23.pack()
     
        bouton24 = Button(fenetre,text="Fleche bas",command=touche_fleche_bas)
        bouton24.pack()
     
        bouton25 = Button(fenetre,text="Fleche droite",command=touche_fleche_droite)
        bouton25.pack()
     
        bouton26 = Button(fenetre,text="Programme +",command=touche_programme_plus)
        bouton26.pack()
     
        bouton27 = Button(fenetre,text="Programme -",command=touche_programme_moins)
        bouton27.pack()
     
        bouton28 = Button(fenetre,text="Mute",command=touche_mute)
        bouton28.pack()
     
        bouton29 = Button(fenetre,text="Home / Touche free",command=touche_free)
        bouton29.pack()
     
        bouton30 = Button(fenetre,text="Rec",command=touche_rec)
        bouton30.pack()
     
        bouton31 = Button(fenetre,text="Quitter",command=touche_quitter)
        bouton31.pack()
     
     
    from Tkinter import *
    menubar = Menu(fenetre)
    fichier_menu = Menu(menubar, tearoff=0)
    fichier_menu.add_command(label="Quitter", command=fenetre.quit)
    menubar.add_cascade(label="Fichier", menu=fichier_menu)
     
    edit_menu = Menu(menubar, tearoff=0)
    edit_menu.add_command(label="Undo", command=donothing)
    edit_menu.add_separator()
    edit_menu.add_command(label="Couper", command=donothing)
    edit_menu.add_command(label="Copier", command=donothing)
    edit_menu.add_command(label="Coller", command=donothing)
    edit_menu.add_command(label="Supprimer", command=donothing)
    edit_menu.add_command(label="Test", command=test)
    edit_menu.add_command(label="Test2", command=test2)
    edit_menu.add_command(label="Configuration", command=configuration)
    edit_menu.add_command(label="Erreur", command=erreur_url)
    edit_menu.add_command(label="Tout Selectionner", command=donothing)
    menubar.add_cascade(label="Edition", menu=edit_menu)
     
    touche_menu = Menu(menubar, tearoff=0)
    touche_menu.add_command(label="Freebox V5", command=donothing)
    touche_menu.add_command(label="Freebox V6", command=donothing)
    touche_menu.add_separator()
    touche_menu.add_command(label="touche_R", command=touche_Cote_Droit_R)
    touche_menu.add_command(label="Touche B", command=touche_Rond_Rouge_B)
    touche_menu.add_command(label="Touche Y", command=touche_Rond_Jaune_Y)
    touche_menu.add_command(label="Touche A", command=touche_Rond_Vert_A)
    touche_menu.add_command(label="Touche X", command=touche_Rond_Bleu_X)
    touche_menu.add_command(label="Touche Select", command=touche_Select)
    touche_menu.add_command(label="Touche Marche Arret", command=touche_On_Off)
    touche_menu.add_command(label="Touche Liste", command=touche_liste)
    touche_menu.add_command(label="Touche Tv", command=touche_TV)
    touche_menu.add_command(label="Touche 1", command=touche_1)
    touche_menu.add_command(label="Touche 2", command=touche_2)
    touche_menu.add_command(label="Touche 3", command=touche_3)
    touche_menu.add_command(label="Touche 4", command=touche_4)
    touche_menu.add_command(label="Touche 5", command=touche_5)
    touche_menu.add_command(label="Touche 6", command=touche_6)
    touche_menu.add_command(label="Touche 7", command=touche_7)
    touche_menu.add_command(label="Touche 8", command=touche_8)
    touche_menu.add_command(label="Touche 9", command=touche_9)
    touche_menu.add_command(label="Touche 0", command=touche_0)
    touche_menu.add_command(label="Touche INFO", command=touche_INFO)
    touche_menu.add_command(label="Touche MAIL", command=touche_MAIL)
    touche_menu.add_command(label="Touche AIDE", command=touche_HELP)
    touche_menu.add_command(label="Touche PIP", command=touche_PIP)
    touche_menu.add_command(label="Touche Back", command=touche_Back)
    touche_menu.add_command(label="Touche Swap", command=touche_Swap)
    touche_menu.add_command(label="Touche Volume +", command=touche_volume_plus)
    touche_menu.add_command(label="Touche Volume -", command=touche_volume_moins)
    touche_menu.add_command(label="Touche ^", command=touche_fleche_haut)
    touche_menu.add_command(label="Touche <--", command=touche_fleche_gauche)
    touche_menu.add_command(label="Touche Ok", command=touche_OK)
    touche_menu.add_command(label="Touche bas", command=touche_fleche_bas)
    touche_menu.add_command(label="Touche -->", command=touche_fleche_droite)
    touche_menu.add_command(label="Touche Programme +", command=touche_programme_plus)
    touche_menu.add_command(label="Touche Programme -", command=touche_programme_moins)
    touche_menu.add_command(label="Touche Mute", command=touche_mute)
    touche_menu.add_command(label="Touche Home", command=touche_free)
    touche_menu.add_command(label="Touche Rec", command=touche_rec)
    touche_menu.add_command(label="Touche << (Retour arriere)", command=touche_retour_arriere)
    touche_menu.add_command(label="Touche >|| (Lecture pause)", command=touche_lecture_pause)
    touche_menu.add_command(label="Touche [] (Stop)", command=touche_Stop)
    touche_menu.add_command(label="Touche >> (Avance rapide)", command=touche_avance_rapide)
    touche_menu.add_command(label="Touche |<< (precedent)", command=touche_precedent)
    touche_menu.add_command(label="Touche >>| (suivant)", command=touche_suivant)
    touche_menu.add_command(label="Touche Start", command=touche_Start)
    touche_menu.add_command(label="Touche directionnel haut", command=touche_directionnel_haut)
    touche_menu.add_command(label="Touche directionnel gauche", command=touche_directionnel_gauche)
    touche_menu.add_command(label="Touche directionnel bas", command=touche_directionnel_bas)
    touche_menu.add_command(label="Touche directionnel droite", command=touche_directionnel_droite)
    touche_menu.add_command(label="Touche L", command=touche_L)
    menubar.add_cascade(label="Touches", menu=touche_menu)
     
    config_menu = Menu(menubar, tearoff=0)
    config_menu.add_command(label="Menu", command=donothing)
    config_menu.add_command(label="Telecommande", command=donothing)
    menubar.add_cascade(label="Config", menu=config_menu)
     
    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="Index", command=donothing)
    helpmenu.add_command(label="Aide1", command=aide1)
    helpmenu.add_command(label="Aide2", command=aide2)
    helpmenu.add_command(label="Aide3", command=aide3)
    helpmenu.add_command(label="A Propos...", command=a_propos)
    menubar.add_cascade(label="Aide", menu=helpmenu)
     
    fenetre.config(menu=menubar)
    fenetre.mainloop()  
     
    quit ()
    Merci.
    Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
    DreamPlug | 512 mo ram | SSD 16 GO | Linux debian 2.6.39.4 | armv5tel | Lamp | PHP 5.3.3-7 | Apache 2.2.16 | Mysql 14.14

  10. #10
    Expert éminent

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

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Salut,

    Ça se passe ici:
    (lignes 515 - 536)
    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
     
    if __name__ == '__main__' : 
     
     
      fenetre = resolution()
     
      # pick a .gif image file you have in the working directory
      #'telecommande-freebox-hd-1_' ,i, '.jpg'
      nom_fichier = "telecommande-freebox-hd-1_%s.jpg" % i
      print nom_fichier
     
      image = Image.open(nom_fichier)
      image1 = ImageTk.PhotoImage(image)
      w = image1.width()
      h = image1.height()
     
     
      fenetre.geometry("%dx%d+0+0" % (w, h))
     
      # tk.Frame has no image argument
      # so use a label as a panel/frame
      panel1 = tk.Label(fenetre, image=image1)
      panel1.pack(side='top', fill='both', expand='yes')
    Où est définit le 'i' de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    nom_fichier = "telecommande-freebox-hd-1_%s.jpg" % i
    ?

    Est-ce que ce fichier image existe ? Le message d'erreur laisse à penser que non.

  11. #11
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 281
    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 281
    Points : 36 768
    Points
    36 768
    Par défaut
    Oui ben, vous avez un tkinter.Tk() à la ligne 32 et un autre à la ligne 78.
    Comme les PhotoImage sont créées dans la première instance de Tk et que les Labels sont construits dans la seconde, çà plante.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  12. #12
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Points : 79
    Points
    79
    Par défaut
    Bonsoir,

    Le i est défini ici :

    Détection de la résolution (Ligne 31 à 38) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    import Tkinter as tkinter
    fenetre = tkinter.Tk()
    width_1 = fenetre.winfo_screenwidth()
    height_1 = fenetre.winfo_screenheight()
    #width_1 = fenetre.winfo_screenmmwidth()
    #height_1 = fenetre.winfo_screenmmheight()
    print width_1, height_1
    r = width_1 , height_1
    instruction if résolution (Ligne 41 à 65) :
    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
    if r==(800, 600):
        print "Resolution = 1920 x 1080"
        print "essai n° 1"
        i = 1
        n = 1
    if r==(1920, 1080):
        print "Resolution = 1920 x 1080"
        print "essai n° 2"
        i = 2
        n = 2
    if r=="1920 x 1080":
        print "Resolution = 1920 x 1080"
        print "essai n° 2-2"
        i = 2
        n = 2
    if r==(3286, 1080):
        print "Resolution = 3286 x 1080"
        print "essai n° 3"
        i = 4
        n = 4
    if r==(5264, 1050):
        print "Resolution = 5264 x 1050"
        print "essai n° 4"
        i = 3
        n = 3
    if r==5:
        print "Quitter"
        quit()
    else:
        print("\nErreur de saissi ou choix incorrect")
    Merci.
    Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
    DreamPlug | 512 mo ram | SSD 16 GO | Linux debian 2.6.39.4 | armv5tel | Lamp | PHP 5.3.3-7 | Apache 2.2.16 | Mysql 14.14

  13. #13
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 281
    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 281
    Points : 36 768
    Points
    36 768
    Par défaut
    Salut,

    Juste pour illustrer votre problème.

    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
    >>> import Tkinter as tk
    >>> from PIL import ImageTk, Image
    >>> root = tk.Tk()   # ici on crée une instance de Tk()
    >>> root = tk.Tk()   # et la une autre...
    >>> image = Image.open('target.gif')
    >>> imagetk = ImageTk.PhotoImage(image)
    >>> label = tk.Label(root, image=imagetk)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\py_env\py27-32\lib\lib-tk\Tkinter.py", line 2475, in __init__
        Widget.__init__(self, master, 'label', cnf, kw)
      File "C:\py_env\py27-32\lib\lib-tk\Tkinter.py", line 1974, in __init__
        (widgetName, self._w) + extra + self._options(cnf))
    _tkinter.TclError: image "pyimage1" doesn't exist
    >>>
    Si vous supprimez une des deux lignes "root = tk.Tk()", il n'y a plus de problème: la variable TCL pyimage1 sera créée dans le bon interpréteur.

    Reste à corriger cela dans votre code.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  14. #14
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    412
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Décembre 2008
    Messages : 412
    Points : 79
    Points
    79
    Par défaut
    Bonsoir,

    Vous aviez raison, j'ai supprimé l'instance a la ligne 78
    et ça marche maintenant.

    Merci.
    Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
    DreamPlug | 512 mo ram | SSD 16 GO | Linux debian 2.6.39.4 | armv5tel | Lamp | PHP 5.3.3-7 | Apache 2.2.16 | Mysql 14.14

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

Discussions similaires

  1. Réponses: 5
    Dernier message: 23/10/2005, 17h34
  2. Passer une fonction en paramètre ...
    Par Freeze dans le forum C++Builder
    Réponses: 2
    Dernier message: 14/10/2005, 16h51
  3. [Conception] Passer une fonction en paramètre
    Par pejay dans le forum Langage
    Réponses: 9
    Dernier message: 09/12/2004, 13h58
  4. Réponses: 4
    Dernier message: 10/11/2004, 14h58
  5. Passer une fonction comme argument à une fonction
    Par Cocotier974 dans le forum Général Python
    Réponses: 4
    Dernier message: 29/06/2004, 13h41

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