Beispiel #1
0
class lib_ticker_Tests(wtc.WidgetTestCase):
    def test_lib_ticker(self):
        self.ticker = Ticker(self.frame)

        txt = 'a nice ticker text'
        self.ticker.SetText(txt)
        self.assertEqual(self.ticker.GetText(), txt)
    def __init__(self,
                 parent,
                 delai=60,
                 listeActivites=[],
                 fps=20,
                 ppf=2,
                 couleurFond=None):
        wx.Panel.__init__(self, parent, id=-1)
        self.parent = parent
        self.delai = delai
        self.listeActivites = listeActivites
        if couleurFond != None:
            self.SetBackgroundColour(couleurFond)

        self.timer = wx.Timer(self, -1)

        self.ticker = Ticker(self)
        self.ticker.SetBackgroundColour(self.GetBackgroundColour())
        self.ticker.SetFPS(fps)
        self.ticker.SetPPF(ppf)

        # Layout
        sizer_base = wx.BoxSizer(wx.VERTICAL)
        sizer_base.Add(self.ticker, 1, wx.EXPAND | wx.ALL, 5)
        self.SetSizer(sizer_base)
        sizer_base.Fit(self)

        # Binds
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
Beispiel #3
0
    def RunComplexDemo(self, tb):

        # This Is The New Call Style: The Call To GetToasterBoxWindow()
        # Is Mandatory, In Order To Create A Custom Parent On ToasterBox.

        tbpanel = tb.GetToasterBoxWindow()
        panel = wx.Panel(tbpanel, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        horsizer1 = wx.BoxSizer(wx.HORIZONTAL)

        myimage = wx.Bitmap("andrea.jpeg", wx.BITMAP_TYPE_JPEG)
        stbmp = wx.StaticBitmap(panel, -1, myimage)
        horsizer1.Add(stbmp, 0)

        strs = "This Is Another Example Of ToasterBox, A Complex One. This Kind Of"
        strs = strs + " ToasterBox Can Be Created Using The Style TB_COMPLEX."
        sttext = wx.StaticText(panel, -1, strs)
        sttext.SetFont(
            wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL, False, "Verdana"))
        horsizer1.Add(sttext, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)

        hl = hyperlink.HyperLinkCtrl(
            panel,
            -1,
            "My Home Page",
            URL="http://xoomer.virgilio.it/infinity77/")

        sizer.Add((0, 5))
        sizer.Add(horsizer1, 0, wx.EXPAND)

        horsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        horsizer2.Add((5, 0))
        horsizer2.Add(hl, 0, wx.EXPAND | wx.TOP, 10)
        sizer.Add(horsizer2, 0, wx.EXPAND)

        tk = Ticker(panel)
        tk.SetText("Hello From wxPython!")

        horsizer3 = wx.BoxSizer(wx.HORIZONTAL)
        horsizer3.Add((5, 0))
        horsizer3.Add(tk, 1, wx.EXPAND | wx.TOP, 10)
        horsizer3.Add((5, 0))
        sizer.Add(horsizer3, 0, wx.EXPAND)

        sizer.Layout()
        panel.SetSizer(sizer)

        tb.AddPanel(panel)
Beispiel #4
0
    def RunComplexDemo(self, tb):

        # This Is The New Call Style: The Call To GetToasterBoxWindow()
        # Is Mandatory, In Order To Create A Custom Parent On ToasterBox.

        tbpanel = tb.GetToasterBoxWindow()
        panel = wx.Panel(tbpanel, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        horsizer1 = wx.BoxSizer(wx.HORIZONTAL)

        myimage = wx.Bitmap(os.path.join(bitmapDir, "sttfont.png"),
                            wx.BITMAP_TYPE_PNG)
        stbmp = wx.StaticBitmap(panel, -1, myimage)
        horsizer1.Add(stbmp, 0)

        strs = "This Is Another Example Of ToasterBox, A Complex One. This Kind Of"
        strs = strs + " ToasterBox Can Be Created Using The Style TB_COMPLEX."
        sttext = wx.StaticText(panel, -1, strs)
        horsizer1.Add(sttext, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)

        hl = wx.adv.HyperlinkCtrl(panel,
                                  -1,
                                  label="My Home Page",
                                  url="http://xoomer.alice.it/infinity77/")

        sizer.Add((0, 5))
        sizer.Add(horsizer1, 0, wx.EXPAND)

        horsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        horsizer2.Add((5, 0))
        horsizer2.Add(hl, 0, wx.EXPAND | wx.TOP, 10)
        sizer.Add(horsizer2, 0, wx.EXPAND)

        tk = Ticker(panel)
        tk.SetText("Hello From wxPython!")

        horsizer3 = wx.BoxSizer(wx.HORIZONTAL)
        horsizer3.Add((5, 0))
        horsizer3.Add(tk, 1, wx.EXPAND | wx.TOP, 10)
        horsizer3.Add((5, 0))
        sizer.Add(horsizer3, 0, wx.EXPAND)

        panel.SetSizer(sizer)
        panel.Layout()

        tb.AddPanel(panel)
Beispiel #5
0
    def DoCreateResource(self):
        t = Ticker(self.GetParentAsWindow(),
                   self.GetID(),
                   pos=self.GetPosition(),
                   size=self.GetSize(),
                   style=self.GetStyle())
        if self.HasParam("text"):
            t.SetText(self.GetText("text"))
        if self.HasParam("start"):
            if self.GetBool("start"):
                t.Start()
            else:
                t.Stop()
        if self.HasParam("ppf"):
            t.SetPPF(self.GetLong("ppf"))
        if self.HasParam("fps"):
            t.SetFPS(self.GetLong("fps"))
        if self.HasParam("direction"):
            t.SetDirection(self.GetText("direction"))

        self.SetupWindow(t)  # handles font, bg/fg color
        return t
Beispiel #6
0
class CTRL(wx.Panel):
    """ Delai d'actualisation en secondes """
    def __init__(self, parent, delai=60, listeActivites=[], fps=20, ppf=2, couleurFond=None):
        wx.Panel.__init__(self, parent, id=-1)
        self.parent = parent
        self.delai = delai
        self.listeActivites = listeActivites
        if couleurFond != None :
            self.SetBackgroundColour(couleurFond)
        
        self.timer = wx.Timer(self, -1)
        
        self.ticker = Ticker(self)
        self.ticker.SetBackgroundColour(self.GetBackgroundColour())
        self.ticker.SetFPS(fps)
        self.ticker.SetPPF(ppf)
        
        # Layout
        sizer_base = wx.BoxSizer(wx.VERTICAL)
        sizer_base.Add(self.ticker, 1, wx.EXPAND|wx.ALL, 5)
        self.SetSizer(sizer_base)
        sizer_base.Fit(self)
        
        # Binds
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        
    
    def SetTexte(self, texte=u""):
        self.ticker.SetText(texte)

    def Stop(self):
        """Stop moving the text"""
        self.timer.Stop()
        
    def Start(self):
        """Starts the text moving"""
        if not self.timer.IsRunning():
            self.timer.Start(self.delai * 1000)

    def OnTimer(self, event):
        self.MAJ() 
    
    def SetActivites(self, listeActivites=[]):
        self.listeActivites = listeActivites
        
    def MAJ(self):
        try :
            texte = self.GetTexte(self.listeActivites) 
            self.SetTexte(texte)
        except :
            texte = u""
            
        if len(texte) > 0 :
            etat = True
            if self.ticker.IsTicking() == False :
                self.ticker.Start()
        else :
            etat = False
            if self.ticker.IsTicking() :
                self.ticker.Stop()
        try :
            self.parent.AffichePresents(etat)
        except :
            pass
        
    def JoinListe(self, listeTemp=[]):
        if len(listeTemp) > 2 :
            return _(u"%s et %s") % (u", ".join(listeTemp[:-1], listeTemp[-1]))
        else :
            return _(u" et ").join(listeTemp)
        
    def GetTexte(self, listeActivites=[]):
        """ Récupération des données dans la base de données """
        if len(listeActivites) == 0 : conditionActivites = "()"
        elif len(listeActivites) == 1 : conditionActivites = "(%d)" % listeActivites[0]
        else : conditionActivites = str(tuple(listeActivites))
        
        now = datetime.datetime.now()
        date = datetime.date(now.year, now.month, now.day)
        heure = "%02d:%02d" % (now.hour, now.minute)
        
        DB = GestionDB.DB()
        req = """SELECT activites.IDactivite, activites.nom, groupes.IDgroupe, groupes.nom, groupes.ordre, COUNT(IDconso), SUM(quantite)
        FROM consommations 
        LEFT JOIN activites ON activites.IDactivite = consommations.IDactivite
        LEFT JOIN groupes ON groupes.IDgroupe = consommations.IDgroupe
        WHERE consommations.IDactivite IN %s
        AND date = '%s'
        AND heure_debut <= '%s' 
        AND heure_fin >= '%s'
        AND etat IN ("reservation", "present")
        GROUP BY consommations.IDactivite, consommations.IDindividu
        ORDER BY activites.nom, groupes.ordre;""" % (conditionActivites, date, heure, heure)
        DB.ExecuterReq(req)
        listeConso = DB.ResultatReq()
        DB.Close() 
        
        if len(listeConso) == 0 :
            return u""
        
        dictTemp = {}
        listeActivites = []
        for IDactivite, nomActivite, IDgroupe, nomGroupe, ordreGroupe, nbreConso, quantite in listeConso :
            if dictTemp.has_key(IDactivite) == False :
                dictTemp[IDactivite] = {"nom" : nomActivite, "nbre" : 0, "groupes" : {} }
                listeActivites.append(IDactivite)
            if dictTemp[IDactivite]["groupes"].has_key(IDgroupe) == False  :
                dictTemp[IDactivite]["groupes"][IDgroupe] = {"nom" : nomGroupe, "ordre" : ordreGroupe, "nbre" : 0}
            dictTemp[IDactivite]["groupes"][IDgroupe]["nbre"] += 1
            dictTemp[IDactivite]["nbre"] += 1
        
        listeTextes = []
        for IDactivite in listeActivites :
            nomActivite = dictTemp[IDactivite]["nom"]
            
            listeGroupes = []
            for IDgroupe, dictGroupe in dictTemp[IDactivite]["groupes"].iteritems() :
                label = u"%d %s" % (dictGroupe["nbre"], dictGroupe["nom"])
                listeGroupes.append((dictGroupe["ordre"], label))
            listeGroupes.sort() 
            groupes = []
            for ordre, label in listeGroupes :
                groupes.append(label)
            
            nbre = dictTemp[IDactivite]["nbre"]
            if nbre == 1 :
                temp = _(u"individu")
            else :
                temp = _(u"individus")
            listeTextes.append(_(u"%d %s sur l'activité %s (%s)") % (nbre, temp, nomActivite, self.JoinListe(groupes)))
        
        texte = _(u"Il y a actuellement %s") % self.JoinListe(listeTextes)
        return texte
Beispiel #7
0
 def __init__(self, parent, log):
     self.log = log
     wx.Panel.__init__(self, parent, -1)
     
     self.ticker = Ticker(self)
     
     #       Controls for ...controlling... the ticker.
     self.txt = wx.TextCtrl(self, value="I am a scrolling ticker!!!!", size=(200,-1))
     wx.CallAfter(self.txt.SetInsertionPoint, 0)
     txtl = wx.StaticText(self, label="Ticker text:")
     fgb = csel.ColourSelect(self, -1, colour=self.ticker.GetForegroundColour())
     fgl = wx.StaticText(self, label="Foreground Color:")
     bgb = csel.ColourSelect(self, -1, colour=self.ticker.GetBackgroundColour())
     bgl = wx.StaticText(self, label="Background Color:")
     fontb = wx.Button(self, label="Change")
     self.fontl = wx.StaticText(self)
     dirb = wx.Button(self, label="Switch")
     self.dirl = wx.StaticText(self)
     fpsl = wx.StaticText(self, label="Frames per Second:")
     fps = wx.Slider(self, value=self.ticker.GetFPS(), minValue=1, maxValue=100,
                     size=(150,-1),
                     style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LABELS)
     fps.SetTickFreq(5)
     ppfl = wx.StaticText(self, label="Pixels per frame:")
     ppf = wx.Slider(self, value=self.ticker.GetPPF(), minValue=1, maxValue=10,
                     size=(150,-1),
                     style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LABELS)
     
     #       Do layout
     sz = wx.FlexGridSizer(cols=2, hgap=4, vgap=4)
     
     sz.Add(txtl, flag=wx.ALIGN_CENTER_VERTICAL)
     sz.Add(self.txt, flag=wx.ALIGN_CENTER_VERTICAL)
     
     sz.Add(fgl, flag=wx.ALIGN_CENTER_VERTICAL)
     sz.Add(fgb, flag=wx.ALIGN_CENTER_VERTICAL)
     
     sz.Add(bgl, flag=wx.ALIGN_CENTER_VERTICAL)
     sz.Add(bgb, flag=wx.ALIGN_CENTER_VERTICAL)
     
     sz.Add(self.fontl, flag=wx.ALIGN_CENTER_VERTICAL)
     sz.Add(fontb, flag=wx.ALIGN_CENTER_VERTICAL)
     
     sz.Add(self.dirl, flag=wx.ALIGN_CENTER_VERTICAL)
     sz.Add(dirb, flag=wx.ALIGN_CENTER_VERTICAL)
     
     sz.Add(fpsl, flag=wx.ALIGN_CENTER_VERTICAL)
     sz.Add(fps, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
     
     sz.Add(ppfl, flag=wx.ALIGN_CENTER_VERTICAL)
     sz.Add(ppf, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
     
     sz2 = wx.BoxSizer(wx.VERTICAL)
     sz2.Add(self.ticker, flag=wx.EXPAND|wx.ALL, border=5)
     sz2.Add(sz, flag=wx.EXPAND|wx.ALL, proportion=1, border=25)
     self.SetSizer(sz2)
     sz2.SetSizeHints(self)
     
     #       Bind events
     self.Bind(wx.EVT_BUTTON, self.OnChangeTickDirection, dirb)
     self.Bind(wx.EVT_BUTTON, self.OnChangeTickFont, fontb)
     self.Bind(wx.EVT_TEXT, self.OnText, self.txt)
     self.Bind(csel.EVT_COLOURSELECT, self.ChangeTickFGColor, fgb)
     self.Bind(csel.EVT_COLOURSELECT, self.ChangeTickBGColor, bgb)
     self.Bind(wx.EVT_SCROLL, self.ChangeFPS, fps)
     self.Bind(wx.EVT_SCROLL, self.ChangePPF, ppf)
     
     #       Set defaults
     self.SetTickDirection("rtl")
     self.SetTickFont(self.ticker.GetFont())
     self.ticker.SetText(self.txt.GetValue())
Beispiel #8
0
class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, -1)
        
        self.ticker = Ticker(self)
        
        #       Controls for ...controlling... the ticker.
        self.txt = wx.TextCtrl(self, value="I am a scrolling ticker!!!!", size=(200,-1))
        wx.CallAfter(self.txt.SetInsertionPoint, 0)
        txtl = wx.StaticText(self, label="Ticker text:")
        fgb = csel.ColourSelect(self, -1, colour=self.ticker.GetForegroundColour())
        fgl = wx.StaticText(self, label="Foreground Color:")
        bgb = csel.ColourSelect(self, -1, colour=self.ticker.GetBackgroundColour())
        bgl = wx.StaticText(self, label="Background Color:")
        fontb = wx.Button(self, label="Change")
        self.fontl = wx.StaticText(self)
        dirb = wx.Button(self, label="Switch")
        self.dirl = wx.StaticText(self)
        fpsl = wx.StaticText(self, label="Frames per Second:")
        fps = wx.Slider(self, value=self.ticker.GetFPS(), minValue=1, maxValue=100,
                        size=(150,-1),
                        style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LABELS)
        fps.SetTickFreq(5)
        ppfl = wx.StaticText(self, label="Pixels per frame:")
        ppf = wx.Slider(self, value=self.ticker.GetPPF(), minValue=1, maxValue=10,
                        size=(150,-1),
                        style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LABELS)
        
        #       Do layout
        sz = wx.FlexGridSizer(cols=2, hgap=4, vgap=4)
        
        sz.Add(txtl, flag=wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.txt, flag=wx.ALIGN_CENTER_VERTICAL)
        
        sz.Add(fgl, flag=wx.ALIGN_CENTER_VERTICAL)
        sz.Add(fgb, flag=wx.ALIGN_CENTER_VERTICAL)
        
        sz.Add(bgl, flag=wx.ALIGN_CENTER_VERTICAL)
        sz.Add(bgb, flag=wx.ALIGN_CENTER_VERTICAL)
        
        sz.Add(self.fontl, flag=wx.ALIGN_CENTER_VERTICAL)
        sz.Add(fontb, flag=wx.ALIGN_CENTER_VERTICAL)
        
        sz.Add(self.dirl, flag=wx.ALIGN_CENTER_VERTICAL)
        sz.Add(dirb, flag=wx.ALIGN_CENTER_VERTICAL)
        
        sz.Add(fpsl, flag=wx.ALIGN_CENTER_VERTICAL)
        sz.Add(fps, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
        
        sz.Add(ppfl, flag=wx.ALIGN_CENTER_VERTICAL)
        sz.Add(ppf, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
        
        sz2 = wx.BoxSizer(wx.VERTICAL)
        sz2.Add(self.ticker, flag=wx.EXPAND|wx.ALL, border=5)
        sz2.Add(sz, flag=wx.EXPAND|wx.ALL, proportion=1, border=25)
        self.SetSizer(sz2)
        sz2.SetSizeHints(self)
        
        #       Bind events
        self.Bind(wx.EVT_BUTTON, self.OnChangeTickDirection, dirb)
        self.Bind(wx.EVT_BUTTON, self.OnChangeTickFont, fontb)
        self.Bind(wx.EVT_TEXT, self.OnText, self.txt)
        self.Bind(csel.EVT_COLOURSELECT, self.ChangeTickFGColor, fgb)
        self.Bind(csel.EVT_COLOURSELECT, self.ChangeTickBGColor, bgb)
        self.Bind(wx.EVT_SCROLL, self.ChangeFPS, fps)
        self.Bind(wx.EVT_SCROLL, self.ChangePPF, ppf)
        
        #       Set defaults
        self.SetTickDirection("rtl")
        self.SetTickFont(self.ticker.GetFont())
        self.ticker.SetText(self.txt.GetValue())

        
    def SetTickFont(self, font):
        """Sets ticker font, updates label"""
        self.ticker.SetFont(font)
        self.fontl.SetLabel("Font: %s"%(self.ticker.GetFont().GetFaceName()))
        self.Layout()
        
        
    def OnChangeTickFont(self, evt):
        fd = wx.FontData()
        fd.EnableEffects(False)
        fd.SetInitialFont(self.ticker.GetFont())
        dlg = wx.FontDialog(wx.GetTopLevelParent(self), fd)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetFontData()
            self.SetTickFont(data.GetChosenFont())
            
            
    def SetTickDirection(self, dir):
        """Sets tick direction, updates label"""
        self.ticker.SetDirection(dir)
        self.dirl.SetLabel("Direction: %s"%(self.ticker.GetDirection()))
        
        
    def OnChangeTickDirection(self, dir):
        if self.ticker.GetDirection() == "rtl":
            self.SetTickDirection("ltr")
        else:
            self.SetTickDirection("rtl")
            
            
    def OnText(self, evt):
        """Live update of the ticker text"""
        self.ticker.SetText(self.txt.GetValue())
        
    def ChangeTickFGColor(self, evt):
        self.ticker.SetForegroundColour(evt.GetValue())
        
    def ChangeTickBGColor(self, evt):
        self.ticker.SetBackgroundColour(evt.GetValue())
        
    def ChangeFPS(self, evt):
        self.ticker.SetFPS(evt.GetPosition())
        
    def ChangePPF(self, evt):
        self.ticker.SetPPF(evt.GetPosition())


    def ShutdownDemo(self):
        self.ticker.Stop()
Beispiel #9
0
    def __init__(self, *args, **kwargs):

        self.stream = kwargs.pop('stream', None)
        self.name_stream = kwargs.pop('name_stream', 'memory_stream')
        self.bass_handle = 0
        self.sound_font = 0

        result = pybass.BASS_Init(-1, 44100, 0, 0, 0)
        if not result:
            bass_error_code = pybass.BASS_ErrorGetCode()
            if bass_error_code != pybass.BASS_ERROR_ALREADY:
                self.slider.Enable(False)
                self.btn_play.Enable(False)
                self.btn_stop.Enable(False)
                print('BASS_Init error %s' %
                      pybass.get_error_description(bass_error_code))
        self.plugins = {}
        self.plugins['aac'] = (pybass.BASS_PluginLoad('bass_aac.dll',
                                                      0), '|AAC|*.aac')
        self.plugins['ac3'] = (pybass.BASS_PluginLoad('bass_ac3.dll',
                                                      0), '|AC3|*.ac3')
        self.plugins['aix'] = (pybass.BASS_PluginLoad('bass_aix.dll',
                                                      0), '|AIX|*.aix')
        self.plugins['ape'] = (pybass.BASS_PluginLoad('bass_ape.dll',
                                                      0), '|APE|*.ape')
        self.plugins['mpc'] = (pybass.BASS_PluginLoad('bass_mpc.dll',
                                                      0), '|MPC|*.mpc')
        self.plugins['ofr'] = (pybass.BASS_PluginLoad('bass_ofr.dll',
                                                      0), '|OFR|*.ofr')
        self.plugins['spx'] = (pybass.BASS_PluginLoad('bass_spx.dll',
                                                      0), '|SPX|*.spx')
        self.plugins['tta'] = (pybass.BASS_PluginLoad('bass_tta.dll',
                                                      0), '|TTA|*.tta')
        self.plugins['cda'] = (pybass.BASS_PluginLoad('basscd.dll',
                                                      0), '|CDA|*.cda')
        self.plugins['flac'] = (pybass.BASS_PluginLoad('bassflac.dll',
                                                       0), '|FLAC|*.flac')
        self.plugins['wma'] = (pybass.BASS_PluginLoad('basswma.dll', 0),
                               '|WMA, WMV|*.wma;*.wmv')
        if pybassmidi:
            sound_font_file_name = 'CT4MGM.SF2'
            self.sound_font = pybassmidi.BASS_MIDI_FontInit(
                sound_font_file_name, 0)
            if self.sound_font == 0:
                print(
                    'BASS_MIDI_FontInit error %s (sound font file must be %s)'
                    % (pybass.get_error_description(
                        pybass.BASS_ErrorGetCode()), sound_font_file_name))
            else:
                self.plugins['midi'] = (pybass.BASS_PluginLoad(
                    'bassmidi.dll', 0), '|MID|*.mid')
        else:
            print('pybassmidi module not accessible')

        wx.Panel.__init__(self, *args, **kwargs)

        sizer_h = wx.BoxSizer(wx.HORIZONTAL)

        self.btn_play = wx.Button(self,
                                  wx.ID_ANY,
                                  _('Play'),
                                  style=wx.NO_BORDER)
        self.btn_play.SetToolTip(_('Play media data'))
        self.Bind(wx.EVT_BUTTON, self.event_play, self.btn_play)
        sizer_h.Add(self.btn_play)

        self.btn_stop = wx.Button(self,
                                  wx.ID_ANY,
                                  _('Stop'),
                                  style=wx.NO_BORDER)
        self.Bind(wx.EVT_BUTTON, self.event_stop, self.btn_stop)
        sizer_h.Add(self.btn_stop)

        self.btn_open = wx.Button(self,
                                  wx.ID_OPEN,
                                  _('Open'),
                                  style=wx.NO_BORDER)
        self.Bind(wx.EVT_BUTTON, self.event_open, self.btn_open)
        sizer_h.Add(self.btn_open)

        sizer_v = wx.BoxSizer(wx.VERTICAL)

        self.status_line = Ticker(self,
                                  fgcolor='#000062',
                                  bgcolor='#7F7F8F',
                                  start=False,
                                  ppf=1,
                                  fps=50,
                                  direction='ltr')
        sizer_v.Add(self.status_line, 0, wx.EXPAND)

        self.slider = slider_ctrl(self, wx.ID_ANY, 0, 0, 1)
        sizer_v.Add(self.slider, 0, wx.EXPAND)

        sizer_v.Add(sizer_h)

        self.SetSizer(sizer_v)
        self.SetAutoLayout(True)

        self.volume_slider = wx.Slider(self, wx.ID_ANY,
                                       pybass.BASS_GetVolume() * 100, 0, 100)
        self.Bind(wx.EVT_SCROLL, self.event_volume_slider, self.volume_slider)
        sizer_h.Add(self.volume_slider, 0, wx.EXPAND)

        self.method_check_controls()
Beispiel #10
0
class player_ctrl(wx.Panel):
    def __init__(self, *args, **kwargs):

        self.stream = kwargs.pop('stream', None)
        self.name_stream = kwargs.pop('name_stream', 'memory_stream')
        self.bass_handle = 0
        self.sound_font = 0

        result = pybass.BASS_Init(-1, 44100, 0, 0, 0)
        if not result:
            bass_error_code = pybass.BASS_ErrorGetCode()
            if bass_error_code != pybass.BASS_ERROR_ALREADY:
                self.slider.Enable(False)
                self.btn_play.Enable(False)
                self.btn_stop.Enable(False)
                print('BASS_Init error %s' %
                      pybass.get_error_description(bass_error_code))
        self.plugins = {}
        self.plugins['aac'] = (pybass.BASS_PluginLoad('bass_aac.dll',
                                                      0), '|AAC|*.aac')
        self.plugins['ac3'] = (pybass.BASS_PluginLoad('bass_ac3.dll',
                                                      0), '|AC3|*.ac3')
        self.plugins['aix'] = (pybass.BASS_PluginLoad('bass_aix.dll',
                                                      0), '|AIX|*.aix')
        self.plugins['ape'] = (pybass.BASS_PluginLoad('bass_ape.dll',
                                                      0), '|APE|*.ape')
        self.plugins['mpc'] = (pybass.BASS_PluginLoad('bass_mpc.dll',
                                                      0), '|MPC|*.mpc')
        self.plugins['ofr'] = (pybass.BASS_PluginLoad('bass_ofr.dll',
                                                      0), '|OFR|*.ofr')
        self.plugins['spx'] = (pybass.BASS_PluginLoad('bass_spx.dll',
                                                      0), '|SPX|*.spx')
        self.plugins['tta'] = (pybass.BASS_PluginLoad('bass_tta.dll',
                                                      0), '|TTA|*.tta')
        self.plugins['cda'] = (pybass.BASS_PluginLoad('basscd.dll',
                                                      0), '|CDA|*.cda')
        self.plugins['flac'] = (pybass.BASS_PluginLoad('bassflac.dll',
                                                       0), '|FLAC|*.flac')
        self.plugins['wma'] = (pybass.BASS_PluginLoad('basswma.dll', 0),
                               '|WMA, WMV|*.wma;*.wmv')
        if pybassmidi:
            sound_font_file_name = 'CT4MGM.SF2'
            self.sound_font = pybassmidi.BASS_MIDI_FontInit(
                sound_font_file_name, 0)
            if self.sound_font == 0:
                print(
                    'BASS_MIDI_FontInit error %s (sound font file must be %s)'
                    % (pybass.get_error_description(
                        pybass.BASS_ErrorGetCode()), sound_font_file_name))
            else:
                self.plugins['midi'] = (pybass.BASS_PluginLoad(
                    'bassmidi.dll', 0), '|MID|*.mid')
        else:
            print('pybassmidi module not accessible')

        wx.Panel.__init__(self, *args, **kwargs)

        sizer_h = wx.BoxSizer(wx.HORIZONTAL)

        self.btn_play = wx.Button(self,
                                  wx.ID_ANY,
                                  _('Play'),
                                  style=wx.NO_BORDER)
        self.btn_play.SetToolTip(_('Play media data'))
        self.Bind(wx.EVT_BUTTON, self.event_play, self.btn_play)
        sizer_h.Add(self.btn_play)

        self.btn_stop = wx.Button(self,
                                  wx.ID_ANY,
                                  _('Stop'),
                                  style=wx.NO_BORDER)
        self.Bind(wx.EVT_BUTTON, self.event_stop, self.btn_stop)
        sizer_h.Add(self.btn_stop)

        self.btn_open = wx.Button(self,
                                  wx.ID_OPEN,
                                  _('Open'),
                                  style=wx.NO_BORDER)
        self.Bind(wx.EVT_BUTTON, self.event_open, self.btn_open)
        sizer_h.Add(self.btn_open)

        sizer_v = wx.BoxSizer(wx.VERTICAL)

        self.status_line = Ticker(self,
                                  fgcolor='#000062',
                                  bgcolor='#7F7F8F',
                                  start=False,
                                  ppf=1,
                                  fps=50,
                                  direction='ltr')
        sizer_v.Add(self.status_line, 0, wx.EXPAND)

        self.slider = slider_ctrl(self, wx.ID_ANY, 0, 0, 1)
        sizer_v.Add(self.slider, 0, wx.EXPAND)

        sizer_v.Add(sizer_h)

        self.SetSizer(sizer_v)
        self.SetAutoLayout(True)

        self.volume_slider = wx.Slider(self, wx.ID_ANY,
                                       pybass.BASS_GetVolume() * 100, 0, 100)
        self.Bind(wx.EVT_SCROLL, self.event_volume_slider, self.volume_slider)
        sizer_h.Add(self.volume_slider, 0, wx.EXPAND)

        self.method_check_controls()

    def method_load_file(self):
        import os
        wildcard = 'music sounds (MO3, IT, XM, S3M, MTM, MOD, UMX)|*.mo3;*.it;*.xm;*.s3m;*.mtm;*.mod;*.umx'
        wildcard += '|stream sounds (MP3, MP2, MP1, OGG, WAV, AIFF)|*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aiff'
        for plugin in self.plugins.itervalues():
            if plugin[0] > 0:
                wildcard += plugin[1]
        wildcard += '|All files (*.*)|*.*'
        dlg = wx.FileDialog(self,
                            message=_('Choose a file'),
                            defaultDir=os.getcwd(),
                            defaultFile='',
                            wildcard=wildcard,
                            style=wx.FD_OPEN | wx.FD_CHANGE_DIR)
        if dlg.ShowModal() == wx.ID_OK:
            self.name_stream = file_name = dlg.GetPath()
            if os.path.isfile(file_name):
                flags = 0
                if isinstance(file_name, unicode):
                    flags |= pybass.BASS_UNICODE
                    try:
                        pybass.BASS_CHANNELINFO._fields_.remove(
                            ('filename', pybass.ctypes.c_char_p))
                    except:
                        pass
                    else:
                        pybass.BASS_CHANNELINFO._fields_.append(
                            ('filename', pybass.ctypes.c_wchar_p))
                error_msg = 'BASS_StreamCreateFile error %s'
                new_bass_handle = 0
                if dlg.GetFilterIndex() == 0:  #BASS_CTYPE_MUSIC_MOD
                    flags |= pybass.BASS_MUSIC_PRESCAN
                    new_bass_handle = pybass.BASS_MusicLoad(
                        False, file_name, 0, 0, flags, 0)
                    error_msg = 'BASS_MusicLoad error %s'
                else:  #other sound types
                    new_bass_handle = pybass.BASS_StreamCreateFile(
                        False, file_name, 0, 0, flags)
                if new_bass_handle == 0:
                    print(error_msg % pybass.get_error_description(
                        pybass.BASS_ErrorGetCode()))
                else:
                    self.method_stop_audio()
                    self.bass_handle = new_bass_handle
                    self.stream = None
                    self.method_slider_set_range()
                    self.method_check_controls()

    def method_load_wav_file(self):
        import os
        wildcard = 'wav (*.wav)|*.wav|All files (*.*)|*.*'
        dlg = wx.FileDialog(self,
                            message=_('Choose a file'),
                            defaultDir=os.getcwd(),
                            defaultFile='',
                            wildcard=wildcard,
                            style=wx.OPEN | wx.CHANGE_DIR)
        if dlg.ShowModal() == wx.ID_OK:
            self.name_stream = file_name = dlg.GetPath()
            if os.path.isfile(file_name):
                flags = 0
                if isinstance(file_name, unicode):
                    flags |= pybass.BASS_UNICODE
                    try:
                        pybass.BASS_CHANNELINFO._fields_.remove(
                            ('filename', pybass.ctypes.c_char_p))
                    except:
                        pass
                    else:
                        pybass.BASS_CHANNELINFO._fields_.append(
                            ('filename', pybass.ctypes.c_wchar_p))

                def stream_callback(handle, buffer, length, user):
                    b = pybass.ctypes.cast(buffer, pybass.ctypes.c_char_p)
                    pybass.ctypes.memset(b, 0, length)
                    data = pybass.ctypes.c_char_p(self.stream.read(length))
                    pybass.ctypes.memmove(b, data, length)
                    if self.stream.is_eof():
                        length |= pybass.BASS_STREAMPROC_END
                        self.stream.current_position = 0
                    return length

                self.stream_callback = stream_callback
                self.user_func = pybass.STREAMPROC(self.stream_callback)
                self.stream = memory_stream(
                    open(file_name, 'rb').read(), file_name)
                new_bass_handle = pybass.BASS_StreamCreate(
                    44100, 2, flags, self.user_func, 0)
                if new_bass_handle == 0:
                    print('BASS_StreamCreate error %s' %
                          pybass.get_error_description(
                              pybass.BASS_ErrorGetCode()))
                else:
                    self.method_stop_audio()
                    self.bass_handle = new_bass_handle
                    self.stream = None
                    self.method_slider_set_range()
                    self.method_check_controls()

    def method_load_data(self, stream, name_stream='memory_stream'):
        if stream is not None:
            if isinstance(stream, (str, list, tuple, buffer)):
                self.stream = memory_stream(stream, name_stream)
            else:
                self.stream = stream
            if isinstance(self.stream, memory_stream):
                system = pybass.STREAMFILE_BUFFER
                flags = 0

                def callback_close(user):
                    self.stream.current_position = 0

                self.callback_close = callback_close

                def callback_length(user):
                    return len(self.stream.data)

                self.callback_length = callback_length

                def callback_read(buffer, length, user):
                    b = pybass.ctypes.cast(buffer, pybass.ctypes.c_char_p)
                    pybass.ctypes.memset(b, 0, length)
                    data = pybass.ctypes.c_char_p(self.stream.read(length))
                    pybass.ctypes.memmove(b, data, length)
                    return length

                self.callback_read = callback_read

                def callback_seek(offset, user):
                    self.stream.seek(offset)
                    return True

                self.callback_seek = callback_seek
                self.bass_file_procs = pybass.BASS_FILEPROCS()
                self.bass_file_procs.close = pybass.FILECLOSEPROC(
                    self.callback_close)
                self.bass_file_procs.length = pybass.FILELENPROC(
                    self.callback_length)
                self.bass_file_procs.read = pybass.FILEREADPROC(
                    self.callback_read)
                self.bass_file_procs.seek = pybass.FILESEEKPROC(
                    self.callback_seek)
                new_bass_handle = pybass.BASS_StreamCreateFileUser(
                    system, flags, self.bass_file_procs, id(self.stream.data))
                if new_bass_handle == 0:
                    print('BASS_StreamCreateFileUser error %s' %
                          pybass.get_error_description(
                              pybass.BASS_ErrorGetCode()))
                else:
                    self.method_stop_audio()
                    self.bass_handle = new_bass_handle
                    channel_info = self.method_get_channel_info()
                    if channel_info.ctype == pybass.BASS_CTYPE_STREAM_OGG:
                        import pyogginfo
                        ogg_info = pyogginfo.VorbisStreamInfo()
                        stream = pyogginfo.SimpleDemultiplexer(ogg_info)
                        if isinstance(self.stream.data, str):
                            stream.process(self.stream.data)
                        else:
                            stream.process(str(self.stream.data))
                        self.stream.decode_length = ogg_info.lastPosition
                        self.stream.seconds = ogg_info.stop
                        try:
                            for key, value in ogg_info.comments.comments:
                                if key == 'TITLE':
                                    if value.strip() > '':
                                        self.stream.name = value
                        except:
                            pass
                    self.method_slider_set_range()
                    self.method_check_controls()

    def method_get_channel_info(self):
        channel_info = pybass.BASS_CHANNELINFO()
        if not pybass.BASS_ChannelGetInfo(self.bass_handle, channel_info):
            print('BASS_ChannelGetInfo error %s' %
                  pybass.get_error_description(pybass.BASS_ErrorGetCode()))
        return channel_info

    def method_get_state(self):
        return pybass.BASS_ChannelIsActive(self.bass_handle)

    def method_get_length(self):
        result = pybass.BASS_ChannelGetLength(self.bass_handle,
                                              pybass.BASS_POS_BYTE)
        if result <= 0 and isinstance(self.stream, memory_stream):
            result = self.stream.decode_length
        return result

    def method_get_position(self):
        return pybass.BASS_ChannelGetPosition(self.bass_handle,
                                              pybass.BASS_POS_BYTE)

    def method_set_position(self, value):
        if not pybass.BASS_ChannelSetPosition(self.bass_handle, value,
                                              pybass.BASS_POS_BYTE):
            print('BASS_ChannelSetPosition error %s' %
                  pybass.get_error_description(pybass.BASS_ErrorGetCode()))

    def method_slider_set_range(self):
        self.slider.SetRange(0, self.method_get_length())

    def method_check_controls(self):
        if self.bass_handle:
            self.slider.Enable(True)
            self.btn_play.Enable(True)
            if self.method_get_state() == pybass.BASS_ACTIVE_STOPPED:
                self.btn_stop.Enable(False)
            else:
                self.btn_stop.Enable(True)
            test = ''
            if hasattr(self.stream, 'name'):
                text = self.stream.name + ' (' + pybass.seconds_to_string(
                    self.stream.seconds) + ')'
            else:
                #~ channel_info = self.method_get_channel_info()
                #~ text = channel_info.filename
                text = self.name_stream + ' (' + pybass.stream_length_as_hms(
                    self.bass_handle) + ')'
            self.status_line.SetText(text)
            if self.status_line.GetText() != '':
                self.status_line.Start()
        else:
            self.slider.Enable(False)
            self.btn_play.Enable(False)
            self.btn_stop.Enable(False)
            if self.status_line.GetText() == '':
                if self.status_line.IsTicking():
                    self.status_line.Stop()

    def method_is_end(self):
        return self.method_get_state(
        ) == pybass.BASS_ACTIVE_STOPPED and self.method_get_position() == 0

    def method_play(self):
        if self.bass_handle:
            if self.method_get_state() in (pybass.BASS_ACTIVE_STOPPED,
                                           pybass.BASS_ACTIVE_PAUSED):
                if not pybass.BASS_ChannelPlay(self.bass_handle, False):
                    print('BASS_ChannelPlay error %s' %
                          pybass.get_error_description(
                              pybass.BASS_ErrorGetCode()))
                else:
                    self.slider.timer_start()
                    self.btn_play.SetLabel(_('Pause'))
                    self.btn_stop.Enable(True)
            else:
                if not pybass.BASS_ChannelPause(self.bass_handle):
                    print('BASS_ChannelPause error %s' %
                          pybass.get_error_description(
                              pybass.BASS_ErrorGetCode()))
                else:
                    self.slider.timer_stop()
                    self.btn_play.SetLabel(_('Unpause'))

    def event_volume_slider(self, event):
        pybass.BASS_SetVolume(event.GetPosition() / 100.0)

    def event_play(self, event):
        self.method_play()

    def event_open(self, event):
        self.method_load_file()

    def event_stop(self, event):
        self.method_stop_audio()

    def method_stop_audio(self):
        self.method_stop_audio_stream()
        self.btn_play.SetLabel(_('Play'))
        self.slider.SetValue(0)
        self.btn_stop.Enable(False)

    def method_stop_audio_stream(self):
        self.slider.timer_stop()
        if self.bass_handle:
            if not pybass.BASS_ChannelStop(self.bass_handle):
                print('BASS_ChannelStop error %s' %
                      pybass.get_error_description(pybass.BASS_ErrorGetCode()))
            else:
                self.method_set_position(0)

    def method_free_handle(self):
        if self.bass_handle:
            channel_info = self.method_get_channel_info()
            if channel_info.ctype >= pybass.BASS_CTYPE_MUSIC_MOD:
                if not pybass.BASS_MusicFree(self.bass_handle):
                    print('BASS_MusicFree error %s' %
                          pybass.get_error_description(
                              pybass.BASS_ErrorGetCode()))
                else:
                    self.bass_handle = 0
            elif channel_info.ctype >= pybass.BASS_CTYPE_STREAM:
                if not pybass.BASS_StreamFree(self.bass_handle):
                    print('BASS_StreamFree error %s' %
                          pybass.get_error_description(
                              pybass.BASS_ErrorGetCode()))
                else:
                    self.bass_handle = 0

    def method_reset(self):
        self.method_free_handle()
        self.status_line.SetText('')
        self.method_check_controls()

    def __del__(self):
        self.method_free_handle()
        if self.sound_font != 0 and pybassmidi:
            if pybassmidi.BASS_MIDI_FontFree(self.sound_font):
                print('BASS_MIDI_FontFree error %s' %
                      pybass.get_error_description(pybass.BASS_ErrorGetCode()))
        for plugin in self.plugins.itervalues():
            if plugin[0] > 0:
                if pybass.BASS_PluginFree(plugin[0]):
                    print('BASS_PluginFree error %s' %
                          pybass.get_error_description(
                              pybass.BASS_ErrorGetCode()))
Beispiel #11
0
    def test_lib_ticker(self):
        self.ticker = Ticker(self.frame)

        txt = 'a nice ticker text'
        self.ticker.SetText(txt)
        self.assertEqual(self.ticker.GetText(), txt)
Beispiel #12
0
    def __init__(self, parent, titre=_(u"Fiche individuelle"), IDpersonne=0):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           name="FicheIndividuelle",
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.IDpersonne = IDpersonne
        self.contratEnCours = None
        self.AnnulationImpossible = False
        self.barre_problemes = None
        self.photo = None

        import locale
        self.locale = wx.Locale(wx.LANGUAGE_FRENCH)

        try:
            locale.setlocale(locale.LC_ALL, 'FR')
        except:
            pass

        self.panel_1 = wx.Panel(self, -1)
        self.label_hd_CatId = wx.StaticText(self.panel_1, -1, u"")
        self.static_line_1 = wx.StaticLine(self.panel_1, -1)
        self.label_hd_nomPrenom = wx.StaticText(self.panel_1, -1,
                                                _(u"NOM, Prénom"))
        self.label_hd_adresse = wx.StaticText(
            self.panel_1, -1,
            _(u"Résidant 42 rue des oiseaux 29870 LANNILIS"))
        self.label_hd_naiss = wx.StaticText(
            self.panel_1, -1, _(u"Date et lieu de naissance inconnus"))
        self.bitmap_photo = CTRL_Photo.CTRL_Photo(self.panel_1,
                                                  style=wx.SUNKEN_BORDER)
        self.bitmap_photo.SetPhoto(
            IDindividu=None,
            nomFichier=Chemins.GetStaticPath("Images/128x128/Personne.png"),
            taillePhoto=(128, 128),
            qualite=100)

        self.bitmap_button_aide = CTRL_Bouton_image.CTRL(
            self.panel_1,
            texte=_(u"Aide"),
            cheminImage=Chemins.GetStaticPath("Images/32x32/Aide.png"))
        self.bitmap_button_Ok = CTRL_Bouton_image.CTRL(
            self.panel_1,
            texte=_(u"Ok"),
            cheminImage=Chemins.GetStaticPath("Images/32x32/Valider.png"))
        self.bitmap_button_annuler = CTRL_Bouton_image.CTRL(
            self.panel_1,
            texte=_(u"Annuler"),
            cheminImage=Chemins.GetStaticPath("Images/32x32/Annuler.png"))

        # NoteBook
        self.notebook = Notebook(self.panel_1, IDpersonne=self.IDpersonne)
        if self.nouvelleFiche == True:
            self.notebook.AfficheAutresPages(False)

        # Recherche s'il y a un contrat en cours ou à venir pour savoir s'il faut afficher la barre des problèmes
        if self.IDpersonne in FonctionsPerso.Recherche_ContratsEnCoursOuAVenir(
        ):
            self.barre_problemes = True
        else:
            self.barre_problemes = False

        # Récupération de la liste des problèmes de la personne
        self.bitmap_problemes_G = wx.StaticBitmap(
            self.panel_1, -1,
            wx.Bitmap(Chemins.GetStaticPath("Images/Special/Problemes_G.png"),
                      wx.BITMAP_TYPE_PNG))
        self.bitmap_problemes_D = wx.StaticBitmap(
            self.panel_1, -1,
            wx.Bitmap(Chemins.GetStaticPath("Images/Special/Problemes_D.png"),
                      wx.BITMAP_TYPE_PNG))
        self.txtDefilant = Ticker(self.panel_1,
                                  size=(-1, 18),
                                  fgcolor=(255, 255, 255),
                                  bgcolor=(255, 60, 60))
        self.txtPbPersonne = self.Recup_txt_pb_personne()
        self.txtDefilant.SetText(self.txtPbPersonne)

        # Mise à jour des infos du bandeau supérieur de la fiche
        self.MaJ_header()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bitmap_button_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bitmap_button_Ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAnnuler,
                  self.bitmap_button_annuler)
        self.txtDefilant.Bind(wx.EVT_MOTION, self.OnMotionTxtDefilant)
        self.txtDefilant.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveTxtDefilant)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.__set_properties()
        self.__do_layout()

        self.Affichage_barre_problemes()
Beispiel #13
0
class Dialog(wx.Dialog):
    def __init__(self, parent, titre=_(u"Fiche individuelle"), IDpersonne=0):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           name="FicheIndividuelle",
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.IDpersonne = IDpersonne
        self.contratEnCours = None
        self.AnnulationImpossible = False
        self.barre_problemes = None
        self.photo = None

        import locale
        self.locale = wx.Locale(wx.LANGUAGE_FRENCH)

        try:
            locale.setlocale(locale.LC_ALL, 'FR')
        except:
            pass

        self.panel_1 = wx.Panel(self, -1)
        self.label_hd_CatId = wx.StaticText(self.panel_1, -1, u"")
        self.static_line_1 = wx.StaticLine(self.panel_1, -1)
        self.label_hd_nomPrenom = wx.StaticText(self.panel_1, -1,
                                                _(u"NOM, Prénom"))
        self.label_hd_adresse = wx.StaticText(
            self.panel_1, -1,
            _(u"Résidant 42 rue des oiseaux 29870 LANNILIS"))
        self.label_hd_naiss = wx.StaticText(
            self.panel_1, -1, _(u"Date et lieu de naissance inconnus"))
        self.bitmap_photo = CTRL_Photo.CTRL_Photo(self.panel_1,
                                                  style=wx.SUNKEN_BORDER)
        self.bitmap_photo.SetPhoto(
            IDindividu=None,
            nomFichier=Chemins.GetStaticPath("Images/128x128/Personne.png"),
            taillePhoto=(128, 128),
            qualite=100)

        self.bitmap_button_aide = CTRL_Bouton_image.CTRL(
            self.panel_1,
            texte=_(u"Aide"),
            cheminImage=Chemins.GetStaticPath("Images/32x32/Aide.png"))
        self.bitmap_button_Ok = CTRL_Bouton_image.CTRL(
            self.panel_1,
            texte=_(u"Ok"),
            cheminImage=Chemins.GetStaticPath("Images/32x32/Valider.png"))
        self.bitmap_button_annuler = CTRL_Bouton_image.CTRL(
            self.panel_1,
            texte=_(u"Annuler"),
            cheminImage=Chemins.GetStaticPath("Images/32x32/Annuler.png"))

        # NoteBook
        self.notebook = Notebook(self.panel_1, IDpersonne=self.IDpersonne)
        if self.nouvelleFiche == True:
            self.notebook.AfficheAutresPages(False)

        # Recherche s'il y a un contrat en cours ou à venir pour savoir s'il faut afficher la barre des problèmes
        if self.IDpersonne in FonctionsPerso.Recherche_ContratsEnCoursOuAVenir(
        ):
            self.barre_problemes = True
        else:
            self.barre_problemes = False

        # Récupération de la liste des problèmes de la personne
        self.bitmap_problemes_G = wx.StaticBitmap(
            self.panel_1, -1,
            wx.Bitmap(Chemins.GetStaticPath("Images/Special/Problemes_G.png"),
                      wx.BITMAP_TYPE_PNG))
        self.bitmap_problemes_D = wx.StaticBitmap(
            self.panel_1, -1,
            wx.Bitmap(Chemins.GetStaticPath("Images/Special/Problemes_D.png"),
                      wx.BITMAP_TYPE_PNG))
        self.txtDefilant = Ticker(self.panel_1,
                                  size=(-1, 18),
                                  fgcolor=(255, 255, 255),
                                  bgcolor=(255, 60, 60))
        self.txtPbPersonne = self.Recup_txt_pb_personne()
        self.txtDefilant.SetText(self.txtPbPersonne)

        # Mise à jour des infos du bandeau supérieur de la fiche
        self.MaJ_header()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bitmap_button_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bitmap_button_Ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAnnuler,
                  self.bitmap_button_annuler)
        self.txtDefilant.Bind(wx.EVT_MOTION, self.OnMotionTxtDefilant)
        self.txtDefilant.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveTxtDefilant)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.__set_properties()
        self.__do_layout()

        self.Affichage_barre_problemes()

    def __set_properties(self):
        self.SetTitle("Fiche individuelle")
        if 'phoenix' in wx.PlatformInfo:
            _icon = wx.Icon()
        else:
            _icon = wx.EmptyIcon()
        _icon.CopyFromBitmap(
            wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"),
                      wx.BITMAP_TYPE_ANY))
        self.SetIcon(_icon)
        self.label_hd_CatId.SetFont(
            wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.label_hd_nomPrenom.SetFont(
            wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.bitmap_photo.SetBackgroundColour(wx.Colour(0, 0, 0))
        self.txtDefilant.SetToolTip(
            wx.ToolTip(
                _(u"Cette barre d'information recense les points\nà contrôler sur le dossier de cette personne."
                  )))
        self.bitmap_photo.SetToolTip(
            wx.ToolTip(
                "Cliquez sur le bouton droit de votre souris pour modifier cette image"
            ))
        self.bitmap_button_aide.SetToolTip(
            wx.ToolTip("Cliquez ici pour obtenir de l'aide"))
        self.bitmap_button_aide.SetSize(self.bitmap_button_aide.GetBestSize())
        self.bitmap_button_Ok.SetToolTip(
            wx.ToolTip("Cliquez ici pour valider"))
        self.bitmap_button_Ok.SetSize(self.bitmap_button_Ok.GetBestSize())
        self.bitmap_button_annuler.SetToolTip(
            wx.ToolTip("Cliquez ici pour annuler"))
        self.bitmap_button_annuler.SetSize(
            self.bitmap_button_annuler.GetBestSize())
        self.SetMinSize((770, 600))

    def __do_layout(self):
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.FlexGridSizer(rows=3, cols=1, vgap=5, hgap=5)
        grid_sizer_boutons = wx.FlexGridSizer(rows=1, cols=5, vgap=0, hgap=10)
        grid_sizer_header = wx.FlexGridSizer(rows=1, cols=2, vgap=0, hgap=0)
        sizer_header_textes = wx.BoxSizer(wx.VERTICAL)
        sizer_header_textes.Add(self.label_hd_CatId, 0, wx.ALIGN_RIGHT, 0)
        sizer_header_textes.Add(self.static_line_1, 0,
                                wx.TOP | wx.BOTTOM | wx.EXPAND, 5)

        sizer_header_textes.Add(self.label_hd_nomPrenom, 0, wx.BOTTOM, 10)
        sizer_header_textes.Add(self.label_hd_adresse, 0, 0, 0)
        sizer_header_textes.Add(self.label_hd_naiss, 0, 0, 0)

        grid_sizer_problemes = wx.FlexGridSizer(rows=1, cols=3, vgap=0, hgap=0)
        grid_sizer_problemes.Add(self.bitmap_problemes_G, 0, 0, 0)
        grid_sizer_problemes.Add(self.txtDefilant, 0, wx.EXPAND, 0)
        grid_sizer_problemes.Add(self.bitmap_problemes_D, 0, 0, 0)
        grid_sizer_problemes.AddGrowableCol(1)
        sizer_header_textes.Add(grid_sizer_problemes, 0, wx.EXPAND | wx.TOP,
                                20)

        grid_sizer_header.Add(sizer_header_textes, 1, wx.EXPAND, 0)
        grid_sizer_header.Add(self.bitmap_photo, 0, wx.LEFT, 10)
        grid_sizer_header.AddGrowableCol(0)
        grid_sizer_1.Add(grid_sizer_header, 1,
                         wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, 10)
        grid_sizer_1.Add(self.notebook, 1,
                         wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10)
        grid_sizer_boutons.Add(self.bitmap_button_aide, 0, wx.EXPAND, 0)
        grid_sizer_boutons.Add((20, 20), 0, 0, 0)
        grid_sizer_boutons.Add(self.bitmap_button_Ok, 0, 0, 0)
        grid_sizer_boutons.Add(self.bitmap_button_annuler, 0, 0, 0)
        grid_sizer_boutons.AddGrowableRow(0)
        grid_sizer_boutons.AddGrowableCol(1)
        grid_sizer_1.Add(grid_sizer_boutons, 1,
                         wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10)
        self.panel_1.SetSizer(grid_sizer_1)
        grid_sizer_1.AddGrowableRow(1)
        grid_sizer_1.AddGrowableCol(0)
        sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        self.CentreOnScreen()

        self.sizer_header_textes = sizer_header_textes

    def Affichage_barre_problemes(self):
        """ Permet d'afficher ou non la barre des problèmes """
        if self.txtPbPersonne == "" or self.barre_problemes == False:
            self.bitmap_problemes_G.Show(False)
            self.bitmap_problemes_D.Show(False)
            self.txtDefilant.Show(False)
            self.txtDefilant.Stop()
        else:
            self.bitmap_problemes_G.Show(True)
            self.bitmap_problemes_D.Show(True)
            self.txtDefilant.Show(True)
            self.txtDefilant.Start()

    def MAJ_barre_problemes(self):
        """ Recherche le texte de la barre des problemes """
        if self.barre_problemes == None: return
        if self.barre_problemes == False:
            self.Affichage_barre_problemes()
        else:
            self.txtPbPersonne = self.MAJ_txt_pb_personne()
            self.txtDefilant.SetText(self.txtPbPersonne)
            self.Affichage_barre_problemes()

    def Recup_txt_pb_personne(self):
        """ Récupère un texte de la liste des problèmes de la personne """
        dictNomsPersonnes, dictProblemesPersonnes = FonctionsPerso.Recup_liste_pb_personnes(
        )
        if self.IDpersonne in dictProblemesPersonnes:
            txtProblemes = ""
            for labelCategorie, listeProblemes in dictProblemesPersonnes[
                    self.IDpersonne].items():
                txtProblemes += labelCategorie + " ("
                for labelProbleme in listeProblemes:
                    txtProblemes += labelProbleme + ", "
                txtProblemes = txtProblemes[:-2] + ")       "
            return txtProblemes
        else:
            return ""

    def MAJ_txt_pb_personne(self):
        """ Récupère un texte de la liste des problèmes de la personne """
        civilite = self.notebook.pageGeneralites.combo_box_civilite.GetStringSelection(
        )
        nom = self.notebook.pageGeneralites.text_nom.GetValue()
        nom_jfille = self.notebook.pageGeneralites.text_ctrl_nomjf.GetValue()
        prenom = self.notebook.pageGeneralites.text_prenom.GetValue()

        # Validation date de naissance
        temp = self.notebook.pageGeneralites.text_date_naiss.GetValue()
        if temp == "  /  /    ":
            date_naiss = None
        else:
            jour = int(temp[:2])
            mois = int(temp[3:5])
            annee = int(temp[6:10])
            date_naiss = datetime.date(annee, mois, jour)

        cp_naiss = self.notebook.pageGeneralites.text_cp_naiss.GetValue()
        ville_naiss = self.notebook.pageGeneralites.text_ville_naiss.GetValue()
        pays_naiss = self.notebook.pageGeneralites.IDpays_naiss
        nationalite = self.notebook.pageGeneralites.IDpays_nation
        num_secu = self.notebook.pageGeneralites.text_numsecu.GetValue()
        adresse_resid = self.notebook.pageGeneralites.text_adresse.GetValue()
        cp_resid = self.notebook.pageGeneralites.text_cp.GetValue()
        ville_resid = self.notebook.pageGeneralites.text_ville.GetValue()

        # Validation IDSituation
        try:
            temp = self.notebook.pageGeneralites.combo_box_situation.GetClientData(
                self.notebook.pageGeneralites.combo_box_situation.GetSelection(
                ))
            if temp == None or temp == '':
                IDsituation = 0
            else:
                IDsituation = temp
        except:
            IDsituation = 0

        infosPersonne = ((self.IDpersonne, civilite, nom, nom_jfille, prenom,
                          date_naiss, cp_naiss, ville_naiss, pays_naiss,
                          nationalite, num_secu, adresse_resid, cp_resid,
                          ville_resid, IDsituation), )
        dictNomsPersonnes, dictProblemesPersonnes = FonctionsPerso.Recherche_problemes_personnes(
            listeIDpersonnes=(self.IDpersonne, ), infosPersonne=infosPersonne)
        if self.IDpersonne in dictProblemesPersonnes:
            txtProblemes = ""
            for labelCategorie, listeProblemes in dictProblemesPersonnes[
                    self.IDpersonne].items():
                txtProblemes += labelCategorie + " ("
                for labelProbleme in listeProblemes:
                    txtProblemes += labelProbleme + ", "
                txtProblemes = txtProblemes[:-2] + ")       "
            return txtProblemes
        else:
            return ""

    def MaJ_header(self):
        # MàJ de l'affichage de ID :
        if self.IDpersonne == 0:
            ID = "Attribution de l'ID en cours"
        else:
            ID = self.IDpersonne
        # MàJ de l'affichage du contrat en cours :
        if self.contratEnCours == None:
            txtContrat = _(u"Aucun contrat en cours")
        else:
            date_debut = FonctionsPerso.DateEngFr(self.contratEnCours[1])
            if self.contratEnCours[2] == "2999-01-01":
                txtContrat = _(u"Contrat en cours : ") + self.contratEnCours[
                    0] + " depuis le " + date_debut + _(u" (Durée ind.)")
            else:
                date_fin = FonctionsPerso.DateEngFr(self.contratEnCours[2])
                date_rupture = FonctionsPerso.DateEngFr(self.contratEnCours[3])
                if date_rupture != "//": date_fin = date_rupture
                txtContrat = _(u"Contrat en cours : ") + self.contratEnCours[
                    0] + " du " + date_debut + " au " + date_fin

        # Affichage
        self.label_hd_CatId.SetLabel(txtContrat + " | ID : " + str(ID))
        try:
            self.sizer_header_textes.Layout()
        except:
            pass

    def OnMotionTxtDefilant(self, event):
        self.txtDefilant.Stop()
        event.Skip()

    def OnLeaveTxtDefilant(self, event):
        self.txtDefilant.Start()
        event.Skip()

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

    def OnBoutonOk(self, event):
        self.AnnulationImpossible = False
        self.Fermer(save=True)
        event.Skip()

    def OnBoutonAnnuler(self, event):
        # Test d'importation des données de la base
        if self.AnnulationImpossible == True:
            self.Fermer(save=True)
        else:
            self.Fermer(save=False)
        event.Skip()

    def OnClose(self, event):
        if self.AnnulationImpossible == True:
            self.Fermer(save=True)
        else:
            self.Fermer(save=False)
        event.Skip()

    def Fermer(self, save=True):
        """ Fermeture """
        if save == False:
            # Annule la création d'une nouvelle fiche
            if self.nouvelleFiche == True:
                db = GestionDB.DB()
                db.ReqDEL("coordonnees", "IDpersonne", self.IDpersonne)
                db.ReqDEL("personnes", "IDpersonne", self.IDpersonne)
                db.Close()

        else:
            # Sauvegarde des données
            # Vérifie que les infos principales sont saisies :
            if self.Verifie_validite_donnees() == True:
                self.notebook.pageGeneralites.Sauvegarde()
                self.notebook.pageQuestionnaire.Sauvegarde()
            else:
                return

        # Recherche si un parent est à mettre à jour
        frm = FonctionsPerso.FrameOuverte("Personnes")
        if frm != None:
            frm.listCtrl_personnes.MAJ(IDpersonne=self.IDpersonne)
            frm.panel_dossiers.tree_ctrl_problemes.MAJ_treeCtrl()
        # Fin
        self.EndModal(wx.ID_OK)

    def Verifie_validite_donnees(self):
        # Vérifie Civilité
        if self.notebook.pageGeneralites.combo_box_civilite.GetStringSelection(
        ) == "":
            dlg = wx.MessageDialog(
                self, _(u"Vous devez saisir obligatoirement une civilité !"),
                "Information", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            self.notebook.pageGeneralites.combo_box_civilite.SetFocus()
            return False
        # Vérifie Nom
        if self.notebook.pageGeneralites.text_nom.GetValue() == "":
            dlg = wx.MessageDialog(
                self,
                _(u"Vous devez saisir obligatoirement un nom de famille !"),
                "Information", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            self.notebook.pageGeneralites.text_nom.SetFocus()
            return False
        # Vérifie Prénom
        if self.notebook.pageGeneralites.text_prenom.GetValue() == "":
            dlg = wx.MessageDialog(
                self, _(u"Vous devez saisir obligatoirement un prénom !"),
                "Information", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            self.notebook.pageGeneralites.text_prenom.SetFocus()
            return False
        return True