| 12
 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
 
 | # -*- coding: iso-8859-1 -*-
 
from ftplib import *
from tkinter import *
 
 
class Graphique:
    def __init__(self):
        #instanciation d'un nouvel objet de ClientFtp
        client=ClientFtp("ftpperso.free.fr","blablabla","blablabla"
 
        self.root = Tk()
        self.root.configure(height="500", width="500", bg='#548754')
        self.can = Canvas(self.root, height="200", width="300", bg="ivory").pack()
        btnConnect = Button(self.can, text="connexion", command=client.connexion).pack()
        btnDeconnect = Button(self.can, text="deconnexion", command=client.deconnexion).pack()
        btnAffiche = Button(self.can, text="afficher", command=client.afficherContenu).pack()
        self.root.mainloop()
 
class ClientFtp:
    def __init__(self,host,user,password):
        self.host = host
        self.port = "21"
        self.user = user
        self.password = password
        self.etatConnexion="0"
        print (self.host)
        print (self.port)
        print (self.user)
        print (self.password)
 
    def connexion(self):
        try:
            FTP(self.host, self.user, self.password)
            self.etat="connecté"
            print('Etat:',self.etat)
            self.etatConnexion="1"
        except:
            self.etat="non connecté"
            print('Etat:',self.etat)
 
    def afficherContenu(self):
         if self.etatConnexion=="1":
            rep = pwd()
            print(rep)
        else:
            print("on n'est pas connecté")
 
    def deconnexion(self):
        try:
            FTP.quit
            self.etat="non connecté"
            print('Etat:',self.etat)
        except:
            print('Etat:',self.etat)
 
 
 
if __name__ == "__main__":
    Graphique() | 
Partager