Esempio n. 1
0
    def __init__(self, parent, categorie=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        if categorie == None:
            categorie = Categorie()

        self.categorie = categorie

        self.label_IDCategorie = wx.StaticText(self, -1, u"ID Cat�gorie :")
        self.combo_box_IDCategorie = wx.ComboBox(self,
                                                 -1,
                                                 choices=[],
                                                 style=wx.CB_DROPDOWN
                                                 | wx.CB_READONLY)
        self.label_IDCategorieV = wx.StaticText(self, -1, "IDCategorieV")
        self.label_NomCategorie = wx.StaticText(self, -1, "Nom :")
        self.text_NomCategorie = wx.TextCtrl(self,
                                             -1,
                                             "",
                                             style=wx.TE_PROCESS_ENTER,
                                             validator=GenericTextValidator())
        self.button_ok = wx.Button(self, wx.ID_OK, "Ok")
        self.button_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler")

        self.button_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnEnregistre, self.text_NomCategorie)

        self.Bind(wx.EVT_CLOSE, self.OnClose, self)
        self.Bind(wx.EVT_BUTTON, self.OnClose, self.button_annuler)

        self.__set_properties()
        self.__set_valeurs()
        self.__do_layout()
    def __set_comboboxs(self):
        #TODO: Faire système de verification en cas de non existance de fournisseur/categorie/tva
        try:
            categories = [c for c in Categorie.select().order_by(Categorie.nom.asc())]
            for c in categories:
                self.combo_box_Categorie.Append(str(c.get_id()).zfill(2) + " - " + c.nom, c)

            fournisseurs = [f for f in Fournisseur.select().order_by(Fournisseur.nom.asc())]
            for fournisseur in fournisseurs:
                self.combo_box_Fournisseur.Append(fournisseur.nom, fournisseur)

            tvas = [t for t in Tva.select().order_by(Tva.taux.asc())]
            for tva in tvas:
                self.combo_box_TVA.Append(str(tva.taux), tva)

        except BaseException as ex:
            print ex
    def __set_valeurs(self):
        if self.categorie.get_id() != None:
            self.combo_box_IDCategorie.Hide()
            self.label_IDCategorieV.SetLabel(str(self.categorie.get_id()))
            self.text_NomCategorie.SetValue(self.categorie.nom)
        else:
            self.label_IDCategorieV.Hide()

            liste_ids = [str(n + 1).zfill(2) for n in range(99)]
            liste_ids_occupees = [str(x).zfill(2) for x in
                                  [cat.get_id() for cat in Categorie.select()]]

            liste_ids_libres = set(liste_ids) - set(liste_ids_occupees)

            self.combo_box_IDCategorie.SetItems(sorted(liste_ids_libres))

            self.combo_box_IDCategorie.Select(0)
Esempio n. 4
0
    def __set_valeurs(self):
        if self.categorie.get_id() != None:
            self.combo_box_IDCategorie.Hide()
            self.label_IDCategorieV.SetLabel(str(self.categorie.get_id()))
            self.text_NomCategorie.SetValue(self.categorie.nom)
        else:
            self.label_IDCategorieV.Hide()

            liste_ids = [str(n + 1).zfill(2) for n in range(99)]
            liste_ids_occupees = [
                str(x).zfill(2)
                for x in [cat.get_id() for cat in Categorie.select()]
            ]

            liste_ids_libres = set(liste_ids) - set(liste_ids_occupees)

            self.combo_box_IDCategorie.SetItems(sorted(liste_ids_libres))

            self.combo_box_IDCategorie.Select(0)
Esempio n. 5
0
    def __set_comboboxs(self):
        #TODO: Faire système de verification en cas de non existance de fournisseur/categorie/tva
        try:
            categories = [
                c for c in Categorie.select().order_by(Categorie.nom.asc())
            ]
            for c in categories:
                self.combo_box_Categorie.Append(
                    str(c.get_id()).zfill(2) + " - " + c.nom, c)

            fournisseurs = [
                f for f in Fournisseur.select().order_by(Fournisseur.nom.asc())
            ]
            for fournisseur in fournisseurs:
                self.combo_box_Fournisseur.Append(fournisseur.nom, fournisseur)

            tvas = [t for t in Tva.select().order_by(Tva.taux.asc())]
            for tva in tvas:
                self.combo_box_TVA.Append(str(tva.taux), tva)

        except BaseException as ex:
            print ex
 def __remplissage_liste(self):
     try:
         self.liste_categories.SetObjects([c for c in Categorie.select()])
     except BaseException as ex:
         print ex
Esempio n. 7
0
 def __remplissage_liste(self):
     try:
         self.liste_categories.SetObjects([c for c in Categorie.select()])
     except BaseException as ex:
         print ex