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

PyQt Python Discussion :

Aide à finaliser mon script


Sujet :

PyQt Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2011
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mars 2011
    Messages : 31
    Par défaut Aide à finaliser mon script
    Bonjour à tous.
    Pour commencer soyez indulgent je débute
    Je suis entrain de scripter un petit soft pour envoyer et recevoir des fichiers par FTP. Pour cela j'utilise NCFTP.

    L'interface je l'ai crée avec Designer.
    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
    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
    from PyQt4 import QtCore, QtGui
     
    try:
        _fromUtf8 = QtCore.QString.fromUtf8
    except AttributeError:
        _fromUtf8 = lambda s: s
     
    class Ui_Dialog(object):
        def setupUi(self, Dialog):
            Dialog.setObjectName(_fromUtf8("Dialog"))
            Dialog.resize(432, 389)
            Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "FTP Gui", None, QtGui.QApplication.UnicodeUTF8))
            Dialog.setToolTip(_fromUtf8(""))
            self.buttonBox = QtGui.QDialogButtonBox(Dialog)
            self.buttonBox.setGeometry(QtCore.QRect(70, 350, 341, 32))
            self.buttonBox.setMouseTracking(True)
            self.buttonBox.setAcceptDrops(True)
            self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
            self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Ok)
            self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
            self.shell = QtGui.QTextEdit(Dialog)
            self.shell.setGeometry(QtCore.QRect(20, 210, 391, 131))
            self.shell.setMouseTracking(True)
            self.shell.setAutoFillBackground(False)
            self.shell.setFrameShape(QtGui.QFrame.WinPanel)
            self.shell.setFrameShadow(QtGui.QFrame.Sunken)
            self.shell.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
            self.shell.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
            self.shell.setAutoFormatting(QtGui.QTextEdit.AutoAll)
            self.shell.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextEditable|QtCore.Qt.TextEditorInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
            self.shell.setObjectName(_fromUtf8("shell"))
            self.FTP = QtGui.QLineEdit(Dialog)
            self.FTP.setGeometry(QtCore.QRect(140, 10, 271, 20))
            self.FTP.setAutoFillBackground(False)
            self.FTP.setText(QtGui.QApplication.translate("Dialog", "192.168.1.1", None, QtGui.QApplication.UnicodeUTF8))
            self.FTP.setDragEnabled(True)
            self.FTP.setObjectName(_fromUtf8("FTP"))
            self.Login = QtGui.QLineEdit(Dialog)
            self.Login.setGeometry(QtCore.QRect(140, 40, 271, 20))
            self.Login.setText(QtGui.QApplication.translate("Dialog", "user", None, QtGui.QApplication.UnicodeUTF8))
            self.Login.setDragEnabled(True)
            self.Login.setObjectName(_fromUtf8("Login"))
            self.MdP = QtGui.QLineEdit(Dialog)
            self.MdP.setGeometry(QtCore.QRect(140, 70, 271, 20))
            self.MdP.setText(QtGui.QApplication.translate("Dialog", "password", None, QtGui.QApplication.UnicodeUTF8))
            self.MdP.setDragEnabled(True)
            self.MdP.setObjectName(_fromUtf8("MdP"))
            self.LocalFolder = QtGui.QLineEdit(Dialog)
            self.LocalFolder.setGeometry(QtCore.QRect(140, 100, 271, 20))
            self.LocalFolder.setText(QtGui.QApplication.translate("Dialog", "/test", None, QtGui.QApplication.UnicodeUTF8))
            self.LocalFolder.setDragEnabled(True)
            self.LocalFolder.setObjectName(_fromUtf8("LocalFolder"))
            self.RemoteFolder = QtGui.QLineEdit(Dialog)
            self.RemoteFolder.setGeometry(QtCore.QRect(140, 130, 271, 20))
            self.RemoteFolder.setText(QtGui.QApplication.translate("Dialog", "/", None, QtGui.QApplication.UnicodeUTF8))
            self.RemoteFolder.setDragEnabled(True)
            self.RemoteFolder.setObjectName(_fromUtf8("RemoteFolder"))
            self.LabelFTP = QtGui.QLabel(Dialog)
            self.LabelFTP.setGeometry(QtCore.QRect(20, 10, 81, 16))
            self.LabelFTP.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Adresse FTP</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelFTP.setObjectName(_fromUtf8("LabelFTP"))
            self.LabelLogin = QtGui.QLabel(Dialog)
            self.LabelLogin.setGeometry(QtCore.QRect(20, 40, 111, 16))
            self.LabelLogin.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Nom d\'utilisateur</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelLogin.setObjectName(_fromUtf8("LabelLogin"))
            self.LabelMdP = QtGui.QLabel(Dialog)
            self.LabelMdP.setGeometry(QtCore.QRect(20, 70, 101, 16))
            self.LabelMdP.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Mot de Passe</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelMdP.setObjectName(_fromUtf8("LabelMdP"))
            self.LabelLocalFolder = QtGui.QLabel(Dialog)
            self.LabelLocalFolder.setGeometry(QtCore.QRect(20, 100, 111, 16))
            self.LabelLocalFolder.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Répertoire Local</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelLocalFolder.setObjectName(_fromUtf8("LabelLocalFolder"))
            self.LabelRemoteFolder = QtGui.QLabel(Dialog)
            self.LabelRemoteFolder.setGeometry(QtCore.QRect(20, 130, 121, 16))
            self.LabelRemoteFolder.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Répertoire Distant</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelRemoteFolder.setObjectName(_fromUtf8("LabelRemoteFolder"))
            self.radioButtonUP = QtGui.QRadioButton(Dialog)
            self.radioButtonUP.setGeometry(QtCore.QRect(20, 170, 82, 17))
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            self.radioButtonUP.setFont(font)
            self.radioButtonUP.setText(QtGui.QApplication.translate("Dialog", "Upload", None, QtGui.QApplication.UnicodeUTF8))
            self.radioButtonUP.setChecked(True)
            self.radioButtonUP.setObjectName(_fromUtf8("radioButtonUP"))
            self.radioButtonDown = QtGui.QRadioButton(Dialog)
            self.radioButtonDown.setGeometry(QtCore.QRect(90, 170, 82, 17))
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            self.radioButtonDown.setFont(font)
            self.radioButtonDown.setText(QtGui.QApplication.translate("Dialog", "Download", None, QtGui.QApplication.UnicodeUTF8))
            self.radioButtonDown.setObjectName(_fromUtf8("radioButtonDown"))
            self.progressBar = QtGui.QProgressBar(Dialog)
            self.progressBar.setGeometry(QtCore.QRect(180, 170, 241, 23))
            font = QtGui.QFont()
            font.setBold(False)
            font.setWeight(50)
            self.progressBar.setFont(font)
            self.progressBar.setProperty("value", 0)
            self.progressBar.setObjectName(_fromUtf8("progressBar"))
            self.line = QtGui.QFrame(Dialog)
            self.line.setGeometry(QtCore.QRect(0, 150, 431, 20))
            self.line.setFrameShape(QtGui.QFrame.HLine)
            self.line.setFrameShadow(QtGui.QFrame.Sunken)
            self.line.setObjectName(_fromUtf8("line"))
     
            self.retranslateUi(Dialog)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.choice)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.close)
            QtCore.QMetaObject.connectSlotsByName(Dialog)
     
        def retranslateUi(self, Dialog):
            pass
     
        def choice(self):
            print("choix de l envoi")
            print(Login)
            if self.radioButtonUP == True:
                self.ncftpup
            if self.radioButtonDown == True:
                self.ncftpdown
     
        def ncftpup(self):
            Login="user"      # avec ca ca marche
            MdP="password"
            FTP="192.168.1.1"
            RemoteFolder="/"
            LocalFolder="/test"
            args = ["C:\\windows\\ncftpput.exe","-u", Login,"-p", MdP,"-R","-z", FTP, RemoteFolder, LocalFolder]
            cmd = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)    
            status=cmd.wait()
            pyerr = cmd.stderr.readlines()
            pyout = cmd.stdout.readlines()
            print(pyerr)
            print(pyout)
     
        def ncftpdown(self):
            args = ["C:\\windows\\ncftpget.exe","-u", Login,"-p", MdP,"-R","-z", FTP, LocalFolder, RemoteFolder]
            cmd = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)   
            status=cmd.wait()
            pyerr = cmd.stderr.readlines()
            pyout = cmd.stdout.readlines()
            print(pyerr)
            print(pyout)
     
     
    if __name__ == "__main__":
        import os, sys, subprocess
        app = QtGui.QApplication(sys.argv)
        Dialog = QtGui.QDialog()
        ui = Ui_Dialog()
        ui.setupUi(Dialog)
        Dialog.show()
        sys.exit(app.exec_())
    Plusieurs problèmes : Comment dire à subprocess d'utiliser les valeurs de connexion que je tape dans la fenêtre (ex: Nom d'utilisateur : user) car quand je le mets à la main ça fonctionne.

    Comment faire marcher les radiobuttons ainsi que la progressbar.

    Pouvez-vous me donner des pistes? C'est la première fois que j'utilise Qt. Ca à l'air compliquer mais que c'est pratique avec Designer pour faire de belles fenêtres.
    Mon objectif est de faire de simples scripts pour mon travail.

    Merci pour votre aide.

  2. #2
    Expert confirmé

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

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 307
    Par défaut
    Bonjour,

    1 Place cette ligne au tout début de ton script:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
        # -*- coding: utf-8 -*-
    2 Une bonne habitude à prendre, mettre les radioButton dans un groupe.
    Ici, tu n'en a que deux donc ca fonctionne, pour les utiliser, tu peux
    soit les connecter:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
        self.radioButtonUP.toggled.connect(self.maFonction)
    soit vérifier s'ils sont cochés
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
        if self.radioButtonUP.isChecked():
            ... action
    3 Pour les lineEdit, il suffit de les lire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
        ftp = unicode(self.FTP.text())
    4 Tes _fromUtf8 qui se balladent dans le code, je vois pas trop à quoi ils
    servent. Jamais utilisé.

    5 Tu peux aussi nettoyer ton code du Html en utilisant simplement une
    définition de fonte comme pour les radioButton.

    6 Pour les subprocess je ne vois rien d'anormal, il faudrait tester, je
    suppose que tu l'as fait, tu as eu des retours d'erreurs ?

    7 La progressBar s'utilise avec setValue(int) mais c'est toi qui, dans ton code, dois calculer le pourcentage de transfert. Si tu connais la taille totale, c'est faisable, sinon faut bricoler.

  3. #3
    Expert confirmé

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

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 307
    Par défaut
    Je ne l'avais pas vu, mais il faut mettre des parenthèses à tes appels de fonctions, je suppose que c'est un oubli.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
        def choice(self):
            print("choix de l envoi")
            print(Login)  # ! Login n'existe pas dans l'espace de nom de cette fonction !
            if self.radioButtonUP.isChecked():
                self.ncftpup()
            else:
                self.ncftpdown()

  4. #4
    Membre prolifique
    Avatar de Sve@r
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2006
    Messages
    12 831
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Février 2006
    Messages : 12 831
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par VinsS Voir le message
    4 Tes _fromUtf8 qui se balladent dans le code, je vois pas trop à quoi ils
    servent. Jamais utilisé.
    Salut

    Il l'a défini comme un raccourci de QString.fromUtf8(). Ca sert à rendre un texte utf8 (surtout s'il y a des accents) correctement écrit dans un objet Qt
    Mon Tutoriel sur la programmation «Python»
    Mon Tutoriel sur la programmation «Shell»
    Sinon il y en a pleins d'autres. N'oubliez pas non plus les différentes faq disponibles sur ce site
    Et on poste ses codes entre balises [code] et [/code]

  5. #5
    Rédacteur/Modérateur

    Avatar de Jiyuu
    Homme Profil pro
    Développeur amateur
    Inscrit en
    Janvier 2007
    Messages
    2 456
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur amateur
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 2 456
    Billets dans le blog
    15
    Par défaut
    Petite remarque... à mon avis modifier le code issu de QtDesigner n'est pas une très bonne idée. Lorsque tu vas regénérer ce code via pyuic, tu risques fort d'avoir une mauvaise surprise.

    À mon avis, il serait déjà bien de jeter un coup d'oeil à mon article traitant de QtDesigner et Eric.

    Pour les applications devant travailler avec un serveur ftp, tu as aussi QFtp de pas mal. Tu peux lire ce topic pour te faire une petite idée de la chose.

    Bonne continuation
    Initiation à Qt Quick et QML : Partie 1 - Partie 2
    En cas de besoin, pensez à la
    Mon site et mes tutoriaux sur Developpez.com
    Pas de question technique par MP... Les forums sont là pour ça

  6. #6
    Membre averti
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2011
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mars 2011
    Messages : 31
    Par défaut
    Allo,

    Merci merci pour toutes ces réponses vous êtes bien gentils.

    Je vais me mettre à la tâche pour améliorer mon script.
    Je vais vous revenir bientôt avec mes résultats.

    A plus.

  7. #7
    Membre averti
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2011
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Mars 2011
    Messages : 31
    Par défaut
    Bonjour Messieurs,

    Merci pour vos trucs ça m'a permis d'avancer dans mon script.

    Voici mon nouveau 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
    # -*- coding: utf-8 -*-
     
    from PyQt4 import QtCore, QtGui
     
    try:
        _fromUtf8 = QtCore.QString.fromUtf8
    except AttributeError:
        _fromUtf8 = lambda s: s
     
    class Ui_Dialog(object):
        def setupUi(self, Dialog):
            Dialog.setObjectName(_fromUtf8("Dialog"))
            Dialog.resize(432, 389)
            Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "FTP Gui", None, QtGui.QApplication.UnicodeUTF8))
            Dialog.setToolTip(_fromUtf8(""))
            self.buttonBox = QtGui.QDialogButtonBox(Dialog)
            self.buttonBox.setGeometry(QtCore.QRect(70, 350, 341, 32))
            self.buttonBox.setMouseTracking(True)
            self.buttonBox.setAcceptDrops(True)
            self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
            self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Ok)
            self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
            self.shell = QtGui.QTextEdit(Dialog)
            self.shell.setGeometry(QtCore.QRect(20, 210, 391, 131))
            self.shell.setMouseTracking(True)
            self.shell.setAutoFillBackground(False)
            self.shell.setFrameShape(QtGui.QFrame.WinPanel)
            self.shell.setFrameShadow(QtGui.QFrame.Sunken)
            self.shell.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
            self.shell.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
            self.shell.setAutoFormatting(QtGui.QTextEdit.AutoAll)
            self.shell.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextEditable|QtCore.Qt.TextEditorInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
            self.shell.setObjectName(_fromUtf8("shell"))
            self.FTP = QtGui.QLineEdit(Dialog)
            self.FTP.setGeometry(QtCore.QRect(140, 10, 271, 20))
            self.FTP.setAutoFillBackground(False)
            self.FTP.setText(QtGui.QApplication.translate("Dialog", "192.168.1.1", None, QtGui.QApplication.UnicodeUTF8))
            self.FTP.setDragEnabled(True)
            self.FTP.setObjectName(_fromUtf8("FTP"))
            self.Login = QtGui.QLineEdit(Dialog)
            self.Login.setGeometry(QtCore.QRect(140, 40, 271, 20))
            self.Login.setText(QtGui.QApplication.translate("Dialog", "user", None, QtGui.QApplication.UnicodeUTF8))
            self.Login.setDragEnabled(True)
            self.Login.setObjectName(_fromUtf8("Login"))
            self.MdP = QtGui.QLineEdit(Dialog)
            self.MdP.setGeometry(QtCore.QRect(140, 70, 271, 20))
            self.MdP.setText(QtGui.QApplication.translate("Dialog", "password", None, QtGui.QApplication.UnicodeUTF8))
            self.MdP.setDragEnabled(True)
            self.MdP.setObjectName(_fromUtf8("MdP"))
            self.LocalFolder = QtGui.QLineEdit(Dialog)
            self.LocalFolder.setGeometry(QtCore.QRect(140, 100, 271, 20))
            self.LocalFolder.setText(QtGui.QApplication.translate("Dialog", "/test", None, QtGui.QApplication.UnicodeUTF8))
            self.LocalFolder.setDragEnabled(True)
            self.LocalFolder.setObjectName(_fromUtf8("LocalFolder"))
            self.RemoteFolder = QtGui.QLineEdit(Dialog)
            self.RemoteFolder.setGeometry(QtCore.QRect(140, 130, 271, 20))
            self.RemoteFolder.setText(QtGui.QApplication.translate("Dialog", "/", None, QtGui.QApplication.UnicodeUTF8))
            self.RemoteFolder.setDragEnabled(True)
            self.RemoteFolder.setObjectName(_fromUtf8("RemoteFolder"))
            self.LabelFTP = QtGui.QLabel(Dialog)
            self.LabelFTP.setGeometry(QtCore.QRect(20, 10, 81, 16))
            self.LabelFTP.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Adresse FTP</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelFTP.setObjectName(_fromUtf8("LabelFTP"))
            self.LabelLogin = QtGui.QLabel(Dialog)
            self.LabelLogin.setGeometry(QtCore.QRect(20, 40, 111, 16))
            self.LabelLogin.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Nom d\'utilisateur</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelLogin.setObjectName(_fromUtf8("LabelLogin"))
            self.LabelMdP = QtGui.QLabel(Dialog)
            self.LabelMdP.setGeometry(QtCore.QRect(20, 70, 101, 16))
            self.LabelMdP.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Mot de Passe</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelMdP.setObjectName(_fromUtf8("LabelMdP"))
            self.LabelLocalFolder = QtGui.QLabel(Dialog)
            self.LabelLocalFolder.setGeometry(QtCore.QRect(20, 100, 111, 16))
            self.LabelLocalFolder.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Répertoire Local</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelLocalFolder.setObjectName(_fromUtf8("LabelLocalFolder"))
            self.LabelRemoteFolder = QtGui.QLabel(Dialog)
            self.LabelRemoteFolder.setGeometry(QtCore.QRect(20, 130, 121, 16))
            self.LabelRemoteFolder.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Répertoire Distant</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
            self.LabelRemoteFolder.setObjectName(_fromUtf8("LabelRemoteFolder"))
            self.radioButtonUP = QtGui.QRadioButton(Dialog)
            self.radioButtonUP.setGeometry(QtCore.QRect(20, 170, 82, 17))
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            self.radioButtonUP.setFont(font)
            self.radioButtonUP.setText(QtGui.QApplication.translate("Dialog", "Upload", None, QtGui.QApplication.UnicodeUTF8))
            self.radioButtonUP.setChecked(True)
            self.radioButtonUP.setObjectName(_fromUtf8("radioButtonUP"))
            self.radioButtonDown = QtGui.QRadioButton(Dialog)
            self.radioButtonDown.setGeometry(QtCore.QRect(90, 170, 82, 17))
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            self.radioButtonDown.setFont(font)
            self.radioButtonDown.setText(QtGui.QApplication.translate("Dialog", "Download", None, QtGui.QApplication.UnicodeUTF8))
            self.radioButtonDown.setObjectName(_fromUtf8("radioButtonDown"))
            self.progressBar = QtGui.QProgressBar(Dialog)
            self.progressBar.setGeometry(QtCore.QRect(180, 170, 241, 23))
            font = QtGui.QFont()
            font.setBold(False)
            font.setWeight(50)
            self.progressBar.setFont(font)
            self.progressBar.setProperty("value", 0)
            self.progressBar.setObjectName(_fromUtf8("progressBar"))
            self.line = QtGui.QFrame(Dialog)
            self.line.setGeometry(QtCore.QRect(0, 150, 431, 20))
            self.line.setFrameShape(QtGui.QFrame.HLine)
            self.line.setFrameShadow(QtGui.QFrame.Sunken)
            self.line.setObjectName(_fromUtf8("line"))
     
            self.retranslateUi(Dialog)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.choice)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.close)
            QtCore.QMetaObject.connectSlotsByName(Dialog)
     
        def retranslateUi(self, Dialog):
            pass
     
        def choice(self):
            if self.radioButtonUP.isChecked():
                self.ncftpup()
            if self.radioButtonDown.isChecked():
                self.ncftpdown()
     
        def ncftpup(self):
            Login = self.Login.text()
            MdP = self.MdP.text()
            FTP = self.FTP.text()
            RemoteFolder = self.RemoteFolder.text()
            LocalFolder = self.LocalFolder.text()
            args = ["C:\\windows\\ncftpput.exe","-u", Login,"-p", MdP,"-R","-z", FTP, RemoteFolder, LocalFolder]
            cmd = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)   
            status=cmd.wait()
            pyerr = cmd.stderr.readlines()
            pyout = cmd.stdout.readlines()
            print(pyerr)
            print(pyout)
            self.step = 0
            self.step += 100
            self.progressBar.setValue(self.step)
     
        def ncftpdown(self):
            Login = self.Login.text()
            MdP = self.MdP.text()
            FTP = self.FTP.text()
            RemoteFolder = self.RemoteFolder.text()
            LocalFolder = self.LocalFolder.text()
            args = ["C:\\windows\\ncftpget.exe","-u", Login,"-p", MdP,"-R","-z", FTP, LocalFolder, RemoteFolder]
            cmd = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)    
            status=cmd.wait()
            pyerr = cmd.stderr.readlines()
            pyout = cmd.stdout.readlines()
     
     
    if __name__ == "__main__":
        import os, sys, subprocess
        app = QtGui.QApplication(sys.argv)
        Dialog = QtGui.QDialog()
        ui = Ui_Dialog()
        ui.setupUi(Dialog)
        Dialog.show()
        sys.exit(app.exec_())
    J'ai ajouté la partie ProgressBar mais à part la faire progresser de 0 à 100 d'un coup j'ai pas trouvé comment faire pour qu'elle s'ajuste avec l'upload ou download.
    J'aimerais aussi savoir comment je peux écrire le résultat de la commande ncftp (erreur etc..) ainsi qu'un texte qui me dit "Opération réussie" dans mon widget Shell.

    Merci de votre aide précieuse.

    Bonne journée

Discussions similaires

  1. Aide sur mon script
    Par naniccino dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 13
    Dernier message: 29/01/2015, 11h37
  2. Besoin d'aide pour mon script sur les listes chainées
    Par narama87 dans le forum Débuter
    Réponses: 1
    Dernier message: 13/01/2011, 12h29
  3. Aide pour mon premier script sous linux
    Par bomonde dans le forum Shell et commandes GNU
    Réponses: 1
    Dernier message: 21/10/2010, 13h27
  4. [AJAX] Finalisation de mon site
    Par belvina dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 25/01/2006, 01h54

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