Example #1
0
    def OnGridChangeEvent(self, evt):
        pg = self.property_grid_1
        prop = evt.GetProperty()
        if prop.GetName() == 'Overlay Plot':
            self.get_static_overlay_data()
            choices = list(self.overlay.keys())
            pg.GetProperty('X Axis Variable').SetChoices(
                wxpg.PGChoices(['Select option'] + choices))
            pg.GetProperty('Y Axis Variable').SetChoices(
                wxpg.PGChoices(['Select option'] + choices))

        elif prop.GetName(
        ) == 'X Axis Variable' or 'Y Axis Variable' and self.flag_complete:
            self.update_yAxisData()
Example #2
0
 def MAJ_modeles(self):
     categorie = "attestation"
     DB = GestionDB.DB()
     req = """SELECT IDmodele, nom, largeur, hauteur, observations, defaut 
     FROM documents_modeles
     WHERE categorie='%s'
     ORDER BY nom;""" % categorie
     DB.ExecuterReq(req)
     listeDonnees = DB.ResultatReq()
     DB.Close()
     propriete = self.GetPropertyByName("IDmodele")
     self.dictDonnees["modeles"] = {}
     choix = wxpg.PGChoices()
     selectionDefaut = None
     for IDmodele, nom, largeur, hauteur, observations, defaut in listeDonnees:
         self.dictDonnees["modeles"][IDmodele] = {
             "nom": nom,
             "largeur": largeur,
             "hauteur": hauteur,
             "observations": observations,
             "defaut": defaut
         }
         choix.Add(nom, IDmodele)
         if defaut != None:
             selectionDefaut = IDmodele
     propriete.SetChoices(choix)
     self.RefreshProperty(propriete)
     if selectionDefaut != None:
         propriete.SetValue(selectionDefaut)
Example #3
0
 def MAJ_titulaire_helios(self):
     propriete = self.GetPropertyByName("titulaire_helios")
     ancienneValeur = propriete.GetValue()
     DB = GestionDB.DB()
     req = """SELECT individus.IDindividu, nom, prenom
     FROM rattachements
     LEFT JOIN individus ON individus.IDindividu = rattachements.IDindividu
     WHERE IDfamille=%d AND IDcategorie=1
     GROUP BY individus.IDindividu
     ORDER BY nom, prenom;""" % self.IDfamille
     DB.ExecuterReq(req)
     listeDonnees = DB.ResultatReq()
     DB.Close()
     choix = wxpg.PGChoices()
     ancienChoixValide = False
     for IDindividu, nom, prenom in listeDonnees:
         if prenom == None: prenom = ""
         nomIndividu = u"%s %s" % (nom, prenom)
         if IDindividu == ancienneValeur:
             ancienChoixValide = True
         choix.Add(nomIndividu, IDindividu)
     propriete.SetChoices(choix)
     self.RefreshProperty(propriete)
     if ancienChoixValide == False:
         ancienneValeur = None
     try:
         propriete.SetValue(ancienneValeur)
     except:
         pass
Example #4
0
 def MAJ_modes(self):
     DB = GestionDB.DB()
     req = """SELECT IDmode, label, numero_piece, nbre_chiffres, 
     frais_gestion, frais_montant, frais_pourcentage, frais_arrondi, frais_label, image
     FROM modes_reglements
     ORDER BY label;"""
     DB.ExecuterReq(req)
     listeDonnees = DB.ResultatReq()
     DB.Close()
     self.dictModes = {}
     choix = wxpg.PGChoices()
     for IDmode, label, numero_piece, nbre_chiffres, frais_gestion, frais_montant, frais_pourcentage, frais_arrondi, frais_label, image in listeDonnees:
         self.dictModes[IDmode] = {
             "label": label,
             "numero_piece": numero_piece,
             "nbre_chiffres": nbre_chiffres,
             "frais_gestion": frais_gestion,
             "frais_montant": frais_montant,
             "frais_pourcentage": frais_pourcentage,
             "frais_arrondi": frais_arrondi,
             "frais_label": frais_label,
             "image": image,
         }
         bmp = OL_Modes_reglements.GetImage(image)
         if 'phoenix' in wx.PlatformInfo:
             choix.Add(label=label, bitmap=bmp, value=IDmode)
         else:
             choix.Add(label, bmp, IDmode)
     propriete = self.GetPropertyByName("IDmode")
     propriete.SetChoices(choix)
     self.RefreshProperty(propriete)
Example #5
0
 def MAJ_comptes(self):
     DB = GestionDB.DB()
     req = """SELECT IDcompte, nom, numero, defaut, raison, code_etab, code_guichet, code_nne, cle_rib, cle_iban, iban, bic, code_ics
     FROM comptes_bancaires
     ORDER BY nom;"""
     DB.ExecuterReq(req)
     listeDonnees = DB.ResultatReq()
     DB.Close()
     self.dictComptes = {}
     choix = wxpg.PGChoices()
     for IDcompte, nom, numero, defaut, raison, code_etab, code_guichet, code_nne, cle_rib, cle_iban, iban, bic, code_ics in listeDonnees:
         self.dictComptes[IDcompte] = {
             "nom": nom,
             "numero": numero,
             "defaut": defaut,
             "raison": raison,
             "code_etab": code_etab,
             "code_guichet": code_guichet,
             "code_nne": code_nne,
             "cle_rib": cle_rib,
             "cle_iban": cle_iban,
             "iban": iban,
             "bic": bic,
             "code_ics": code_ics,
         }
         if 'phoenix' in wx.PlatformInfo:
             choix.Add(label=nom, value=IDcompte)
         else:
             choix.Add(nom, IDcompte)
     propriete = self.GetPropertyByName("IDcompte")
     propriete.SetChoices(choix)
     self.RefreshProperty(propriete)
    def MAJ_signataires(self):
        ancienneValeur = None
        propriete = self.GetPropertyByName("signataire")
        index = propriete.GetValue()
        if index != None and index in self.dictDonnees["signataires"]:
            ancienneValeur = self.dictDonnees["signataires"][index]["ID"]

        if len(self.listeActivites) == 0: conditionActivites = "()"
        elif len(self.listeActivites) == 1:
            conditionActivites = "(%d)" % self.listeActivites[0]
        else:
            conditionActivites = str(tuple(self.listeActivites))
        DB = GestionDB.DB()
        req = """SELECT IDresponsable, IDactivite, nom, fonction, defaut, sexe
        FROM responsables_activite
        WHERE IDactivite IN %s
        ORDER BY nom;""" % conditionActivites
        DB.ExecuterReq(req)
        listeDonnees = DB.ResultatReq()
        DB.Close()
        self.dictDonnees["signataires"] = {}
        choix = wxpg.PGChoices()
        selectionDefaut = None
        index = 0
        for IDresponsable, IDactivite, nom, fonction, defaut, sexe in listeDonnees:
            self.dictDonnees["signataires"][index] = {
                "ID": IDresponsable,
                "IDactivite": IDactivite,
                "nom": nom,
                "fonction": fonction,
                "defaut": defaut,
                "sexe": sexe
            }
            if 'phoenix' in wx.PlatformInfo:
                choix.Add(label=nom, value=index)
            else:
                choix.Add(nom, index)
            if defaut == 1:
                selectionDefaut = index
            index += 1
        propriete.SetChoices(choix)
        self.RefreshProperty(propriete)
        if selectionDefaut != None:
            propriete.SetValue(selectionDefaut)
        # Recherche le nom de l'utilisateur parmi la liste des signataires
        dictUtilisateur = UTILS_Identification.GetDictUtilisateur()
        for index, dictDonnees in self.dictDonnees["signataires"].items():
            if ancienneValeur == dictDonnees["ID"]:
                propriete.SetValue(index)
                break
            if dictUtilisateur != None:
                texte1 = u"%s %s" % (dictUtilisateur["prenom"],
                                     dictUtilisateur["nom"])
                texte2 = u"%s %s" % (dictUtilisateur["nom"],
                                     dictUtilisateur["prenom"])
                if dictDonnees["nom"].lower() == texte1.lower(
                ) or dictDonnees["nom"].lower() == texte2.lower():
                    propriete.SetValue(index)
 def __init__(self, label, name=NAME, liste_choix=[], valeur=None):
     self.liste_choix = liste_choix
     Property.__init__(self, label, name)
     if 'phoenix' in wx.PlatformInfo:
         choix = wxpg.PGChoices([x[1] for x in self.liste_choix])
     else:
         choix = [x[1] for x in self.liste_choix]
     self.SetChoices(choix)
     if valeur != None:
         self.SetValue(valeur)
Example #8
0
 def Etape2(self):
     idx = self.colonne
     choixactions = self.GetChoixActions(idx)
     #recomposition des choix d'action
     labels = []
     for (code, label) in choixactions:
         labels.append(label)
     values = list(range(0, len(labels)))
     choix = wxpg.PGChoices(labels, values=values)
     self.ctrl.dicProperties['action'].SetChoices(choix)
     self.Layout()
Example #9
0
    def draw_2dplot(self):
        pg = self.property_grid_1
        if self.table:
            choices = list(self.table.keys())
            pg.GetProperty('X Data').SetChoices(wxpg.PGChoices(choices))
            pg.GetProperty('Y Data').SetChoices(wxpg.PGChoices(choices))
            pg.GetProperty('Data Labels').SetChoices(
                wxpg.PGChoices([""] + choices))
            pg.SetPropertyValue('X Data', choices[0])
            pg.SetPropertyValue('Y Data', [choices[1]])

            self.x, self.y = self.table[choices[0]], [self.table[choices[1]]]
        else:
            self.x, self.y = [0.], [[0.]]

        self.ax = self.figure.add_subplot(111)
        self._plot_helper()

        self.update_axis_labels()
        self.figure.tight_layout()
        self.toolbar.update()  # Not sure why this is needed - ADS
Example #10
0
    def set_solver(self, solver):
        """Sets current solver and builds UI basing on its properties.

        :param Solver solver: Solver to show properties of.
        """

        # Set the solver
        self.solver = solver

        # Reset the properties
        self.reset()

        # Skip if there is no solver or solver has no properties
        if not self.solver or not self.solver.properties:
            return

        # For each property
        for i, p in enumerate(self.solver.properties):
            # Create property object with appropriate type
            if p.type is int:
                prop = wxpg.IntProperty()
            elif p.type is float:
                prop = wxpg.FloatProperty()
            elif issubclass(p.type, Enum):
                prop = wxpg.EnumProperty()
                labels = list(map(lambda c: c.name, p.type))
                values = list(map(lambda c: c.value, p.type))
                prop_choices = wxpg.PGChoices(labels=labels, values=values)
                prop.SetChoices(prop_choices)

            # Set label and value
            prop.SetLabel(p.name)
            prop.SetValue(p.default)
            prop.SetDefaultValue(p.default)
            prop.SetAttribute('property_idx', i)

            # And append the property object
            self.Append(prop)

        # Fit columns and layout the parent
        self.FitColumns()
        self.GetParent().Layout()
Example #11
0
    def fill_property_grid(self):
        print('Filling property grid')
        pair = self.wxprop_layerconf_pair
        pg = self.property_grid_1
        lc = self.layer_config
        pg.Append(wxpg.PropertyCategory("1 - Basic Properties"))
        if len(lc.keys()):
            for p in lc.keys():
                # print('    property <<%s>>'%p)
                proper = lc[p]   # Конфигурационный объект потомок CommonProp
                value = lc[p]()
                curprop = None
                # p - parametr name
                # value - default value of parametr
                if isinstance(proper, layers_opt.BoolProp):  # дискретный параметр
                    curprop = pg.Append(wxpg.BoolProperty(p, value=value))  # объект wx

                elif isinstance(proper, layers_opt.RealRangeProp):  # вещественный параметр
                    curprop = pg.Append(wxpg.FloatProperty(p, value=value))

                elif isinstance(proper, layers_opt.IntRangeProp):  # целочисленый параметр
                    curprop = pg.Append(wxpg.IntProperty(p, value=value))

                elif isinstance(proper, layers_opt.SelectOneProp): # выбор один из многих
                    choices = wxpg.PGChoices()
                    for choice in proper:
                        choices.Add(label=choice, value=wxpg.PG_INVALID_VALUE)
                    default_coice = choices.GetIndicesForStrings([value,])[0]
                    # print(default_coice)
                    curprop = pg.Append(wxpg.EnumProperty(label=p, name=p, choices=choices))
                    curprop.SetChoiceSelection(default_coice)

                if curprop is not None:
                    curprop.SetHelpString(proper.__doc__)
                    pair[curprop] = proper  # свойство wx, свойство CommonProp
        else: # no properties
            print(' No properties')
            empty_prop = pg.Append(wxpg.StringProperty(label='No editable property', value='May be for a while'))
            empty_prop.SetHelpString('Nothing to tweek here')
            pg.Enable(False)
        print('End of filling property grid')
Example #12
0
    def InitMatrice(self, matrice):
        # Compose la grille de saisie des paramètres selon le dictionnaire matrice
        self.matrice = matrice
        self.dicProperties = {}
        chapitre = self.matrice['nomchapitre']
        if isinstance(chapitre, str):
            self.Append(wxpg.PropertyCategory(chapitre))
        for ligne in self.matrice['lignes']:
            if 'name' in ligne and 'genre' in ligne:
                if not 'label' in ligne: ligne['name'] = None
                if not 'value' in ligne: ligne['value'] = None
                genre, name, label, value = (ligne['genre'], ligne['name'],
                                             ligne['label'], ligne['value'])
                genre = genre.lower()
                if not 'labels' in ligne: ligne['labels'] = []
                """
                if 'values' in ligne and ligne['values']:
                    if ligne['labels']:
                        if len(ligne['values']) > 0 and len(ligne['labels']) == 0:
                            ligne['labels'] = ligne['values']
                    else: ligne['labels'] = ligne['values']
                """
                commande = ''
                try:
                    commande = genre
                    if genre in ['enum', 'combo']:
                        values = list(range(0, len(ligne['labels'])))
                        if not isinstance(value, int): value = 0
                        choix = wxpg.PGChoices(ligne['labels'], values=values)
                        propriete = wxpg.EnumProperty(label=label,
                                                      name=name,
                                                      choices=choix,
                                                      value=value)

                    elif genre == 'multichoice':
                        propriete = wxpg.MultiChoiceProperty(
                            label, name, choices=ligne['labels'], value=value)

                    elif genre in ['bool', 'check']:
                        wxpg.PG_BOOL_USE_CHECKBOX = 1
                        propriete = wxpg.BoolProperty(label=label,
                                                      name=name,
                                                      value=value)
                        propriete.PG_BOOL_USE_CHECKBOX = 1

                    elif genre in ['date', 'datetime', 'time']:
                        wxpg.PG_BOOL_USE_CHECKBOX = 1
                        propriete = wxpg.DateProperty(label=label,
                                                      name=name,
                                                      value=value)
                        propriete.SetFormat('%d/%m/%Y')
                        propriete.PG_BOOL_USE_CHECKBOX = 1

                    else:
                        commande = "wxpg."  + genre.upper()[:1] + genre.lower()[1:] \
                                            + "Property(label= label, name=name, value=value)"
                        propriete = eval(commande)
                    if 'help' in ligne:
                        propriete.SetHelpString(ligne['help'])
                    self.Append(propriete)
                    self.dicProperties[propriete] = name
                    self.dicProperties[name] = propriete
                except Exception as err:
                    wx.MessageBox(
                        "Echec sur Property de name - value: %s - %s (%s)\nLe retour d'erreur est : \n%s\n\nSur commande : %s"
                        % (name, value, type(value), err, commande),
                        'CTRL_property.InitMatrice() : Paramètre ligne indigeste !',
                        wx.OK | wx.ICON_STOP)