# -*- coding: utf-8 -*-
#Boa:Frame:FenetrePrincipale

import wx
from wx.lib.anchors import LayoutAnchors

def create(parent):
    return FenetrePrincipale(parent)

[wxID_FENETREPRINCIPALE, wxID_FENETREPRINCIPALEAFFICHEOPERATION, 
 wxID_FENETREPRINCIPALEAFFICHERESULTAT, wxID_FENETREPRINCIPALEBOUTON0, 
 wxID_FENETREPRINCIPALEBOUTON1, wxID_FENETREPRINCIPALEBOUTON2, 
 wxID_FENETREPRINCIPALEBOUTON3, wxID_FENETREPRINCIPALEBOUTON4, 
 wxID_FENETREPRINCIPALEBOUTON5, wxID_FENETREPRINCIPALEBOUTON6, 
 wxID_FENETREPRINCIPALEBOUTON7, wxID_FENETREPRINCIPALEBOUTON8, 
 wxID_FENETREPRINCIPALEBOUTON9, wxID_FENETREPRINCIPALEBOUTONADITION, 
 wxID_FENETREPRINCIPALEBOUTONDIVISION, 
 wxID_FENETREPRINCIPALEBOUTONMULTIPLICATION, 
 wxID_FENETREPRINCIPALEBOUTONNEGATIF, wxID_FENETREPRINCIPALEBOUTONPARENTHESEF, 
 wxID_FENETREPRINCIPALEBOUTONPARENTHESEO, 
 wxID_FENETREPRINCIPALEBOUTONRESULTAT, 
 wxID_FENETREPRINCIPALEBOUTONSOUSTRACTION, 
 wxID_FENETREPRINCIPALEBOUTONVIRGULE, wxID_FENETREPRINCIPALEEFFACER, 
 wxID_FENETREPRINCIPALEPANELGENERAL, 
] = [wx.NewId() for _init_ctrls in range(24)]

class FenetrePrincipale(wx.Frame):
    def _init_coll_General_Items(self, parent):
        # generated method, don't edit

        parent.AddWindow(self.AfficheOperation, 0, border=2, flag=0)
        parent.AddWindow(self.AfficheResultat, 0, border=2, flag=0)
        parent.AddSizer(self.Nombres, 0, border=0, flag=0)
        parent.AddSizer(self.Operateur, 0, border=0, flag=0)
        parent.AddSizer(self.Operateur2, 0, border=0, flag=0)
        parent.AddWindow(self.Effacer, 0, border=0, flag=0)

    def _init_coll_Nombres_Items(self, parent):
        # generated method, don't edit

        parent.AddWindow(self.bouton1, 0, border=0, flag=0)
        parent.AddWindow(self.bouton2, 0, border=0, flag=0)
        parent.AddWindow(self.bouton3, 0, border=0, flag=0)
        parent.AddWindow(self.bouton4, 0, border=0, flag=0)
        parent.AddWindow(self.bouton5, 0, border=0, flag=0)
        parent.AddWindow(self.bouton6, 0, border=0, flag=0)
        parent.AddWindow(self.bouton7, 0, border=0, flag=0)
        parent.AddWindow(self.bouton8, 0, border=0, flag=0)
        parent.AddWindow(self.bouton9, 0, border=0, flag=0)
        parent.AddWindow(self.boutonNegatif, 0, border=0, flag=0)
        parent.AddWindow(self.bouton0, 0, border=0, flag=0)
        parent.AddWindow(self.boutonVirgule, 0, border=0, flag=0)

    def _init_coll_Operateur2_Items(self, parent):
        # generated method, don't edit

        parent.AddWindow(self.BoutonParentheseO, 0, border=0, flag=0)
        parent.AddWindow(self.BoutonParentheseF, 0, border=0, flag=0)
        parent.AddWindow(self.boutonResultat, 2, border=0, flag=0)

    def _init_coll_Operateur_Items(self, parent):
        # generated method, don't edit

        parent.AddWindow(self.boutonAdition, 1, border=0, flag=0)
        parent.AddWindow(self.boutonSoustraction, 1, border=0, flag=0)
        parent.AddWindow(self.boutonMultiplication, 1, border=0, flag=0)
        parent.AddWindow(self.boutonDivision, 1, border=0, flag=0)

    def _init_sizers(self):
        # generated method, don't edit
        self.General = wx.BoxSizer(orient=wx.VERTICAL)

        self.Operateur = wx.BoxSizer(orient=wx.HORIZONTAL)

        self.Nombres = wx.GridSizer(cols=3, hgap=0, rows=4, vgap=0)

        self.Operateur2 = wx.BoxSizer(orient=wx.HORIZONTAL)

        self._init_coll_General_Items(self.General)
        self._init_coll_Operateur_Items(self.Operateur)
        self._init_coll_Nombres_Items(self.Nombres)
        self._init_coll_Operateur2_Items(self.Operateur2)

        self.panelGeneral.SetSizer(self.General)

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FENETREPRINCIPALE,
              name=u'FenetrePrincipale', parent=prnt, pos=wx.Point(589, 280),
              size=wx.Size(257, 282), style=wx.DEFAULT_FRAME_STYLE,
              title=u'Calculatrice 1')
        self.SetClientSize(wx.Size(257, 254))

        self.panelGeneral = wx.Panel(id=wxID_FENETREPRINCIPALEPANELGENERAL,
              name=u'panelGeneral', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(257, 254), style=wx.TAB_TRAVERSAL)

        self.Effacer = wx.Button(id=wxID_FENETREPRINCIPALEEFFACER,
              label=u'Effacer', name=u'Effacer', parent=self.panelGeneral,
              pos=wx.Point(0, 222), size=wx.Size(256, 31), style=0)
        self.Effacer.SetToolTipString(u'Effacer')
        self.Effacer.SetHelpText(u'')
        self.Effacer.SetLabelText(u'Effacer')
        self.Effacer.SetAutoLayout(False)
        self.Effacer.Center(wx.HORIZONTAL)
        self.Effacer.Bind(wx.EVT_BUTTON, self.OnEffacerButton,
              id=wxID_FENETREPRINCIPALEEFFACER)

        self.bouton1 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON1, label=u'1',
              name=u'bouton1', parent=self.panelGeneral, pos=wx.Point(0, 48),
              size=wx.Size(85, 29), style=0)
        self.bouton1.Bind(wx.EVT_BUTTON, self.OnBouton1Button,
              id=wxID_FENETREPRINCIPALEBOUTON1)

        self.bouton2 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON2, label=u'2',
              name=u'bouton2', parent=self.panelGeneral, pos=wx.Point(85, 48),
              size=wx.Size(85, 29), style=0)
        self.bouton2.Bind(wx.EVT_BUTTON, self.OnBouton2Button,
              id=wxID_FENETREPRINCIPALEBOUTON2)

        self.bouton3 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON3, label=u'3',
              name=u'bouton3', parent=self.panelGeneral, pos=wx.Point(170, 48),
              size=wx.Size(85, 29), style=0)
        self.bouton3.Bind(wx.EVT_BUTTON, self.OnBouton3Button,
              id=wxID_FENETREPRINCIPALEBOUTON3)

        self.bouton4 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON4, label=u'4',
              name=u'bouton4', parent=self.panelGeneral, pos=wx.Point(0, 77),
              size=wx.Size(85, 29), style=0)
        self.bouton4.Bind(wx.EVT_BUTTON, self.OnBouton4Button,
              id=wxID_FENETREPRINCIPALEBOUTON4)

        self.bouton5 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON5, label=u'5',
              name=u'bouton5', parent=self.panelGeneral, pos=wx.Point(85, 77),
              size=wx.Size(85, 29), style=0)
        self.bouton5.Bind(wx.EVT_BUTTON, self.OnBouton5Button,
              id=wxID_FENETREPRINCIPALEBOUTON5)

        self.bouton6 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON6, label=u'6',
              name=u'bouton6', parent=self.panelGeneral, pos=wx.Point(170, 77),
              size=wx.Size(85, 29), style=0)
        self.bouton6.Bind(wx.EVT_BUTTON, self.OnBouton6Button,
              id=wxID_FENETREPRINCIPALEBOUTON6)

        self.bouton7 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON7, label=u'7',
              name=u'bouton7', parent=self.panelGeneral, pos=wx.Point(0, 106),
              size=wx.Size(85, 29), style=0)
        self.bouton7.Bind(wx.EVT_BUTTON, self.OnBouton7Button,
              id=wxID_FENETREPRINCIPALEBOUTON7)

        self.bouton8 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON8, label=u'8',
              name=u'bouton8', parent=self.panelGeneral, pos=wx.Point(85, 106),
              size=wx.Size(85, 29), style=0)
        self.bouton8.Bind(wx.EVT_BUTTON, self.OnBouton8Button,
              id=wxID_FENETREPRINCIPALEBOUTON8)

        self.bouton9 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON9, label=u'9',
              name=u'bouton9', parent=self.panelGeneral, pos=wx.Point(170, 106),
              size=wx.Size(85, 29), style=0)
        self.bouton9.Bind(wx.EVT_BUTTON, self.OnBouton9Button,
              id=wxID_FENETREPRINCIPALEBOUTON9)

        self.boutonNegatif = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONNEGATIF,
              label=u'- / +', name=u'boutonNegatif', parent=self.panelGeneral,
              pos=wx.Point(0, 135), size=wx.Size(85, 29), style=0)
        self.boutonNegatif.Bind(wx.EVT_BUTTON, self.OnBoutonNegatifButton,
              id=wxID_FENETREPRINCIPALEBOUTONNEGATIF)

        self.bouton0 = wx.Button(id=wxID_FENETREPRINCIPALEBOUTON0, label=u'0',
              name=u'bouton0', parent=self.panelGeneral, pos=wx.Point(85, 135),
              size=wx.Size(85, 29), style=0)
        self.bouton0.Bind(wx.EVT_BUTTON, self.OnBouton0Button,
              id=wxID_FENETREPRINCIPALEBOUTON0)

        self.boutonVirgule = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONVIRGULE,
              label=u',', name=u'boutonVirgule', parent=self.panelGeneral,
              pos=wx.Point(170, 135), size=wx.Size(85, 29), style=0)
        self.boutonVirgule.Bind(wx.EVT_BUTTON, self.OnBoutonVirguleButton,
              id=wxID_FENETREPRINCIPALEBOUTONVIRGULE)

        self.boutonAdition = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONADITION,
              label=u'+', name=u'boutonAdition', parent=self.panelGeneral,
              pos=wx.Point(0, 164), size=wx.Size(64, 29), style=0)
        self.boutonAdition.Bind(wx.EVT_BUTTON, self.OnBoutonAditionButton,
              id=wxID_FENETREPRINCIPALEBOUTONADITION)

        self.boutonSoustraction = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONSOUSTRACTION,
              label=u'-', name=u'boutonSoustraction', parent=self.panelGeneral,
              pos=wx.Point(64, 164), size=wx.Size(64, 29), style=0)
        self.boutonSoustraction.Bind(wx.EVT_BUTTON,
              self.OnBoutonSoustractionButton,
              id=wxID_FENETREPRINCIPALEBOUTONSOUSTRACTION)

        self.boutonMultiplication = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONMULTIPLICATION,
              label=u'x', name=u'boutonMultiplication',
              parent=self.panelGeneral, pos=wx.Point(128, 164), size=wx.Size(64,
              29), style=0)
        self.boutonMultiplication.Bind(wx.EVT_BUTTON,
              self.OnBoutonMultiplicationButton,
              id=wxID_FENETREPRINCIPALEBOUTONMULTIPLICATION)

        self.boutonDivision = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONDIVISION,
              label=u'/', name=u'boutonDivision', parent=self.panelGeneral,
              pos=wx.Point(192, 164), size=wx.Size(64, 29), style=0)
        self.boutonDivision.Bind(wx.EVT_BUTTON, self.OnBoutonDivisionButton,
              id=wxID_FENETREPRINCIPALEBOUTONDIVISION)

        self.boutonResultat = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONRESULTAT,
              label=u'=', name=u'boutonResultat', parent=self.panelGeneral,
              pos=wx.Point(128, 193), size=wx.Size(128, 29), style=0)
        self.boutonResultat.Bind(wx.EVT_BUTTON, self.OnBoutonResultatButton,
              id=wxID_FENETREPRINCIPALEBOUTONRESULTAT)

        self.AfficheResultat = wx.StaticText(id=wxID_FENETREPRINCIPALEAFFICHERESULTAT,
              label=u'=', name=u'AfficheResultat', parent=self.panelGeneral,
              pos=wx.Point(0, 24), size=wx.Size(256, 24), style=0)

        self.AfficheOperation = wx.StaticText(id=wxID_FENETREPRINCIPALEAFFICHEOPERATION,
              label=u'', name=u'AfficheOperation', parent=self.panelGeneral,
              pos=wx.Point(0, 0), size=wx.Size(256, 24), style=0)

        self.BoutonParentheseO = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONPARENTHESEO,
              label=u'(', name=u'BoutonParentheseO', parent=self.panelGeneral,
              pos=wx.Point(0, 193), size=wx.Size(64, 29), style=0)
        self.BoutonParentheseO.Bind(wx.EVT_BUTTON,
              self.OnBoutonParentheseOButton,
              id=wxID_FENETREPRINCIPALEBOUTONPARENTHESEO)

        self.BoutonParentheseF = wx.Button(id=wxID_FENETREPRINCIPALEBOUTONPARENTHESEF,
              label=u')', name=u'BoutonParentheseF', parent=self.panelGeneral,
              pos=wx.Point(64, 193), size=wx.Size(64, 29), style=0)
        self.BoutonParentheseF.Bind(wx.EVT_BUTTON,
              self.OnBoutonParentheseFButton,
              id=wxID_FENETREPRINCIPALEBOUTONPARENTHESEF)

        self._init_sizers()

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OnBoutonSoustractionButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "-")

    def OnEffacerButton(self, event):
        self.AfficheOperation.SetLabel('')

    def OnBouton1Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + '1')
        
    def OnBouton2Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + '2')

    def OnBouton3Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "3")

    def OnBouton4Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "4")

    def OnBouton5Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "5")

    def OnBouton6Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "6")
        
    def OnBouton7Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "7")
        
    def OnBouton8Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "8")

    def OnBouton9Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "9")
        
    def OnBoutonNegatifButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "-")

    def OnBouton0Button(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "0")

    def OnBoutonVirguleButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + ".")

    def OnBoutonAditionButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + '+')

    def OnBoutonMultiplicationButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "*")

    def OnBoutonDivisionButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "/")

    def OnBoutonResultatButton(self, event):
        self.AfficheResultat.SetLabel("=" + str(eval(self.AfficheOperation.GetLabel())))
        self.AfficheOperation.SetLabel('')

    def OnBoutonParentheseOButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + "(")

    def OnBoutonParentheseFButton(self, event):
        self.AfficheOperation.SetLabel(self.AfficheOperation.GetLabel() + ")")


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = create(None)
    frame.Show()

    app.MainLoop()
