# -*- coding: UTF-8 -*-

# -*- coding: ISO-8859-1 -*-

#
""" capellaScript -- Copyright (c) 2004 Hartmut Ring
>>> Braille-View Optionen

    Dieses Skript erlaubt, die Ausgabe von Braille-View|
    zu konfigurieren: Vorlesen oder Braillezeile
<<<
"""

"""
"""

class ScriptOptions (object):
    def __init__(self):
        dir, file = os.path.split(sys.argv[0])
        fileName = 'braille-view.opt'
        self._optionsFile = os.path.join(dir, fileName)

    def get(self):
        opt = dict()
        try:
            f = file(self._optionsFile)
            l = f.readlines()
            f.close()
            for x in l:
                a = [s.strip() for s in x.split('=')] 
                if len(a) == 2:
                    opt[a[0]] = a[1]
        except: pass
        return opt

    def set(self, d):
        f = file(self._optionsFile, 'w')
        for i in d:
            f.write('%s = %s\n' % (i, str(d[i])))
        f.flush()            
        f.close()

options = ScriptOptions()
opt = options.get()     # opt = dict()

helptext='Die Notenbezeichnungen der ganzen Stimme können in Braille-Codierung oder in \
Schwarzschriftdarstellung ausgegeben werden. Die Option Vorlesbar ist zum Vorlesen durch \
einen Screenreader optimiert. Die Option Schwarzschrift dient hauptsächlich der \
Skript-Weiterentwicklung.'
def optionsDlg():
    optionslist = ['Braille', 'Schwarzschrift', 'Vorlesbar']
    if opt.has_key('OutputStyle'):
        val = optionslist.index(opt['OutputStyle'])
    else:
        val = 0    
    styleRadio = Radio(optionslist, value=val)
    dlg = Dialog('Braille-Optionen', styleRadio, help=helptext)
    if dlg.run():
        opt['OutputStyle'] = optionslist[styleRadio.value()]
        options.set(opt)

optionsDlg()

