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 :

créer un progress bar


Sujet :

Tkinter Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Janvier 2009
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Janvier 2009
    Messages : 23
    Par défaut créer un progress bar
    salut,

    je débute avec Tkinter et j´aimerai programmer une petite interface qui actionne le lancement d´un programme.
    J´y arrive mais j´aimerai y apporter qlqs ajustements,notamment pouvoir creer un "progress bar" qui se déclenche qd le programme est en exécution et qui affiche un message "finish" quand le programme est terminé...

    Voici mon code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
     
     
    # -*- coding: cp1252 -*-
    from Tkinter import*
    from PIL import Image, ImageTk
    from DCM import*
    import Tkinter, tkFileDialog
    import os
     
    #---------------------function's definition------------------------
     
    def creeDialog1():
        """
        create a dialog for the selection of the to be classified files....
        """
        dirname1= tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select a directory')
        dirInLab=Label(root,text='Infile:'+ dirname1)
        dirInLab.pack()
        return str(dirname1)
     
    def creeDialog2():
        """
        create a dialog for the selection of the classification's directory....
        """
        dirname2= tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select a directory for the classification')
        dirOutLab=Label(root,text='Outfile:'+ dirname2)
        dirOutLab.pack()
        return str(dirname2)
     
    def creeWindow():
        """
        create a window with a button'Close'that will be destroy after its release..
        """
        fen=Tk()
        fen.title('Welcome to v1.00')
        tex=Label(fen,text='This the description of....',fg='red')
        tex.pack()
        bou=Button(fen,text='Close',command=fen.destroy)
        bou.pack()
     
    def dcm(dirs1,dirs2):
        """
        callback the function Classification from DCM and execute
        this one...
        """
        os.chdir(dirs2)
        Classification(dirs1)
     
     
    def test():
        """
        """
        call_Dialog1=creeDialog1()
        call_Dialog2=creeDialog2()
        dcm(call_Dialog1,call_Dialog2)
     
     
     
    #---------------------main programm------------------------------
     
    if __name__ == '__main__':
     
        root=Tkinter.Tk()
        root.resizable(False,False)
        root.title('Welcome to v1.00')
        image=Image.open('log.png')
        photo=ImageTk.PhotoImage(image)
        Label_photo=Label(root,image=photo).pack(side=RIGHT)
     
        tex1=Label(root,text='This programm....',fg='blue')
        tex1.pack()
     
        tex2=Label(root,text='(c)2009')
        tex2.pack(side=LEFT)
     
        bou1=Button(root,text='Start',background='blue',command=test)
        bou1.pack(side=LEFT)
     
     
        bou2=Button(root,text='Help',background='blue',command=creeWindow)   
        bou2.pack(side=RIGHT)
     
     
        root.mainloop()
    mer6 d´avance!

    sBugsy

  2. #2
    Membre confirmé Avatar de bringer
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    125
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Bâtiment

    Informations forums :
    Inscription : Juin 2009
    Messages : 125
    Par défaut
    bonjour morty,

    si tu veux faire un progress bar avec tkinter, je te propose un conteneur Frame dans lequel tu mets un Canvas qui contient un objet rectangle qui va de width0 à width canvas. Le ratio entre le point 0 et longueur canvas est en fonction de ton ratio d'avancement de progression.

    du style:
    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
     
    def main():
    	root=Tk()
    	#creation du canvas
    	endval=200
    	canvas=Canvas(root, width=endval,  height=20,  bg='ivory')
    	canvas.configure(bd=2,  relief='groove')
    	canvas.pack()
     
    	for step in range(endval):
    		canvas.create_rectangle(0, 0, step, 20, fill='red')
    		canvas.update()
    		time.sleep(0.1)
     
    	root.mainloop()
    bon courage

Discussions similaires

  1. créer une sorte de progress bar avec jsp
    Par p1xl_01 dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 25/02/2010, 09h50
  2. [winAPI] Comment créer une progress bar ownerdraw ?
    Par kidpaddle2 dans le forum Windows
    Réponses: 1
    Dernier message: 01/08/2006, 11h02
  3. [MFC]Changer la couleur d'un progress bar
    Par Deedier dans le forum MFC
    Réponses: 1
    Dernier message: 21/04/2005, 18h39
  4. [VB.NET] Mise en place d'une progress bar
    Par Hoegaarden dans le forum Windows Forms
    Réponses: 14
    Dernier message: 19/10/2004, 09h23
  5. Progress bar au boot
    Par saibe dans le forum Administration système
    Réponses: 2
    Dernier message: 18/08/2003, 10h01

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