class FicheFournisseur(wx.Panel): def __init__(self, parent, fournisseur=None): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL) #permet de faire un validate sur tout les panels self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY) if fournisseur: self.fournisseur = fournisseur else: self.fournisseur = Fournisseur() self.notebook = wx.Notebook(self, -1, style=0) self.notebook_p1 = wx.Panel(self.notebook, -1) self.notebook_p2 = wx.Panel(self.notebook, -1) #self.sizer_adhesions_staticbox = wx.StaticBox(self.notebook_p4, -1, u"Types d'adhésion") #self.label_description_adhesions = wx.StaticText(self.notebook_p4, -1, u"Ce sont les différentes formules disponibles pour adhérer à l'association.") self.panel_fournisseur = FicheFournisseurBase(self.notebook_p1, self.fournisseur) self.panel_gestion_referents = GestionReferents(self.notebook_p2, self.fournisseur) self.bouton_ok = wx.Button(self, wx.ID_OK, "") self.bouton_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler") self.bouton_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose) self.__set_properties() self.__do_layout() # end wxGlade def __set_properties(self): #On affiche pas les panneaux secondaires pour un nouveau fournisseur if not self.fournisseur.get_id(): self.notebook_p2.Hide() def __do_layout(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer_p1 = wx.BoxSizer(wx.VERTICAL) sizer_p2 = wx.BoxSizer(wx.VERTICAL) sizer_p1.Add(self.panel_fournisseur, 1, wx.ALL|wx.EXPAND, 5) self.notebook_p1.SetSizer(sizer_p1) sizer_p2.Add(self.panel_gestion_referents, 1, wx.ALL|wx.EXPAND, 5) self.notebook_p2.SetSizer(sizer_p2) self.notebook.AddPage(self.notebook_p1, u"Fournisseur") self.notebook.AddPage(self.notebook_p2, u"Référents") sizer_boutons = wx.BoxSizer(wx.HORIZONTAL) sizer_boutons.Add((20, 20), 1, 0, 0) sizer_boutons.Add(self.bouton_ok, 0, 0, 0) sizer_boutons.Add((20, 20), 1, 0, 0) sizer_boutons.Add(self.bouton_annuler, 0, 0, 0) sizer_boutons.Add((20, 20), 1, 0, 0) sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 5) sizer.Add(sizer_boutons, 0, wx.TOP|wx.BOTTOM|wx.EXPAND, 10) self.SetSizer(sizer) sizer.Fit(self) def GetFournisseur(self): return self.fournisseur def OnEnregistre(self, event): if self.Validate(): self.panel_fournisseur.Enregistre() DATABASE.commit() event.Skip() else: control = wx.Window.FindFocus() self.notebook.ChangeSelection(0) control.SetFocus() def OnClose(self, event): DATABASE.rollback() event.Skip()
class FicheFournisseur(wx.Panel): def __init__(self, parent, fournisseur=None): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL) #permet de faire un validate sur tout les panels self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY) if fournisseur: self.fournisseur = fournisseur else: self.fournisseur = Fournisseur() self.notebook = wx.Notebook(self, -1, style=0) self.notebook_p1 = wx.Panel(self.notebook, -1) self.notebook_p2 = wx.Panel(self.notebook, -1) #self.sizer_adhesions_staticbox = wx.StaticBox(self.notebook_p4, -1, u"Types d'adhésion") #self.label_description_adhesions = wx.StaticText(self.notebook_p4, -1, u"Ce sont les différentes formules disponibles pour adhérer à l'association.") self.panel_fournisseur = FicheFournisseurBase(self.notebook_p1, self.fournisseur) self.panel_gestion_referents = GestionReferents( self.notebook_p2, self.fournisseur) self.bouton_ok = wx.Button(self, wx.ID_OK, "") self.bouton_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler") self.bouton_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose) self.__set_properties() self.__do_layout() # end wxGlade def __set_properties(self): #On affiche pas les panneaux secondaires pour un nouveau fournisseur if not self.fournisseur.get_id(): self.notebook_p2.Hide() def __do_layout(self): sizer = wx.BoxSizer(wx.VERTICAL) sizer_p1 = wx.BoxSizer(wx.VERTICAL) sizer_p2 = wx.BoxSizer(wx.VERTICAL) sizer_p1.Add(self.panel_fournisseur, 1, wx.ALL | wx.EXPAND, 5) self.notebook_p1.SetSizer(sizer_p1) sizer_p2.Add(self.panel_gestion_referents, 1, wx.ALL | wx.EXPAND, 5) self.notebook_p2.SetSizer(sizer_p2) self.notebook.AddPage(self.notebook_p1, u"Fournisseur") self.notebook.AddPage(self.notebook_p2, u"Référents") sizer_boutons = wx.BoxSizer(wx.HORIZONTAL) sizer_boutons.Add((20, 20), 1, 0, 0) sizer_boutons.Add(self.bouton_ok, 0, 0, 0) sizer_boutons.Add((20, 20), 1, 0, 0) sizer_boutons.Add(self.bouton_annuler, 0, 0, 0) sizer_boutons.Add((20, 20), 1, 0, 0) sizer.Add(self.notebook, 1, wx.ALL | wx.EXPAND, 5) sizer.Add(sizer_boutons, 0, wx.TOP | wx.BOTTOM | wx.EXPAND, 10) self.SetSizer(sizer) sizer.Fit(self) def GetFournisseur(self): return self.fournisseur def OnEnregistre(self, event): if self.Validate(): self.panel_fournisseur.Enregistre() DATABASE.commit() event.Skip() else: control = wx.Window.FindFocus() self.notebook.ChangeSelection(0) control.SetFocus() def OnClose(self, event): DATABASE.rollback() event.Skip()