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 :

Barre de défilement qui fait défiler le fond mais pas les widget du premier plan


Sujet :

Tkinter Python

  1. #1
    Membre du Club
    Homme Profil pro
    Ingénieur calcul et simulation
    Inscrit en
    Juin 2013
    Messages
    41
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Ingénieur calcul et simulation
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2013
    Messages : 41
    Points : 60
    Points
    60
    Par défaut Barre de défilement qui fait défiler le fond mais pas les widget du premier plan
    Bonjour,

    Sur un programme basique (launcher) je me retrouve avec un problème de scrollbar : elles ne veulent faire défiler que l'image de fond et pas les widgets au premier plan.

    L'interface est construite comme suit :
    - Niveau 0 (parent = self) : Canvas (self.c) de fond avec une image + scrollbars
    - Niveau 1 (parent = self.c) : Boutons + un Frame non visible

    Voilà le script :

    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
    # -*-coding:Utf-8 -*-
    from __future__ import unicode_literals
     
    import Tkinter
    import ImageTk
    import Image
     
     
     
    class Interface(Tkinter.Tk) :
        def __init__(self, parent) :
            Tkinter.Tk.__init__(self, parent)
            self.parent = parent
            self.initialize()
     
    # Creation des widgets
        def initialize(self) :
        # Fenetre principale
            self.minsize(437, 98)
            # Scrollbars agissant sur le Canvas principal self.c
            self.ascenseur_y = Tkinter.Scrollbar(self, orient=Tkinter.VERTICAL)
            self.ascenseur_x = Tkinter.Scrollbar(self, orient=Tkinter.HORIZONTAL)
            self.ascenseur_y.grid(row=0, column=1, sticky="ns")
            self.ascenseur_x.grid(row=1, column=0, sticky="ew")
     
            # Canvas qui contient tous les widgets
            self.c = Tkinter.Canvas(self, yscrollcommand=self.ascenseur_y.set, xscrollcommand=self.ascenseur_x.set,\
                                    bg="white", highlightthicknes=0) #, scrollregion=(0, 0, 415, 200)
            self.apercu_logo="Logo.png"
            self.photo = ImageTk.PhotoImage(Image.open(self.apercu_logo))
            self.c.config(height=self.photo.height(), width=self.photo.width())
            self.image_x = self.photo.height()/2
            self.image_y = self.photo.width()/2
            self.item = self.c.create_image(self.image_x, self.image_y, anchor="center", image=self.photo)
            self.c.grid(row=0, column=0, sticky="news")
            self.c.bind('<Configure>', self.dimensionner)
     
            self.ascenseur_y.config(command=self.c.yview)
            self.ascenseur_x.config(command=self.c.xview)
     
            self.grid_rowconfigure(0, weight=1)
            self.grid_columnconfigure(0, weight=1)
     
            # Frame non visible pour lier l'évènement "molette souris" à la scrollbar verticale
            self.fr = Tkinter.Frame(self.c)
            self.fr.bind_all("<MouseWheel>", self._on_mousewheel_haupt)
     
        # Bouton lancer pdf2pptx
            self.c.bouton_pdf2pptx = Tkinter.Button(self.c, width=13, text=u"Pdf2pptx", command=self.ButtonPdf2pptx, anchor="center", cursor="hand2", padx=0)
            self.c.bouton_pdf2pptx.grid(column=0, row=0)
            self.c.bouton_pdf2pptx.bind("<Return>", self.EnterPdf2pptx)
            self.c.bouton_pdf2pptx.focus_set()
     
        # Bouton lancer xls2inp
            self.c.bouton_xls2inp = Tkinter.Button(self.c, width=13, text=u"xls2inp", command=self.ButtonXls2inp, anchor="center", cursor="hand2", padx=0)
            self.c.bouton_xls2inp.grid(column=1, row=0)
            self.c.bouton_xls2inp.bind("<Return>", self.EnterXls2inp)
     
        # Bouton lancer Zeichen ersetzer
            self.c.bouton_ZeichenErsetzer = Tkinter.Button(self.c, width=13, text=u"Zeichen ersetzer", command=self.ButtonZeichenErsetzer, anchor="center", cursor="hand2", padx=0)
            self.c.bouton_ZeichenErsetzer.grid(column=2, row=0)
            self.c.bouton_ZeichenErsetzer.bind("<Return>", self.EnterZeichenErsetzer)
     
        # Configuration lignes/colonnes
            self.c.grid_rowconfigure(0, weight=1, pad=100, minsize=300)
     
            self.c.grid_columnconfigure(0, weight=1, pad=30, minsize=140)
            self.c.grid_columnconfigure(1, weight=1, pad=30, minsize=140)
            self.c.grid_columnconfigure(2, weight=1, pad=30, minsize=140)
     
     
        # Logo du cadre de la fenêtre
            self.iconbitmap("IcoKAG.ico")
     
    # Options de la fenetre principale
            # Redimentionnement autorisée y/n
            self.resizable(True, True)
            # Création du Canvas principal qui contient tout et config des scrollbars pour qu'elles s'y adaptent
            self.c.create_window(0, 0, window=self.fr)
            self.fr.update_idletasks()
            self.c.config(scrollregion=self.c.bbox("all"))
            # On s'assure que Tkinter a termine les rendus graphiques
            self.update()
     
     
     
     
    # Fonctions associées aux widgets de la fenetre principale
     
        def dimensionner(self, event):
            """ Gestion du redimentionnement de la taille de la fenêtre :
                Repositionne l'image de fond
                Modifie la taille des lignes/colonnes
                Regle les scrollbars """
            self.image_y = self.winfo_height()/2
            self.image_x = self.winfo_width()/2
            self.c.delete(self.item)
            self.item = self.c.create_image(self.image_x, self.image_y, anchor="center", image=self.photo)
            if self.winfo_height() < 300 and self.winfo_height() > 100:
                self.c.grid_rowconfigure(0, weight=1, pad=100, minsize=self.winfo_height())
            elif self.winfo_height() < 100 :
                self.c.grid_rowconfigure(0, weight=1, pad=100, minsize=98)
            else :
                self.c.grid_rowconfigure(0, weight=1, pad=100, minsize=300)
     
        # Regle les scrollbars
            if self.winfo_width() < 437 :
                self.c.grid_columnconfigure(0, weight=1, pad=30, minsize=self.winfo_width()/3)
                self.c.grid_columnconfigure(1, weight=1, pad=30, minsize=self.winfo_width()/3)
                self.c.grid_columnconfigure(2, weight=1, pad=30, minsize=self.winfo_width()/3)
            else :
                self.c.grid_columnconfigure(0, weight=1, pad=30, minsize=140)
                self.c.grid_columnconfigure(1, weight=1, pad=30, minsize=140)
                self.c.grid_columnconfigure(2, weight=1, pad=30, minsize=140)
     
            if self.winfo_height() > 223 and self.winfo_width() > 420 :
                self.SR = self.c.bbox("all")
                self.SRL=list(self.SR)
                self.SRL[2] = self.winfo_width() - 16
                self.SRL[3] = self.winfo_height() - 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
            elif self.winfo_height() < 223 and self.winfo_width() > 420 :
                self.SR = self.c.bbox("all")
                self.SRL=list(self.SR)
                self.SRL[2] = self.winfo_width() - 16
                self.SRL[3] -= 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
            elif self.winfo_height() > 223 and self.winfo_width() < 420 :
                self.SR = self.c.bbox("all")
                self.SRL=list(self.SR)
                self.SRL[2] -= 16
                self.SRL[3] = self.winfo_height() - 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
            else :
                pass
     
     
     
        def _on_mousewheel_haupt(self, event):
            """ Fonction qui lie la scrollbar principale à la molette de la souris (le /120 est parceque sinon ca scroll trop vite sous windows) """
            self.c.yview_scroll(-1*(event.delta/120), "units")
     
        def ButtonPdf2pptx(self) :
            pass
     
        def EnterPdf2pptx(self, event) :
            self.ButtonPdf2pptx()
     
        def ButtonXls2inp(self) :
            pass
     
        def EnterXls2inp(self, event) :
            self.ButtonXls2inp()
     
        def ButtonZeichenErsetzer(self) :
            pass
     
        def EnterZeichenErsetzer(self, event) :
            self.ButtonZeichenErsetzer()
     
     
     
    # Hauptfenster wird gebaut
    if __name__ == "__main__" :
        appLauncher = Interface(None)
        appLauncher.title(u"Programm-launcher - Kämmerer AG")
        appLauncher.mainloop()
    La scrollbar bouge donc le Canvas "self.c" mais pas les boutons qui sont dans le canvas. Après pas mal de tests je ne parviens toujours pas à voir où se situe l'erreur ... Quelqu'un aurait une idée du problème ?

    Merci d'avance !

  2. #2
    Expert confirmé 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
    Points : 4 005
    Points
    4 005
    Par défaut
    Bonsoir,

    Pour que les Widgets soit des items du Canvas, et que le scroll s'applique donc, vous devez utiliser create_windows pour les 'intégrer' à celui ci.

    @+
    Merci d'utiliser le forum pour les questions techniques.

  3. #3
    Membre du Club
    Homme Profil pro
    Ingénieur calcul et simulation
    Inscrit en
    Juin 2013
    Messages
    41
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Ingénieur calcul et simulation
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2013
    Messages : 41
    Points : 60
    Points
    60
    Par défaut
    En effet. Merci beaucoup !

  4. #4
    Membre du Club
    Homme Profil pro
    Ingénieur calcul et simulation
    Inscrit en
    Juin 2013
    Messages
    41
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Ingénieur calcul et simulation
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2013
    Messages : 41
    Points : 60
    Points
    60
    Par défaut
    Bonjour,

    le programme a été corrigé en conséquence. Cependant un autre problème est apparu, lui aussi lié aux scrollbars : lorsqu'elles sont utilisées (avec la molette souris ou en cliquant dessus), les boutons disparaissent. Ils réapparaissent cependant si on fait passer la souris au dessus de leur position. Je ne sais pas si c'est du à un problème d'update de l'interface, dans le doute je lui ai dit d'en faire un peu partout (certainement plus que de raison) mais ça n'a pas réglé le problème.

    Voilà le script corrigé :

    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
    # -*-coding:Utf-8 -*-
    from __future__ import unicode_literals
     
    import Tkinter
    import ImageTk
    import Image
     
     
    class Interface(Tkinter.Tk) :
        def __init__(self, parent) :
            Tkinter.Tk.__init__(self, parent)
            self.parent = parent
            self.initialize()
     
    # Creation de nos widgets
        def initialize(self) :
    # Fenetre principale
        # Def Scrollbars
            self.ascenseur_y = Tkinter.Scrollbar(self, orient=Tkinter.VERTICAL)
            self.ascenseur_x = Tkinter.Scrollbar(self, orient=Tkinter.HORIZONTAL)
            self.ascenseur_y.grid(row=0, column=1, sticky="ns")
            self.ascenseur_x.grid(row=1, column=0, sticky="ew")
     
        # Def Canvas contenant le Label avec l'image de fond
            self.c = Tkinter.Canvas(self, yscrollcommand=self.ascenseur_y.set, xscrollcommand=self.ascenseur_x.set, bg="white", highlightthicknes=0)
            self.c.grid(row=0, column=0, sticky="news")
            self.c.bind('<Configure>', self.dimensionner)
     
            self.grid_rowconfigure(0, weight=1)
            self.grid_columnconfigure(0, weight=1)
     
            self.ascenseur_x.config(command=self.c.xview)
            self.ascenseur_y.config(command=self.c.yview)
     
        # Def Frame invisible pour lier la molette souris à la Y-Scrollbar
            self.fr = Tkinter.Frame(self.c)
     
            self.fr.pack(expand=True, fill="both")
     
     
        # Def Label avec l'iamage de fond. Contient les autres widegts
            self.apercu_logo="Logo.png"
            self.photo = ImageTk.PhotoImage(Image.open(self.apercu_logo))
            self.bl = Tkinter.Label(self.c, image=self.photo, bg="white")
     
            self.image_y = self.winfo_height()/2
            self.image_x = self.winfo_width()/2
            self.c.create_window(450/2, 300/2, window=self.bl, height=500, width=800)
            self.bl.update_idletasks()
     
     
            self.fr.bind_all("<MouseWheel>", self._on_mousewheel_haupt)
     
        # Bouton lancer pdf2pptx - Dans self.bl
            self.bouton_pdf2pptx = Tkinter.Button(self.bl, width=13, text=u"Pdf2pptx", command=self.ButtonPdf2pptx, anchor="center", cursor="hand2", padx=0)
            self.bouton_pdf2pptx.grid(column=0, row=0, padx=10)
            self.bouton_pdf2pptx.bind("<Return>", self.EnterPdf2pptx)
            self.bouton_pdf2pptx.focus_set()
     
        # Bouton lancer xls2inp - Dans self.bl
            self.bouton_xls2inp = Tkinter.Button(self.bl, width=13, text=u"xls2inp", command=self.ButtonXls2inp, anchor="center", cursor="hand2", padx=0)
            self.bouton_xls2inp.grid(column=1, row=0, padx=10)
            self.bouton_xls2inp.bind("<Return>", self.EnterXls2inp)
     
        # Bouton lancer Zeichen ersetzer - Dans self.bl
            self.bouton_ZeichenErsetzer = Tkinter.Button(self.bl, width=13, text=u"Zeichen ersetzer", command=self.ButtonZeichenErsetzer, anchor="center", cursor="hand2", padx=0)
            self.bouton_ZeichenErsetzer.grid(column=2, row=0, padx=10)
            self.bouton_ZeichenErsetzer.bind("<Return>", self.EnterZeichenErsetzer)
     
        # Configuration lignes/colonnes - Dans self.bl
     
            self.bl.grid_rowconfigure(0, weight=1, pad=100, minsize=50)
     
            self.bl.grid_columnconfigure(0, weight=1, pad=30, minsize=140)
            self.bl.grid_columnconfigure(1, weight=1, pad=30, minsize=140)
            self.bl.grid_columnconfigure(2, weight=1, pad=30, minsize=140)
     
     
        # Logo du cadre de la fenêtre
            self.iconbitmap("IcoKAG.ico")
     
    # Options de la fenetre principale
            # Redimentionnement autorisée y/n
            self.resizable(True, True)
            # Création du Canvas principal qui contient tout et config des scrollbars pour qu'elles s'y adaptent
            self.image_y = self.winfo_height()/2
            self.image_x = self.winfo_width()/2
            self.c.create_window(self.image_x, self.image_y, window=self.fr)
            self.fr.update_idletasks()
     
            # Taille minimum de la fenêtre
            self.minsize(200, 100)
     
            # Taille de la fenêtre à l'ouverture
            self.geometry("500x300")
     
            #self.c.config(scrollregion=self.c.bbox("all"))
            if self.winfo_width() < 437 :
                self.bl.grid_columnconfigure(0, weight=1, pad=30, minsize=self.winfo_width()/3)
                self.bl.grid_columnconfigure(1, weight=1, pad=30, minsize=self.winfo_width()/3)
                self.bl.grid_columnconfigure(2, weight=1, pad=30, minsize=self.winfo_width()/3)
            else :
                self.bl.grid_columnconfigure(0, weight=1, pad=30, minsize=140)
                self.bl.grid_columnconfigure(1, weight=1, pad=30, minsize=140)
                self.bl.grid_columnconfigure(2, weight=1, pad=30, minsize=140)
     
            if self.winfo_height() >= 300 and self.winfo_width() >= 500 :
                self.SR = (0, 0, self.photo.width(), self.photo.height())#self.c.bbox("all")
                self.SRL = list(self.SR)
                self.SRL[2] = self.winfo_width() - 16
                self.SRL[3] = self.winfo_height() - 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
            elif self.winfo_height() < 300 and self.winfo_width() >= 500 :
                self.SR = (0, 0, self.photo.width(), self.photo.height())#self.c.bbox("all")
                self.SRL = list(self.SR)
                self.SRL[2] = self.winfo_width() - 16
                self.SRL[3] -= 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
            elif self.winfo_height() >= 300 and self.winfo_width() < 500 :
                self.SR = (0, 0, self.photo.width(), self.photo.height())#self.c.bbox("all")
                self.SRL = list(self.SR)
                self.SRL[2] -= 16
                self.SRL[3] = self.winfo_height() - 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
            else :
                self.SR = (0, 0, self.photo.width(), self.photo.height())#self.c.bbox("all")
                self.SRL = list(self.SR)
                self.SRL[2] -= 16
                self.SRL[3] -= 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
            # On s'assure que Tkinter a termine les rendus graphiques
            self.update()
            self.bl.update_idletasks()
     
     
     
     
     
     
    # Fonctions associées aux widgets de la fenetre principale
        def dimensionner(self, event):
            """ Gestion du redimentionnement de la taille de la fenêtre :
                Repositionne l'image de fond
                Modifie la taille des lignes/colonnes """
        # Regle la taille des scrollbars et la scrollregion
            if self.winfo_width() < 437 :
                self.bl.grid_columnconfigure(0, weight=1, pad=30, minsize=self.winfo_width()/3)
                self.bl.grid_columnconfigure(1, weight=1, pad=30, minsize=self.winfo_width()/3)
                self.bl.grid_columnconfigure(2, weight=1, pad=30, minsize=self.winfo_width()/3)
                self.update()
                self.c.update_idletasks()
            else :
                self.bl.grid_columnconfigure(0, weight=1, pad=30, minsize=140)
                self.bl.grid_columnconfigure(1, weight=1, pad=30, minsize=140)
                self.bl.grid_columnconfigure(2, weight=1, pad=30, minsize=140)
                self.update()
                self.c.update_idletasks()
     
            if self.winfo_height() >= 300 and self.winfo_width() >= 500 :
                self.SR = (0, 0, self.photo.width(), self.photo.height())
                self.SRL = list(self.SR)
                self.SRL[2] = self.winfo_width() - 16
                self.SRL[3] = self.winfo_height() - 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
                self.c.update_idletasks()
            elif self.winfo_height() < 300 and self.winfo_width() >= 500 :
                self.SR = (0, 0, self.photo.width(), self.photo.height())
                self.SRL = list(self.SR)
                self.SRL[2] = self.winfo_width() - 16
                self.SRL[3] = 300 - 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
                self.c.update_idletasks()
            elif self.winfo_height() >= 300 and self.winfo_width() < 500 :
                self.SR = (0, 0, self.photo.width(), self.photo.height())
                self.SRL = list(self.SR)
                self.SRL[2] = 500 - 16
                self.SRL[3] = self.winfo_height() - 16
                self.c.config(scrollregion=tuple(self.SRL))
                self.update()
                self.c.update_idletasks()
            else :
                self.c.config(scrollregion=(0, 0, 484, 284))
                self.update()
                self.c.update_idletasks()
     
        # Ajuste le Background-label
            if self.winfo_height() >= 300 and self.winfo_width() >= 500 :
                self.image_y = self.winfo_height()/2
                self.image_x = self.winfo_width()/2
                self.c.create_window(self.image_x, self.image_y, window=self.bl, height=self.winfo_height(), width=self.winfo_width())
                self.update()
                self.c.update_idletasks()
            elif self.winfo_height() < 300 and self.winfo_width() >= 500 :
                self.image_y = 300/2
                self.image_x = self.winfo_width()/2
                self.c.create_window(self.image_x, self.image_y, window=self.bl, height=300, width=self.winfo_width())
                self.update()
                self.c.update_idletasks()
            elif self.winfo_height() >= 300 and self.winfo_width() < 500 :
                self.image_y = self.winfo_height()/2
                self.image_x = 500/2
                self.c.create_window(self.image_x, self.image_y, window=self.bl, height=self.winfo_height(), width=500)
                self.update()
                self.c.update_idletasks()
            else :
                self.image_y = 300/2
                self.image_x = 500/2
                self.c.create_window(self.image_x, self.image_y, window=self.bl, height=300, width=500)
                self.update()
                self.c.update_idletasks()
     
     
        def _on_mousewheel_haupt(self, event):
            """ Fonction qui lie la scrollbar principale à la molette de la souris (le /120 est parceque sinon ca scroll trop vite sous windows) """
            self.c.yview_scroll(-1*(event.delta/120), "units")
            self.update()
            self.c.update_idletasks()
     
        def ButtonPdf2pptx(self) :
            pass
     
        def EnterPdf2pptx(self, event) :
            self.ButtonPdf2pptx()
     
        def ButtonXls2inp(self) :
            pass
     
        def EnterXls2inp(self, event) :
            self.ButtonXls2inp()
     
        def ButtonZeichenErsetzer(self) :
            pass
     
        def EnterZeichenErsetzer(self, event) :
            self.ButtonZeichenErsetzer()
     
     
     
     
     
    # Hauptfenster wird gebaut
    if __name__ == "__main__" :
        appLauncher = Interface(None)
        appLauncher.title(u"Programm-launcher - Kämmerer AG")
        appLauncher.mainloop()
    Une idée ?

    Merci d'avance.

  5. #5
    Expert confirmé 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
    Points : 4 005
    Points
    4 005
    Par défaut
    Peut être ici

    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
        # Def Label avec l'iamage de fond. Contient les autres widegts
            #self.apercu_logo="Logo.png"
            #self.photo = ImageTk.PhotoImage(Image.open(self.apercu_logo))
            self.bl = Tkinter.Label(self.c, bg="white")
     
            self.image_y = self.winfo_height()/2
            self.image_x = self.winfo_width()/2
            self.c.create_window(450/2, 300/2, window=self.bl, height=500, width=800)
            self.bl.update_idletasks()
     
     
            self.fr.bind_all("<MouseWheel>", self._on_mousewheel_haupt)
     
        # Bouton lancer pdf2pptx - Dans self.bl
            self.bouton_pdf2pptx = Tkinter.Button(self.bl, width=13, text=u"Pdf2pptx", command=self.ButtonPdf2pptx, anchor="center", cursor="hand2", padx=0)
            self.bouton_pdf2pptx.grid(column=0, row=0, padx=10)
            self.bouton_pdf2pptx.bind("<Return>", self.EnterPdf2pptx)
            self.bouton_pdf2pptx.focus_set()
     
        # Bouton lancer xls2inp - Dans self.bl
            self.bouton_xls2inp = Tkinter.Button(self.bl, width=13, text=u"xls2inp", command=self.ButtonXls2inp, anchor="center", cursor="hand2", padx=0)
            self.bouton_xls2inp.grid(column=1, row=0, padx=10)
            self.bouton_xls2inp.bind("<Return>", self.EnterXls2inp)
     
        # Bouton lancer Zeichen ersetzer - Dans self.bl
            self.bouton_ZeichenErsetzer = Tkinter.Button(self.bl, width=13, text=u"Zeichen ersetzer", command=self.ButtonZeichenErsetzer, anchor="center", cursor="hand2", padx=0)
            self.bouton_ZeichenErsetzer.grid(column=2, row=0, padx=10)
            self.bouton_ZeichenErsetzer.bind("<Return>", self.EnterZeichenErsetzer)
     
        # Configuration lignes/colonnes - Dans self.bl
     
            self.bl.grid_rowconfigure(0, weight=1, pad=100, minsize=50)
     
            self.bl.grid_columnconfigure(0, weight=1, pad=30, minsize=140)
            self.bl.grid_columnconfigure(1, weight=1, pad=30, minsize=140)
            self.bl.grid_columnconfigure(2, weight=1, pad=30, minsize=140)
    Un Label n'est pas un conteneur pour les autres Widgets.
    Commencez par faire un create_windows pour chaque Widgets.

    Maintenant comme cela ne se produit pas chez moi je pense que vous devez être sous Windows et que cela viens de votre WM.
    Merci d'utiliser le forum pour les questions techniques.

Discussions similaires

  1. [Joomla!] Module qui fait défiler les articles en vedette
    Par jere12 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 2
    Dernier message: 23/03/2013, 13h48
  2. Réponses: 2
    Dernier message: 15/10/2011, 14h16
  3. barre de défilement qui ne fonctionne pas sous IE
    Par eiffel59300 dans le forum Général JavaScript
    Réponses: 0
    Dernier message: 02/09/2009, 18h06
  4. [Joomla!] Cherche Module qui fait défiler des articles d'une catégorie
    Par Alcius dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 1
    Dernier message: 12/08/2009, 13h35
  5. Réponses: 0
    Dernier message: 31/10/2007, 14h05

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