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 :

[QDialog] La fenêtre ne se charge pas [QtGui]


Sujet :

PyQt Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2006
    Messages
    105
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Distribution

    Informations forums :
    Inscription : Novembre 2006
    Messages : 105
    Par défaut [QDialog] La fenêtre ne se charge pas
    Bonjour à tous,

    Voilà j'ai quelque soucis avec une application que je développe pour le moment.
    J'ai déjà utiliser quelques fenêtre QDialog dans mon projet et pas de problème.
    Mais je viens d'en créer une nouvelle qui m'en pause un gros, lorsque que j'appelle celle-ci c'est une autre fenêtre qui s'affiche.

    Normalement je devrait obtenir ceci :


    Et j'obtiens ceci :


    Si j'appelle ma fenêtre avec exe_() ou show() cela pause le même soucis...

    Voici la classe de la fenetre :
    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
    # -*- coding: utf-8 -*-
     
    from PyQt4 import QtCore, QtGui
     
    class Ui_Dialog(object):
        def setupUi(self, Dialog):
            Dialog.setObjectName("Dialog")
            Dialog.resize(315, 119)
            Dialog.setModal(True)
            self.label = QtGui.QLabel(Dialog)
            self.label.setGeometry(QtCore.QRect(1, 21, 311, 46))
            font = QtGui.QFont()
            font.setPointSize(14)
            font.setWeight(75)
            font.setBold(True)
            self.label.setFont(font)
            self.label.setAlignment(QtCore.Qt.AlignCenter)
            self.label.setObjectName("label")
            self.buttonBox = QtGui.QDialogButtonBox(Dialog)
            self.buttonBox.setGeometry(QtCore.QRect(80, 80, 156, 23))
            self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
            self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.No|QtGui.QDialogButtonBox.Yes)
            self.buttonBox.setObjectName("buttonBox")
     
            self.retranslateUi(Dialog)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
            QtCore.QMetaObject.connectSlotsByName(Dialog)
     
        def retranslateUi(self, Dialog):
            Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Attention !", None, QtGui.QApplication.UnicodeUTF8))
            self.label.setText(QtGui.QApplication.translate("Dialog", "Voulez-vous vraiment \n"
    "supprimer cette entitée ?", None, QtGui.QApplication.UnicodeUTF8))

  2. #2
    Membre éprouvé
    Inscrit en
    Avril 2010
    Messages
    99
    Détails du profil
    Informations personnelles :
    Âge : 43

    Informations forums :
    Inscription : Avril 2010
    Messages : 99
    Par défaut
    Bonjour,

    peux-tu faire voir le code qui fait appel à cette boite de dialogue stp ?
    Ce code a-t-il été généré par pyuic ?

  3. #3
    Membre confirmé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2006
    Messages
    105
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Distribution

    Informations forums :
    Inscription : Novembre 2006
    Messages : 105
    Par défaut
    La méthode setupui() a été généré par pyuic, mais le reste est de ma main...

    Voici comment j'appelle la fenêtre :

    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
    from ui_Dialog_Suppr_Entite import Ui_Dialog_Suppr_Entite
    from lib_vtek import *
     
    class Ui_Form_gestion_entite(QtGui.QWidget):
        def __init__(self):
            QtGui.QWidget.__init__(self)
            self.setupUi(self)
            self.Tag_Btn_modif = "modif"
            self.Btn_modif.setEnabled(False)
            self.db = DB_Connection()
            self.entite = Vtek_Entite()
     
       #Je vous passe une grosse partie du code :)
     
        def Action_Btn_suppr(self):
            self.dialog = Ui_Dialog_Suppr_Entite()
            self.dialog.exec_()

  4. #4
    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
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    def Action_Btn_suppr(self):
        dialog = QtGui.QDialog()
        sup = Ui_Dialog(dialog)
        sup.setupUi()
        reply = dialog.exec_()
    Je pense que ça ira mieux comme ça.

    Vincent

  5. #5
    Membre confirmé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2006
    Messages
    105
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Distribution

    Informations forums :
    Inscription : Novembre 2006
    Messages : 105
    Par défaut
    Merci pour la réponse Vincent,
    Effectivement, ainsi cela fonctionne... Seulement je ne comprend pas pourquoi une autre dialog s'affiche.

    En faite, je gère des entités(client, employé ou fournisseur) j'ai une boite de dialogue pour rechercher les entite, et une autre pour confirmer la suppresion d'une entité.
    J'appelle la boite de dialog de recherche ainsi et cela fonctionne... Pourquoi une et pas l'autre ? :s

    Ui_Form_Gestion_Entite
    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
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    # -*- coding: utf-8 -*-
     
    # Form implementation generated from reading ui file 'ui_Gestion_Entite.ui'
    #
    # Created: Tue Apr 27 23:53:28 2010
    #      by: PyQt4 UI code generator 4.7
    #
    # WARNING! All changes made in this file will be lost!
     
    from PyQt4 import QtCore, QtGui
    from ui_Dialog_Recherche_Entite import Ui_Dialog_recherche_entite
    from ui_Dialog_Suppr_Entite import Ui_Dialog_Suppr_Entite
    from lib_vtek import *
     
    class Ui_Form_gestion_entite(QtGui.QWidget):
        def __init__(self):
            QtGui.QWidget.__init__(self)
            self.setupUi(self)
            self.Tag_Btn_modif = "modif"
            self.Btn_modif.setEnabled(False)
            self.db = DB_Connection()
            self.entite = Vtek_Entite()
     
        def setupUi(self, Form_gestion_entite):
            Form_gestion_entite.setObjectName("Form_gestion_entite")
            Form_gestion_entite.resize(642, 480)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(Form_gestion_entite.sizePolicy().hasHeightForWidth())
            Form_gestion_entite.setSizePolicy(sizePolicy)
            self.verticalLayout_2 = QtGui.QVBoxLayout(Form_gestion_entite)
            self.verticalLayout_2.setObjectName("verticalLayout_2")
            self.horizontalLayout = QtGui.QHBoxLayout()
            self.horizontalLayout.setObjectName("horizontalLayout")
            self.verticalLayout = QtGui.QVBoxLayout()
            self.verticalLayout.setObjectName("verticalLayout")
            self.groupBoxRecherche = QtGui.QGroupBox(Form_gestion_entite)
            self.groupBoxRecherche.setObjectName("groupBoxRecherche")
            self.gridLayout = QtGui.QGridLayout(self.groupBoxRecherche)
            self.gridLayout.setObjectName("gridLayout")
            self.labelNom = QtGui.QLabel(self.groupBoxRecherche)
            self.labelNom.setObjectName("labelNom")
            self.gridLayout.addWidget(self.labelNom, 0, 0, 1, 1)
            self.textboxNom = QtGui.QLineEdit(self.groupBoxRecherche)
            self.textboxNom.setObjectName("textboxNom")
            self.gridLayout.addWidget(self.textboxNom, 0, 1, 1, 1)
            self.labelPrenom = QtGui.QLabel(self.groupBoxRecherche)
            self.labelPrenom.setObjectName("labelPrenom")
            self.gridLayout.addWidget(self.labelPrenom, 0, 2, 1, 1)
            self.textboxPrenom = QtGui.QLineEdit(self.groupBoxRecherche)
            self.textboxPrenom.setObjectName("textboxPrenom")
            self.gridLayout.addWidget(self.textboxPrenom, 0, 3, 1, 1)
            self.Btn_Rechercher = QtGui.QPushButton(self.groupBoxRecherche)
            self.Btn_Rechercher.setObjectName("Btn_Rechercher")
            self.gridLayout.addWidget(self.Btn_Rechercher, 0, 4, 1, 1)
            self.verticalLayout.addWidget(self.groupBoxRecherche)
            self.line = QtGui.QFrame(Form_gestion_entite)
            self.line.setFrameShape(QtGui.QFrame.HLine)
            self.line.setFrameShadow(QtGui.QFrame.Sunken)
            self.line.setObjectName("line")
            self.verticalLayout.addWidget(self.line)
            self.groupeBoxDetail = QtGui.QGroupBox(Form_gestion_entite)
            self.groupeBoxDetail.setObjectName("groupeBoxDetail")
            self.gridLayout_2 = QtGui.QGridLayout(self.groupeBoxDetail)
            self.gridLayout_2.setObjectName("gridLayout_2")
            self.labelDetNom = QtGui.QLabel(self.groupeBoxDetail)
            self.labelDetNom.setObjectName("labelDetNom")
            self.gridLayout_2.addWidget(self.labelDetNom, 0, 0, 1, 1)
            self.textbox_nom = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_nom.setEnabled(False)
            self.textbox_nom.setObjectName("textbox_nom")
            self.gridLayout_2.addWidget(self.textbox_nom, 0, 1, 1, 2)
            self.labelDetPrenom = QtGui.QLabel(self.groupeBoxDetail)
            self.labelDetPrenom.setObjectName("labelDetPrenom")
            self.gridLayout_2.addWidget(self.labelDetPrenom, 0, 3, 1, 1)
            self.textbox_prenom = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_prenom.setEnabled(False)
            self.textbox_prenom.setObjectName("textbox_prenom")
            self.gridLayout_2.addWidget(self.textbox_prenom, 0, 4, 1, 2)
            self.label = QtGui.QLabel(self.groupeBoxDetail)
            self.label.setObjectName("label")
            self.gridLayout_2.addWidget(self.label, 1, 0, 1, 1)
            self.textbox_adresse1 = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_adresse1.setEnabled(False)
            self.textbox_adresse1.setObjectName("textbox_adresse1")
            self.gridLayout_2.addWidget(self.textbox_adresse1, 1, 1, 1, 5)
            self.textbox_adresse2 = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_adresse2.setEnabled(False)
            self.textbox_adresse2.setObjectName("textbox_adresse2")
            self.gridLayout_2.addWidget(self.textbox_adresse2, 2, 1, 1, 5)
            self.labelCP = QtGui.QLabel(self.groupeBoxDetail)
            self.labelCP.setObjectName("labelCP")
            self.gridLayout_2.addWidget(self.labelCP, 3, 0, 1, 1)
            self.textbox_cp = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_cp.setEnabled(False)
            self.textbox_cp.setObjectName("textbox_cp")
            self.gridLayout_2.addWidget(self.textbox_cp, 3, 1, 1, 2)
            self.labelville = QtGui.QLabel(self.groupeBoxDetail)
            self.labelville.setObjectName("labelville")
            self.gridLayout_2.addWidget(self.labelville, 3, 3, 1, 1)
            self.textbox_ville = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_ville.setEnabled(False)
            self.textbox_ville.setObjectName("textbox_ville")
            self.gridLayout_2.addWidget(self.textbox_ville, 3, 4, 1, 2)
            self.label_2 = QtGui.QLabel(self.groupeBoxDetail)
            self.label_2.setObjectName("label_2")
            self.gridLayout_2.addWidget(self.label_2, 4, 0, 1, 1)
            self.textbox_pays = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_pays.setEnabled(False)
            self.textbox_pays.setObjectName("textbox_pays")
            self.gridLayout_2.addWidget(self.textbox_pays, 4, 1, 1, 2)
            self.label_6 = QtGui.QLabel(self.groupeBoxDetail)
            self.label_6.setObjectName("label_6")
            self.gridLayout_2.addWidget(self.label_6, 4, 3, 1, 1)
            self.textbox_tva = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_tva.setEnabled(False)
            self.textbox_tva.setObjectName("textbox_tva")
            self.gridLayout_2.addWidget(self.textbox_tva, 4, 4, 1, 2)
            self.label_4 = QtGui.QLabel(self.groupeBoxDetail)
            self.label_4.setObjectName("label_4")
            self.gridLayout_2.addWidget(self.label_4, 5, 0, 1, 1)
            self.textbox_tel = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_tel.setEnabled(False)
            self.textbox_tel.setObjectName("textbox_tel")
            self.gridLayout_2.addWidget(self.textbox_tel, 5, 1, 1, 2)
            self.label_5 = QtGui.QLabel(self.groupeBoxDetail)
            self.label_5.setObjectName("label_5")
            self.gridLayout_2.addWidget(self.label_5, 5, 3, 1, 1)
            self.textbox_fax = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_fax.setEnabled(False)
            self.textbox_fax.setObjectName("textbox_fax")
            self.gridLayout_2.addWidget(self.textbox_fax, 5, 4, 1, 2)
            self.label_3 = QtGui.QLabel(self.groupeBoxDetail)
            self.label_3.setObjectName("label_3")
            self.gridLayout_2.addWidget(self.label_3, 6, 0, 1, 1)
            self.textbox_email = QtGui.QLineEdit(self.groupeBoxDetail)
            self.textbox_email.setEnabled(False)
            self.textbox_email.setObjectName("textbox_email")
            self.gridLayout_2.addWidget(self.textbox_email, 6, 1, 1, 5)
            self.label_7 = QtGui.QLabel(self.groupeBoxDetail)
            self.label_7.setObjectName("label_7")
            self.gridLayout_2.addWidget(self.label_7, 7, 0, 1, 2)
            self.texbox_birth = QtGui.QLineEdit(self.groupeBoxDetail)
            self.texbox_birth.setEnabled(False)
            self.texbox_birth.setObjectName("texbox_birth")
            self.gridLayout_2.addWidget(self.texbox_birth, 7, 2, 1, 1)
            self.Btn_modif = QtGui.QPushButton(self.groupeBoxDetail)
            self.Btn_modif.setObjectName("Btn_modif")
            self.gridLayout_2.addWidget(self.Btn_modif, 7, 3, 1, 2)
            self.Btn_suppr = QtGui.QPushButton(self.groupeBoxDetail)
            self.Btn_suppr.setObjectName("Btn_suppr")
            self.Btn_suppr.setEnabled(False)
            self.gridLayout_2.addWidget(self.Btn_suppr, 7, 5, 1, 1)
            self.verticalLayout.addWidget(self.groupeBoxDetail)
            self.groupBoxRole = QtGui.QGroupBox(Form_gestion_entite)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.groupBoxRole.sizePolicy().hasHeightForWidth())
            self.groupBoxRole.setSizePolicy(sizePolicy)
            self.groupBoxRole.setObjectName("groupBoxRole")
            self.horizontalLayout_2 = QtGui.QHBoxLayout(self.groupBoxRole)
            self.horizontalLayout_2.setObjectName("horizontalLayout_2")
            self.list_role = QtGui.QListView(self.groupBoxRole)
            self.list_role.setEnabled(False)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.list_role.sizePolicy().hasHeightForWidth())
            self.list_role.setSizePolicy(sizePolicy)
            self.list_role.setObjectName("list_role")
            self.horizontalLayout_2.addWidget(self.list_role)
            self.verticalLayout.addWidget(self.groupBoxRole)
            self.horizontalLayout.addLayout(self.verticalLayout)
            self.verticalLayout_2.addLayout(self.horizontalLayout)
     
            self.retranslateUi(Form_gestion_entite)
            QtCore.QObject.connect(self.Btn_Rechercher, QtCore.SIGNAL("clicked()"), self.Action_Btn_rechercher)
            QtCore.QObject.connect(self.Btn_modif, QtCore.SIGNAL("clicked()"), self.Action_Btn_modif)
            self.connect(self.Btn_suppr,QtCore.SIGNAL("clicked()"), self.Action_Btn_suppr)
            QtCore.QMetaObject.connectSlotsByName(Form_gestion_entite)
     
        def retranslateUi(self, Form_gestion_entite):
            Form_gestion_entite.setWindowTitle(QtGui.QApplication.translate("Form_gestion_entite", "Gestion des entitée", None, QtGui.QApplication.UnicodeUTF8))
            self.groupBoxRecherche.setTitle(QtGui.QApplication.translate("Form_gestion_entite", "Recherche", None, QtGui.QApplication.UnicodeUTF8))
            self.labelNom.setText(QtGui.QApplication.translate("Form_gestion_entite", "Nom :", None, QtGui.QApplication.UnicodeUTF8))
            self.labelPrenom.setText(QtGui.QApplication.translate("Form_gestion_entite", "Prénom :", None, QtGui.QApplication.UnicodeUTF8))
            self.Btn_Rechercher.setText(QtGui.QApplication.translate("Form_gestion_entite", "Rechercher...", None, QtGui.QApplication.UnicodeUTF8))
            self.groupeBoxDetail.setTitle(QtGui.QApplication.translate("Form_gestion_entite", "Détails", None, QtGui.QApplication.UnicodeUTF8))
            self.labelDetPrenom.setText(QtGui.QApplication.translate("Form_gestion_entite", "Prénom :", None, QtGui.QApplication.UnicodeUTF8))
            self.labelville.setText(QtGui.QApplication.translate("Form_gestion_entite", "Ville :", None, QtGui.QApplication.UnicodeUTF8))
            self.label_6.setText(QtGui.QApplication.translate("Form_gestion_entite", "TVA :", None, QtGui.QApplication.UnicodeUTF8))
            self.label_5.setText(QtGui.QApplication.translate("Form_gestion_entite", "Fax:", None, QtGui.QApplication.UnicodeUTF8))
            self.labelDetNom.setText(QtGui.QApplication.translate("Form_gestion_entite", "Nom :", None, QtGui.QApplication.UnicodeUTF8))
            self.label.setText(QtGui.QApplication.translate("Form_gestion_entite", "Adresse :", None, QtGui.QApplication.UnicodeUTF8))
            self.label_7.setText(QtGui.QApplication.translate("Form_gestion_entite", "Date de naissance :", None, QtGui.QApplication.UnicodeUTF8))
            self.label_3.setText(QtGui.QApplication.translate("Form_gestion_entite", "E-mail :", None, QtGui.QApplication.UnicodeUTF8))
            self.label_4.setText(QtGui.QApplication.translate("Form_gestion_entite", "Tel :", None, QtGui.QApplication.UnicodeUTF8))
            self.label_2.setText(QtGui.QApplication.translate("Form_gestion_entite", "Pays :", None, QtGui.QApplication.UnicodeUTF8))
            self.labelCP.setText(QtGui.QApplication.translate("Form_gestion_entite", "CP :", None, QtGui.QApplication.UnicodeUTF8))
            self.Btn_modif.setText(QtGui.QApplication.translate("Form_gestion_entite", "Modifier", None, QtGui.QApplication.UnicodeUTF8))
            self.Btn_suppr.setText(QtGui.QApplication.translate("Form_gestion_entite", "Supprimer", None, QtGui.QApplication.UnicodeUTF8))
            self.groupBoxRole.setTitle(QtGui.QApplication.translate("Form_gestion_entite", "Rôles", None, QtGui.QApplication.UnicodeUTF8))
     
        def Action_Btn_modif(self):
            if self.Tag_Btn_modif == "modif":#Si le bouton est en position modifier...
                self.Enable_UserControl(True)
                self.Btn_modif.setText("Terminer")
                self.Tag_Btn_modif = "Term"
            else:#Si le bouton est en pousition Terminer
                self.entite.setEntite(self.entite.id, self.textbox_nom.text(), self.textbox_prenom.text(), self.textbox_adresse1.text(), self.textbox_adresse2.text(), self.textbox_cp.text(), self.textbox_ville.text(), self.textbox_pays.text(), self.textbox_tva.text(), self.textbox_tel.text(), self.textbox_email.text(), self.texbox_birth.text())
                self.db.update_entite(self.entite)
                self.Enable_UserControl(False)
                self.Btn_modif.setEnabled(True)
                self.Btn_modif.setText("Modifier")
                self.Tag_Btn_modif = "modif"
     
        def Action_Btn_suppr(self):
            dialog_suppr_entite = Ui_Dialog_Suppr_Entite()
            if (dialog_suppr_entite.exec_()):
                print("Entite supprimee")
                self.entite.__init__()# je redefini l'objet entite à zero
                self.Charger_entite(self.entite)
                self.Enable_UserControl(False)
                self.Btn_modif.setText("Modifier")
                self.Tag_Btn_modif = "modif"
     
        def Action_Btn_rechercher(self):#Affiche la fenetre de dialogue pour la selection de la rechervhr
            dialog_recherche_entite = Ui_Dialog_recherche_entite(self,self.textboxNom.text(), self.textboxPrenom.text())
            if (dialog_recherche_entite.exec_()):#j'utilise exec_ car la fenetre est modal, et une fenetre dialogue qui est modal s'apelle ainsi. Rendre la fenetre modal permet de la rendre blocante...
                self.Btn_modif.setEnabled(True)
     
        def Enable_UserControl(self, Bool):#Active ou non les widget de la fenetre
            self.textbox_nom.setEnabled(Bool)
            self.textbox_prenom.setEnabled(Bool)
            self.textbox_adresse1.setEnabled(Bool)
            self.textbox_adresse2.setEnabled(Bool)
            self.textbox_cp.setEnabled(Bool)
            self.textbox_ville.setEnabled(Bool)
            self.textbox_pays.setEnabled(Bool)
            self.textbox_tva.setEnabled(Bool)
            self.textbox_tel.setEnabled(Bool)
            self.textbox_fax.setEnabled(Bool)
            self.textbox_email.setEnabled(Bool)
            self.texbox_birth.setEnabled(Bool)
            self.list_role.setEnabled(Bool)
            self.Btn_modif.setEnabled(Bool)
            self.Btn_suppr.setEnabled(Bool)
     
        def Charger_entite(self, entite):#Charge l'entite reçue dans la fenetre
            self.entite = entite# je defini l'objet de cette classe par celui recu en parametre
            self.textbox_nom.setText(self.entite.nom)#Je defini la valeur des LineEdit
            self.textbox_prenom.setText(self.entite.prenom)
            self.textbox_adresse1.setText(self.entite.adresse)
            self.textbox_adresse2.setText(self.entite.adresse2)
            self.textbox_cp.setText(self.entite.cp)
            self.textbox_ville.setText(self.entite.ville)
            self.textbox_pays.setText(self.entite.pays)
            self.textbox_tva.setText(self.entite.tva)
            self.textbox_tel.setText(self.entite.telephone)
            self.texbox_birth.setText(self.entite.naissance)
            self.textbox_email.setText(self.entite.email)
    Ui_Dialog_Recherche_entite.py
    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
    # -*- coding: utf-8 -*-
     
    from PyQt4 import QtCore, QtGui
    from lib_vtek import *
     
    class Ui_Dialog_recherche_entite(QtGui.QDialog):
        def __init__(self, Ref_Form_gestion_entite,saisie_nom, saisie_prenom):
            QtGui.QDialog.__init__(self)
            self.setupUi(self)
            self.saisie_n = saisie_nom
            self.saisie_p = saisie_prenom
            self.Parent = Ref_Form_gestion_entite
            self.ligne_select = None
            self.DB = DB_Connection()
            self.rechercher()
     
        def setupUi(self, Dialog_recherche_entite):
            Dialog_recherche_entite.setObjectName("Dialog_recherche_entite")
            Dialog_recherche_entite.resize(549, 336)
            Dialog_recherche_entite.setModal(True)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(Dialog_recherche_entite.sizePolicy().hasHeightForWidth())
            Dialog_recherche_entite.setSizePolicy(sizePolicy)
            Dialog_recherche_entite.setMinimumSize(QtCore.QSize(549, 336))
            Dialog_recherche_entite.setMaximumSize(QtCore.QSize(549, 336))
            font = QtGui.QFont()
            font.setPointSize(14)
            font.setWeight(75)
            font.setItalic(True)
            font.setBold(True)
            Dialog_recherche_entite.setFont(font)
            self.buttonBox = QtGui.QDialogButtonBox(Dialog_recherche_entite)
            self.buttonBox.setGeometry(QtCore.QRect(370, 290, 161, 32))
            font = QtGui.QFont()
            font.setPointSize(10)
            font.setWeight(50)
            font.setItalic(False)
            font.setBold(False)
            self.buttonBox.setFont(font)
            self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
            self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
            self.buttonBox.setObjectName("buttonBox")
            self.label = QtGui.QLabel(Dialog_recherche_entite)
            self.label.setGeometry(QtCore.QRect(20, 10, 91, 21))
            font = QtGui.QFont()
            font.setPointSize(14)
            font.setWeight(75)
            font.setItalic(False)
            font.setUnderline(True)
            font.setBold(True)
            self.label.setFont(font)
            self.label.setObjectName("label")
            self.label_number = QtGui.QLabel(Dialog_recherche_entite)
            self.label_number.setGeometry(QtCore.QRect(120, 14, 211, 20))
            font = QtGui.QFont()
            font.setFamily("Arial")
            font.setItalic(False)
            self.label_number.setFont(font)
            self.label_number.setObjectName("label_number")
            self.tablewidget = QtGui.QTableWidget(self)
            self.tablewidget.setGeometry(QtCore.QRect(10, 40, 521, 241))
            self.tablewidget.setObjectName("tablewidget")
            self.tablewidget.setColumnCount(6)
            tableHeader = ["Nom", "Prenom", "Adresse", "CP", "Ville", "Date de naissance"]
            self.tablewidget.setHorizontalHeaderLabels(tableHeader)
     
            self.retranslateUi(Dialog_recherche_entite)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.Accepter)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog_recherche_entite.reject)
            self.connect(self.tablewidget, QtCore.SIGNAL("cellClicked(int,int)"), self.Select_Row)# Les deux parametres du signal sont transmit à self.Select_Row
            self.connect(self.tablewidget, QtCore.SIGNAL("cellDoubleClicked(int,int)"), self.Accepter)
            QtCore.QMetaObject.connectSlotsByName(Dialog_recherche_entite)
     
        def retranslateUi(self, Dialog_recherche_entite):
            Dialog_recherche_entite.setWindowTitle(QtGui.QApplication.translate("Dialog_recherche_entite", "Choisissez une entite", None, QtGui.QApplication.UnicodeUTF8))
            self.label.setText(QtGui.QApplication.translate("Dialog_recherche_entite", "Trouve : ", None, QtGui.QApplication.UnicodeUTF8))
            self.label_number.setText(QtGui.QApplication.translate("Dialog_recherche_entite", "Recherche en cours...", None, QtGui.QApplication.UnicodeUTF8))
     
        def Select_Row(self, row, col):
            Selection = QtGui.QTableWidgetSelectionRange(row, 0, row, 5)
            self.tablewidget.setRangeSelected(Selection, True)
            self.ligne_select = self.Matrice[row][0]
     
        def Accepter(self):
            if (self.ligne_select != None):
                self.Parent.Charger_entite(self.DB.load_entite(self.ligne_select))
                self.accept()
            self.close()
     
        def rechercher(self):
            self.label_number.setText(self.DB.count_entite(self.saisie_n, self.saisie_p))
            self.Matrice = self.DB.search_entite(self.saisie_n, self.saisie_p)# Recuperation d'une matrice (Liste de liste) contenant les données...
            self.tablewidget.setRowCount(len(self.Matrice))# J'établi le nombre de ligne dans le tablewidget
            Mac = 0 # Id de collone
            Mal = 0 # Id de ligne
            for Ligne in self.Matrice:
                for Colonne in Ligne:
                    #print "Ligne : " + str(Mal) + "Collone : " + str(Mac)
                    #print "Contenu :" + Colonne
                    #print " "
                    if (Mac > 0):
                        item = QtGui.QTableWidgetItem(Colonne)# Creation d'un QtableWidgetItem
                        self.tablewidget.setItem(Mal, Mac - 1, item)# Je place le QtableWidgetItem dans le tableau
                    Mac = Mac + 1            
                Mac = 0
                Mal = Mal + 1
    Ui_Dialog_Suppr_Entite
    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
    # -*- coding: utf-8 -*-
     
    from PyQt4 import QtCore, QtGui
     
    class Ui_Dialog_Suppr_Entite(QtGui.QDialog):
        def __inti__(self):
            QtGui.QDialog.__init__(self)
            self.setupUi(self)
     
        def setupUi(self, dialog_suppr_entite):
            dialog_suppr_entite.setObjectName("dialog_suppr_entite")
            dialog_suppr_entite.resize(315, 119)
            dialog_suppr_entite.setModal(True)
            self.label = QtGui.QLabel(dialog_suppr_entite)
            self.label.setGeometry(QtCore.QRect(1, 21, 311, 46))
            font = QtGui.QFont()
            font.setPointSize(14)
            font.setWeight(75)
            font.setBold(True)
            self.label.setFont(font)
            self.label.setAlignment(QtCore.Qt.AlignCenter)
            self.label.setObjectName("label")
            self.buttonBox = QtGui.QDialogButtonBox(dialog_suppr_entite)
            self.buttonBox.setGeometry(QtCore.QRect(80, 80, 156, 23))
            self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
            self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.No|QtGui.QDialogButtonBox.Yes)
            self.buttonBox.setObjectName("buttonBox")
     
            self.retranslateUi(dialog_suppr_entite)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), dialog_suppr_entite.accept)
            QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), dialog_suppr_entite.reject)
            QtCore.QMetaObject.connectSlotsByName(dialog_suppr_entite)
     
        def retranslateUi(self, dialog_suppr_entite):
            dialog_suppr_entite.setWindowTitle(QtGui.QApplication.translate("dialog_suppr_entite", "Attention !", None, QtGui.QApplication.UnicodeUTF8))
            self.label.setText(QtGui.QApplication.translate("dialog_suppr_entite", "Voulez-vous vraiment \nsupprimer cette entitée ?", None, QtGui.QApplication.UnicodeUTF8))
    Je veux juste comprendre pourquoi cela fonctionne dans un cas et pas dans l'autre...

    Merci pour vos réponse car c'est pour un projet que je dois rendre dans 1 mois et je galère

  6. #6
    Membre confirmé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2006
    Messages
    105
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Distribution

    Informations forums :
    Inscription : Novembre 2006
    Messages : 105
    Par défaut
    Rectification, après plusieurs essaies... La solution de Vincent ne fonctionne pas non plus...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Internet Explorer ne charge pas le fichier JS
    Par mr32 dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 05/02/2006, 12h46
  2. [winXP][plantage] ftlmgr.sys ne charge pas, qui la ?.
    Par arnolem dans le forum Windows XP
    Réponses: 10
    Dernier message: 10/06/2005, 17h35
  3. Réponses: 2
    Dernier message: 21/04/2005, 17h09
  4. Ma fenêtre OpenGL ne veut pas rester ouverte
    Par Mynautor dans le forum OpenGL
    Réponses: 3
    Dernier message: 03/02/2005, 13h25

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