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 :

[Tkinter] Scale


Sujet :

Tkinter Python

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    266
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 266
    Points : 161
    Points
    161
    Par défaut [Tkinter] Scale
    Bonjour j'ai un petit probleme
    je fais une fenetre contenant seulement un canevas
    et lorsqu'on clique dessus je souhaite afficher une nouvelle fenetre contenant 3 widgets Scale
    or dans mon code ils s'affichent pas dans la nouvelle fenetre mais en bas de ma premiere fenetre
    comment ca se fait?
    aidez moi je ne trouve pas la solution, pourtant j'ai cherché...

    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
     
    #! /usr/bin/env python
    # -*- coding: Latin-1 -*-
    import os, sys
     
    from Tkinter import *
     
    class Curseurs(Frame):
        def __init__(self, maitre=None):
            Frame.__init__(self)        # constructeur de la classe parente
            # Définition de quelques attributs d'instance :
            self.compR, self.compV, self.compB = 0, 0, 0
            #composante rouge
            Scale(self, length=400, orient=HORIZONTAL, label ='Composante Rouge :',
                    troughcolor ='dark grey', sliderlength =20,
                    showvalue =0, from_=0, to=255, tickinterval =25,
                    command=self.setCompR).pack()
            #composante verte
            Scale(self, length=400, orient=HORIZONTAL, label ='Composante Verte :',
                    troughcolor ='dark grey', sliderlength =20,
                    showvalue =0, from_=0, to=255, tickinterval =25,
                    command=self.setCompV).pack()
            #composante bleue
            Scale(self, length=400, orient=HORIZONTAL, label ='Composante Bleue :',
                    troughcolor ='dark grey', sliderlength =20,
                    showvalue =0, from_=0, to=255, tickinterval =25,
                    command=self.setCompB).pack()
     
        def setCompR(self, r):
            self.compR = float(r)
            self.event_generate('<Control-Z>')
     
        def setCompV(self, v):
            self.compV = float(v)
            self.event_generate('<Control-Z>')
     
        def setCompB(self, b):
            self.compB = float(b)
            self.event_generate('<Control-Z>')
     
    class Application(Frame):
        """Application principale"""
        def __init__(self, boss =None):
            Frame.__init__(self)
            self.master.title('Watermarking attacks')
            self.can2 = Canvas(self, bg='light grey', height=500,
                              width=500, borderwidth =2)
            self.can2.bind("<Button-1>", self.modif_pixel)
            self.can2.pack(side =RIGHT)
            self.pack()
     
        def afficherTout(event=None):
            lab.configure(text = '%s - %s - %s' % (fra.compR, fra.compV, fra.compB))
     
        def modif_pixel(self, event):
            #x = str(event.x)
            #y = str(event.y)
            #print x,y
     
            fen_curseurs = Tk()
            fra = Curseurs(fen_curseurs)
            fra.pack(side =TOP)
            lab = Label(fen_curseurs, text ='test')
            lab.pack()
            fen_curseurs.bind('<Control-Z>', self.afficherTout)
            fen_curseurs.mainloop()
     
    if __name__ == '__main__':
     
        app = Application()
        app.mainloop()

  2. #2
    Membre éclairé
    Avatar de airod
    Homme Profil pro
    Gérant Associé, DMP Santé et Directeur technique
    Inscrit en
    Août 2004
    Messages
    767
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Gérant Associé, DMP Santé et Directeur technique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2004
    Messages : 767
    Points : 891
    Points
    891
    Par défaut
    j'ai bien une solution mais je ne sais pas si c'est vraiment l'idéal.

    ci joint 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
    #! /usr/bin/env python
    # -*- coding: Latin-1 -*-
    import os, sys
     
    from Tkinter import *
     
    class Curseurs(Toplevel):
        def __init__(self):
            Toplevel.__init__(self)        # constructeur de la classe parente
            # Définition de quelques attributs d'instance :
            self.compR, self.compV, self.compB = 0, 0, 0
     
            #composante rouge
            Scale(self, length=400, orient=HORIZONTAL, label ='Composante Rouge :',
                    troughcolor ='dark grey', sliderlength =20,
                    showvalue =0, from_=0, to=255, tickinterval =25,
                    command=self.setCompR).pack()
            #composante verte
            Scale(self, length=400, orient=HORIZONTAL, label ='Composante Verte :',
                    troughcolor ='dark grey', sliderlength =20,
                    showvalue =0, from_=0, to=255, tickinterval =25,
                    command=self.setCompV).pack()
            #composante bleue
            Scale(self, length=400, orient=HORIZONTAL, label ='Composante Bleue :',
                    troughcolor ='dark grey', sliderlength =20,
                    showvalue =0, from_=0, to=255, tickinterval =25,
                    command=self.setCompB).pack()
     
        def setCompR(self, r):
            self.compR = float(r)
            self.event_generate('<Control-Z>')
     
        def setCompV(self, v):
            self.compV = float(v)
            self.event_generate('<Control-Z>')
     
        def setCompB(self, b):
            self.compB = float(b)
            self.event_generate('<Control-Z>')
     
    class Application(Frame):
        """Application principale"""
        def __init__(self, boss =None):
            Frame.__init__(self)
            self.master.title('Watermarking attacks')
            self.can2 = Canvas(self, bg='light grey', height=500,
                              width=500, borderwidth =2)
            self.can2.bind("<Button-1>", self.modif_pixel)
            self.can2.pack(side =RIGHT)
            self.pack()
     
        def afficherTout(event=None):
            lab.configure(text = '%s - %s - %s' % (fra.compR, fra.compV, fra.compB))
     
        def modif_pixel(self, event):
            #x = str(event.x)
            #y = str(event.y)
            #print x,y
     
            fra = Curseurs()
            lab = Label(fra, text ='test')
            lab.pack()
            fra.bind('<Control-Z>', self.afficherTout)
            fra.mainloop()
     
    if __name__ == '__main__':
     
        app = Application()
        app.mainloop()

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    266
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 266
    Points : 161
    Points
    161
    Par défaut
    tres bien merci ca marche comme je veux mais il n'apparait pas l'affichage des valeurs lors du deplacement du curseur...
    comment ca se fait ?
    merci pour votre aide

  4. #4
    Membre éclairé
    Avatar de airod
    Homme Profil pro
    Gérant Associé, DMP Santé et Directeur technique
    Inscrit en
    Août 2004
    Messages
    767
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Gérant Associé, DMP Santé et Directeur technique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2004
    Messages : 767
    Points : 891
    Points
    891
    Par défaut


    Ben, alors on perd la mémoire???

    revois ton post ci joint!
    http://www.developpez.net/forums/sho...d.php?t=137179

    la réponse est là!

    A+

Discussions similaires

  1. [Tkinter] Scale
    Par frizou11 dans le forum Tkinter
    Réponses: 1
    Dernier message: 27/04/2006, 23h02
  2. [Tkinter]
    Par KymZen dans le forum Tkinter
    Réponses: 7
    Dernier message: 08/03/2005, 08h28
  3. [Tkinter] Binder le bouton de fermeture d'un Tk()
    Par jc_isd dans le forum Tkinter
    Réponses: 2
    Dernier message: 09/02/2005, 16h11
  4. Réponses: 3
    Dernier message: 26/10/2004, 07h31
  5. Réponses: 3
    Dernier message: 16/08/2004, 10h57

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