Пример #1
0
def OnScriptItems(win, event):
    import wx.lib.dialogs
    import traceback
    from modules import common

    eid = event.GetId()
    index = win.scriptmenu_ids.index(eid)
    filename = win.pref.scripts[index][1]

    try:
        scripttext = open(common.encode_path(filename), 'rU').read()
    except:
        common.showerror(win, tr("Can't open the file %s.") % filename)
        return

    try:
        code = compile((scripttext + '\n'), common.encode_path(filename), 'exec')
    except:
        d = wx.lib.dialogs.ScrolledMessageDialog(win, (tr("Error compiling script.\n\nTraceback:\n\n") +
            ''.join(traceback.format_exception(*sys.exc_info()))), tr("Error"), wx.DefaultPosition, wx.Size(400,300))
        d.ShowModal()
        d.Destroy()
        return

    try:
        namespace = locals()
        exec code in namespace
    except:
        d = wx.lib.dialogs.ScrolledMessageDialog(win, (tr("Error running script.\n\nTraceback:\n\n") +
            ''.join(traceback.format_exception(*sys.exc_info()))), tr("Error"), wx.DefaultPosition, wx.Size(400,300))
        d.ShowModal()
        d.Destroy()
        return
Пример #2
0
def OnScriptItems(win, event):
    import wx.lib.dialogs
    import traceback
    from modules import common

    eid = event.GetId()
    index = win.scriptmenu_ids.index(eid)
    filename = win.pref.scripts[index][1]

    try:
        scripttext = open(common.encode_path(filename), 'rU').read()
    except:
        common.showerror(win, tr("Can't open the file %s.") % filename)
        return

    try:
        code = compile((scripttext + '\n'), common.encode_path(filename),
                       'exec')
    except:
        d = wx.lib.dialogs.ScrolledMessageDialog(
            win, (tr("Error compiling script.\n\nTraceback:\n\n") +
                  ''.join(traceback.format_exception(*sys.exc_info()))),
            tr("Error"), wx.DefaultPosition, wx.Size(400, 300))
        d.ShowModal()
        d.Destroy()
        return

    try:
        namespace = locals()
        exec code in namespace
    except:
        d = wx.lib.dialogs.ScrolledMessageDialog(
            win, (tr("Error running script.\n\nTraceback:\n\n") +
                  ''.join(traceback.format_exception(*sys.exc_info()))),
            tr("Error"), wx.DefaultPosition, wx.Size(400, 300))
        d.ShowModal()
        d.Destroy()
        return
Пример #3
0
def playmusic(win):
    win.isloop=True
    win.playingid=win.selectedid
    while win.isloop:
        if len(win.m3u.data)==0:
            return
        if win.playingid!=-1:
            if win.playingid>=len(win.m3u.data):
                win.playingid=0
        else:
            return
        try:
            win.playing=win.m3u.data[win.playingid]
        except:
            return
        try:
            win.musiclist.setplaying(win.playing['Author-Title'])
        except:
            pass
        try:
            win.src=pySonic.Source()
            filename=win.playing['Path']
            filename = common.encode_path(filename)
            win.src.Sound = pySonic.FileStream(filename, 0)
            win.src.Play()
        except:
            dlg = wx.MessageDialog(win, tr('Can\'t play!'),
                               tr('Error'),
                               wx.OK | wx.ICON_ERROR
                               )
            dlg.ShowModal()
            dlg.Destroy()
            return
        while win.src.IsPlaying():
            if win.src.IsPaused():
                if not win.flag_pause:
                    win.src.Play()
                    continue
            else:
                if win.flag_pause:
                    win.src.Pause()
                    continue
            time.sleep(0.4)
        if win.isloop:
            win.playingid=win.playingid+1
        time.sleep(0.2)
Пример #4
0
def playmusic(win):
    win.isloop = True
    win.playingid = win.selectedid
    while win.isloop:
        if len(win.m3u.data) == 0:
            return
        if win.playingid != -1:
            if win.playingid >= len(win.m3u.data):
                win.playingid = 0
        else:
            return
        try:
            win.playing = win.m3u.data[win.playingid]
        except:
            return
        try:
            win.musiclist.setplaying(win.playing['Author-Title'])
        except:
            pass
        try:
            win.src = pySonic.Source()
            filename = win.playing['Path']
            filename = common.encode_path(filename)
            win.src.Sound = pySonic.FileStream(filename, 0)
            win.src.Play()
        except:
            dlg = wx.MessageDialog(win, tr('Can\'t play!'), tr('Error'),
                                   wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return
        while win.src.IsPlaying():
            if win.src.IsPaused():
                if not win.flag_pause:
                    win.src.Play()
                    continue
            else:
                if win.flag_pause:
                    win.src.Pause()
                    continue
            time.sleep(0.4)
        if win.isloop:
            win.playingid = win.playingid + 1
        time.sleep(0.2)