Exemplo n.º 1
0
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.parent = parent
        self.dictDonnees = {}

        # Titre
        self.staticbox_generalites_staticbox = wx.StaticBox(self, -1, _(u"Caractéristiques"))
        self.label_titre = wx.StaticText(self, -1, _(u"Titre :"))
        self.ctrl_titre = wx.TextCtrl(self, -1, "")

        # Dates
        self.label_date_debut = wx.StaticText(self, -1, _(u"Du :"))
        self.ctrl_date_debut = CTRL_Saisie_date.Date2(self, heure=True)
        self.ctrl_date_debut.SetDate(datetime.datetime.now())
        self.label_date_fin = wx.StaticText(self, -1, _(u"au"))
        self.ctrl_date_fin = CTRL_Saisie_date.Date2(self, heure=True)

        # Description
        self.label_description = wx.StaticText(self, -1, _(u"Description :"))
        self.ctrl_description = wx.TextCtrl(self, -1, "")

        # Couleur
        self.label_couleur = wx.StaticText(self, -1, _(u"Couleur :"))
        self.ctrl_couleur = CTRL_Couleur(self)

        # Commandes
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png")
        self.bouton_annuler = CTRL_Bouton_image.CTRL(self, id=wx.ID_CANCEL, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)
Exemplo n.º 2
0
    def __init__(self, parent, IDbloc=None):
        wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)
        self.parent = parent
        self.IDbloc = IDbloc
        self.IDpage_initial = None
        self.listeIDelementsImportes = []

        # Généralités
        self.staticbox_generalites_staticbox = wx.StaticBox(self, -1, _(u"Généralités"))

        self.label_titre = wx.StaticText(self, -1, _(u"Titre :"))
        self.ctrl_titre = wx.TextCtrl(self, -1, "")

        self.label_page = wx.StaticText(self, -1, _(u"Page :"))
        self.ctrl_page = CTRL_Page(self)

        self.label_couleur = wx.StaticText(self, -1, _(u"Couleur :"))
        self.ctrl_couleur = CTRL_Couleur(self)

        # Paramètres
        self.staticbox_options_staticbox = wx.StaticBox(self, -1, _(u"Paramètres"))
        self.ctrl_parametres = CTRL_Parametres(self)
        self.ctrl_parametres.SetMinSize((550, 350))

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png")
        self.bouton_annuler = CTRL_Bouton_image.CTRL(self, id=wx.ID_CANCEL, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()
        
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)

        # Init
        if self.IDbloc == None :
            self.SetTitle(_(u"Saisie d'un bloc"))
        else :
            self.SetTitle(_(u"Modification d'un bloc"))
            self.Importation()
        self.ctrl_titre.SetFocus()
Exemplo n.º 3
0
class Dialog(wx.Dialog):
    def __init__(self, parent, IDbloc=None):
        wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)
        self.parent = parent
        self.IDbloc = IDbloc
        self.IDpage_initial = None
        self.listeIDelementsImportes = []

        # Généralités
        self.staticbox_generalites_staticbox = wx.StaticBox(self, -1, _(u"Généralités"))

        self.label_titre = wx.StaticText(self, -1, _(u"Titre :"))
        self.ctrl_titre = wx.TextCtrl(self, -1, "")

        self.label_page = wx.StaticText(self, -1, _(u"Page :"))
        self.ctrl_page = CTRL_Page(self)

        self.label_couleur = wx.StaticText(self, -1, _(u"Couleur :"))
        self.ctrl_couleur = CTRL_Couleur(self)

        # Paramètres
        self.staticbox_options_staticbox = wx.StaticBox(self, -1, _(u"Paramètres"))
        self.ctrl_parametres = CTRL_Parametres(self)
        self.ctrl_parametres.SetMinSize((550, 350))

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png")
        self.bouton_annuler = CTRL_Bouton_image.CTRL(self, id=wx.ID_CANCEL, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()
        
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)

        # Init
        if self.IDbloc == None :
            self.SetTitle(_(u"Saisie d'un bloc"))
        else :
            self.SetTitle(_(u"Modification d'un bloc"))
            self.Importation()
        self.ctrl_titre.SetFocus()

    def __set_properties(self):
        self.ctrl_titre.SetToolTip(wx.ToolTip(_(u"Saisissez ici le titre du bloc")))
        self.ctrl_page.SetToolTip(wx.ToolTip(_(u"Sélectionnez ici la page dans laquelle vous souhaitez insérer ce bloc")))
        self.ctrl_couleur.SetToolTip(wx.ToolTip(_(u"Sélectionnez ici la couleur du bloc")))
        self.bouton_aide.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour obtenir de l'aide")))
        self.bouton_ok.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour valider et fermer")))
        self.bouton_annuler.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour annuler et fermer")))

    def __do_layout(self):
        grid_sizer_base = wx.FlexGridSizer(rows=3, cols=1, vgap=10, hgap=10)

        # Généralités
        staticbox_generalites = wx.StaticBoxSizer(self.staticbox_generalites_staticbox, wx.VERTICAL)

        grid_sizer_generalites = wx.FlexGridSizer(rows=2, cols=2, vgap=10, hgap=10)
        grid_sizer_generalites.Add(self.label_titre, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_generalites.Add(self.ctrl_titre, 0, wx.EXPAND, 0)
        grid_sizer_generalites.Add(self.label_page, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)

        grid_sizer_page = wx.FlexGridSizer(rows=1, cols=4, vgap=10, hgap=10)
        grid_sizer_page.Add(self.ctrl_page, 0, wx.EXPAND, 0)
        grid_sizer_page.Add( (5, 5), 0, 0, 0)
        grid_sizer_page.Add(self.label_couleur, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_page.Add(self.ctrl_couleur, 0, 0, 0)
        grid_sizer_page.AddGrowableCol(0)
        grid_sizer_generalites.Add(grid_sizer_page, 0, wx.EXPAND, 0)

        grid_sizer_generalites.AddGrowableCol(1)
        staticbox_generalites.Add(grid_sizer_generalites, 1, wx.ALL|wx.EXPAND, 10)

        grid_sizer_base.Add(staticbox_generalites, 1, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 10)

        # Paramètres
        staticbox_parametres = wx.StaticBoxSizer(self.staticbox_options_staticbox, wx.VERTICAL)
        staticbox_parametres.Add(self.ctrl_parametres, 1, wx.ALL|wx.EXPAND, 10)

        grid_sizer_base.Add(staticbox_parametres, 1, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)

        # Boutons
        grid_sizer_boutons = wx.FlexGridSizer(rows=1, cols=4, vgap=10, hgap=10)
        grid_sizer_boutons.Add(self.bouton_aide, 0, 0, 0)
        grid_sizer_boutons.Add((20, 20), 0, wx.EXPAND, 0)
        grid_sizer_boutons.Add(self.bouton_ok, 0, 0, 0)
        grid_sizer_boutons.Add(self.bouton_annuler, 0, 0, 0)
        grid_sizer_boutons.AddGrowableCol(1)
        grid_sizer_base.Add(grid_sizer_boutons, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 10)

        self.SetSizer(grid_sizer_base)
        grid_sizer_base.AddGrowableRow(1)
        grid_sizer_base.AddGrowableCol(0)
        grid_sizer_base.Fit(self)
        self.Layout()
        self.SetMinSize(self.GetSize())
        self.CenterOnScreen()

    def OnBoutonAide(self, event):
        from Utils import UTILS_Aide
        UTILS_Aide.Aide("Connecthys")

    def Importation(self):
        """ Importation des données """
        dictParametres = {}

        DB = GestionDB.DB()

        # Bloc
        req = """SELECT IDpage, titre, couleur, categorie, ordre, parametres
        FROM portail_blocs WHERE IDbloc=%d;""" % self.IDbloc
        DB.ExecuterReq(req)
        listeDonnees = DB.ResultatReq()
        if len(listeDonnees) > 0:
            IDpage, titre, couleur, categorie, ordre, parametres = listeDonnees[0]
            self.ctrl_titre.SetValue(titre)
            self.ctrl_couleur.SetID(couleur)
            self.ctrl_page.SetID(IDpage)
            self.IDpage_initial = IDpage
            dictParametres["categorie"] = categorie
            dictParametres["parametres"] = parametres

        # Eléments
        req = """SELECT IDelement, ordre, titre, categorie, date_debut, date_fin, parametres, texte_xml, texte_html
        FROM portail_elements
        WHERE IDbloc=%d
        ORDER BY ordre;""" % self.IDbloc
        DB.ExecuterReq(req)
        listeDonnees = DB.ResultatReq()
        listeElements = []
        if len(listeDonnees) > 0:
            for IDelement, ordre, titre, categorie, date_debut, date_fin, parametres, texte_xml, texte_html in listeDonnees :
                dictElement = {"IDelement": IDelement, "ordre": ordre, "titre": titre, "categorie" : categorie, "date_debut": date_debut, "date_fin": date_fin, "parametres": parametres, "texte_xml": texte_xml, "texte_html" : texte_html}
                listeElements.append(dictElement)
                self.listeIDelementsImportes.append(IDelement)
        dictParametres["elements"] = listeElements

        # Envoie des paramètres
        self.ctrl_parametres.SetParametres(dictParametres)
        DB.Close()

    def GetParametre(self, dictTemp={}, code=""):
        if code in dictTemp:
            return dictTemp[code]
        else:
            return None

    def OnBoutonOk(self, event):
        titre = self.ctrl_titre.GetValue()
        if titre == "" :
            dlg = wx.MessageDialog(self, _(u"Vous devez obligatoirement saisir un titre pour ce bloc !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            self.ctrl_titre.SetFocus()
            return False

        # Validation des paramètres
        if self.ctrl_parametres.Validation() == False :
            return False

        # Récupération des données
        IDpage = self.ctrl_page.GetID()
        couleur = self.ctrl_couleur.GetID()
        dictParametres = self.ctrl_parametres.GetParametres()

        # Sauvegarde
        DB = GestionDB.DB()

        # Sauvegarde du modèle
        listeDonnees = [
            ("IDpage", IDpage),
            ("titre", titre),
            ("couleur", couleur),
            ("categorie", dictParametres["categorie"]),
            ]

        # Recherche l'ordre du bloc
        if self.IDpage_initial == None or self.IDpage_initial != IDpage :
            req = """SELECT MAX(ordre) FROM portail_blocs WHERE IDpage=%d;""" % IDpage
            DB.ExecuterReq(req)
            listeTemp = DB.ResultatReq()
            if len(listeTemp) == 0 or listeTemp[0][0] == None :
                ordre = 1
            else :
                ordre = listeTemp[0][0] + 1
            listeDonnees.append(("ordre", ordre))

        if self.IDbloc == None :
            self.IDbloc = DB.ReqInsert("portail_blocs", listeDonnees)
        else:
            DB.ReqMAJ("portail_blocs", listeDonnees, "IDbloc", self.IDbloc)

        # Sauvegarde des éléments
        index = 1
        listeIDelement = []
        for dictElement in dictParametres["elements"] :
            IDelement = dictElement["IDelement"]
            listeDonnees = [
                ("IDbloc", self.IDbloc),
                ("ordre", index),
                ("titre", self.GetParametre(dictElement, "titre")),
                ("categorie", dictParametres["categorie"]),
                ("date_debut", self.GetParametre(dictElement, "date_debut")),
                ("date_fin", self.GetParametre(dictElement, "date_fin")),
                ("parametres", self.GetParametre(dictElement, "parametres")),
                ("texte_xml", self.GetParametre(dictElement, "texte_xml")),
                ("texte_html", self.GetParametre(dictElement, "texte_html")),
                ]
            if IDelement == None or IDelement < 0 :
                newIDelement = DB.ReqInsert("portail_elements", listeDonnees)
                dictElement["IDelement"] = newIDelement
            else:
                DB.ReqMAJ("portail_elements", listeDonnees, "IDelement", IDelement)
                listeIDelement.append(IDelement)
            index += 1

        # Suppression des colonnes obsolètes
        for IDelement in self.listeIDelementsImportes :
            if IDelement not in listeIDelement :
                DB.ReqDEL("portail_elements", "IDelement", IDelement)

        # Clôture de la base
        DB.Close()

        # Fermeture de la fenêtre
        self.EndModal(wx.ID_OK)

    def GetID(self):
        return self.IDbloc
Exemplo n.º 4
0
class DLG_Saisie_element(wx.Dialog):
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.parent = parent
        self.dictDonnees = {}

        # Titre
        self.staticbox_generalites_staticbox = wx.StaticBox(self, -1, _(u"Caractéristiques"))
        self.label_titre = wx.StaticText(self, -1, _(u"Titre :"))
        self.ctrl_titre = wx.TextCtrl(self, -1, "")

        # Dates
        self.label_date_debut = wx.StaticText(self, -1, _(u"Du :"))
        self.ctrl_date_debut = CTRL_Saisie_date.Date2(self, heure=True)
        self.ctrl_date_debut.SetDate(datetime.datetime.now())
        self.label_date_fin = wx.StaticText(self, -1, _(u"au"))
        self.ctrl_date_fin = CTRL_Saisie_date.Date2(self, heure=True)

        # Description
        self.label_description = wx.StaticText(self, -1, _(u"Description :"))
        self.ctrl_description = wx.TextCtrl(self, -1, "")

        # Couleur
        self.label_couleur = wx.StaticText(self, -1, _(u"Couleur :"))
        self.ctrl_couleur = CTRL_Couleur(self)

        # Commandes
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png")
        self.bouton_annuler = CTRL_Bouton_image.CTRL(self, id=wx.ID_CANCEL, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)

    def __set_properties(self):
        self.SetTitle(_(u"Saisie d'un évènement"))
        self.ctrl_titre.SetToolTip(wx.ToolTip(_(u"Saisissez ici le titre de l'évènement")))
        self.ctrl_description.SetToolTip(wx.ToolTip(_(u"[Optionnel] Ajoutez une description pour cet évènement")))
        self.ctrl_couleur.SetToolTip(wx.ToolTip(_(u"Sélectionnez une couleur pour cet évènement")))
        self.bouton_aide.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour obtenir de l'aide")))
        self.bouton_ok.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour valider")))
        self.bouton_annuler.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour annuler")))

    def __do_layout(self):
        grid_sizer_base = wx.FlexGridSizer(rows=4, cols=1, vgap=0, hgap=10)

        # Généralités
        staticbox_generalites = wx.StaticBoxSizer(self.staticbox_generalites_staticbox, wx.VERTICAL)
        grid_sizer_generalites = wx.FlexGridSizer(rows=5, cols=2, vgap=10, hgap=10)
        grid_sizer_generalites.Add(self.label_titre, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_generalites.Add(self.ctrl_titre, 0, wx.EXPAND, 0)
        grid_sizer_generalites.Add(self.label_date_debut, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)

        grid_sizer_dates = wx.FlexGridSizer(rows=1, cols=3, vgap=10, hgap=10)
        grid_sizer_dates.Add(self.ctrl_date_debut, 0, wx.EXPAND, 0)
        grid_sizer_dates.Add(self.label_date_fin, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_dates.Add(self.ctrl_date_fin, 0, wx.EXPAND, 0)
        grid_sizer_generalites.Add(grid_sizer_dates, 0, wx.EXPAND, 0)

        grid_sizer_generalites.Add(self.label_description, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_generalites.Add(self.ctrl_description, 0, wx.EXPAND, 0)

        grid_sizer_generalites.Add(self.label_couleur, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_generalites.Add(self.ctrl_couleur, 0, wx.EXPAND, 0)

        grid_sizer_generalites.AddGrowableCol(1)
        staticbox_generalites.Add(grid_sizer_generalites, 1, wx.ALL|wx.EXPAND, 5)
        grid_sizer_base.Add(staticbox_generalites, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10)

        # Boutons
        grid_sizer_boutons = wx.FlexGridSizer(rows=1, cols=4, vgap=10, hgap=10)
        grid_sizer_boutons.Add(self.bouton_aide, 0, 0, 0)
        grid_sizer_boutons.Add((20, 20), 0, wx.EXPAND, 0)
        grid_sizer_boutons.Add(self.bouton_ok, 0, 0, 0)
        grid_sizer_boutons.Add(self.bouton_annuler, 0, 0, 0)
        grid_sizer_boutons.AddGrowableCol(1)
        grid_sizer_base.Add(grid_sizer_boutons, 1, wx.ALL | wx.EXPAND, 10)

        self.SetSizer(grid_sizer_base)
        grid_sizer_base.Fit(self)
        grid_sizer_base.AddGrowableRow(0)
        grid_sizer_base.AddGrowableCol(0)
        self.Layout()
        self.SetMinSize(self.GetSize())
        self.CenterOnScreen()

    def OnBoutonAide(self, event):
        from Utils import UTILS_Aide
        UTILS_Aide.Aide("")

    def OnBoutonOk(self, event):
        # Validation
        if len(self.ctrl_titre.GetValue()) == 0:
            dlg = wx.MessageDialog(self, _(u"Vous devez obligatoirement saisir un titre pour cet évènement !"), "Erreur de saisie", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            self.ctrl_titre.SetFocus()
            return

        if self.ctrl_date_debut.Validation() == False or self.ctrl_date_debut.GetDate() == None :
            dlg = wx.MessageDialog(self, _(u"Vous devez obligatoirement saisir une date de début valide pour cet évènement !"), "Erreur de saisie", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            self.ctrl_date_debut.SetFocus()
            return

        if self.ctrl_date_fin.Validation() == False or self.ctrl_date_fin.GetDate() == None :
            dlg = wx.MessageDialog(self, _(u"Vous devez obligatoirement saisir une date de fin valide pour cet évènement !"), "Erreur de saisie", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            self.ctrl_date_fin.SetFocus()
            return

        # Fermeture fenêtre
        self.EndModal(wx.ID_OK)

    def GetDonnees(self):
        self.dictDonnees["titre"] = self.ctrl_titre.GetValue()
        self.dictDonnees["date_debut"] = self.ctrl_date_debut.GetDate()
        self.dictDonnees["date_fin"] = self.ctrl_date_fin.GetDate()
        self.dictDonnees["parametres"] = u"description:::%s###couleur:::%s" % (self.ctrl_description.GetValue(), self.ctrl_couleur.GetCouleur())
        return self.dictDonnees

    def SetDonnees(self, dictDonnees={}):
        self.dictDonnees = dictDonnees
        self.SetTitle(_(u"Modification d'un article"))
        if self.dictDonnees.has_key("titre") :
            self.ctrl_titre.SetValue(self.dictDonnees["titre"])
        if self.dictDonnees.has_key("date_debut") :
            self.ctrl_date_debut.SetDate(self.dictDonnees["date_debut"])
        if self.dictDonnees.has_key("date_fin") :
            self.ctrl_date_fin.SetDate(self.dictDonnees["date_fin"])
        if self.dictDonnees.has_key("parametres") :
            listeParametres = self.dictDonnees["parametres"].split("###")
            for parametre in listeParametres :
                nom, valeur = parametre.split(":::")
                if nom == "description" :
                    self.ctrl_description.SetValue(valeur)
                if nom == "couleur" :
                    self.ctrl_couleur.SetCouleur(valeur)