Beispiel #1
0
 def ReadItachFunctionTranslation(self) -> None:
     """ Reads the translation set from IRDB to ORCA """
     oSet: Element
     oCommand: Element
     if len(self.dTranslations) == 0:
         oFnTranslation: cFileName = cFileName(
             Globals.oPathResources +
             u"irdbtranslation") + u"itach2orca.xml"
         try:
             Logger.debug(u'IRDB: Loading Translation Table:' +
                          oFnTranslation.string)
             oET_Root: Element = LoadXMLFile(oFile=oFnTranslation)
             #oSets=oET_Root.findall('set')
             for oSet in oET_Root:
                 for oCommand in oSet.findall('action'):
                     uFrom: str = GetXMLTextAttribute(oXMLNode=oCommand,
                                                      uTag=u'from',
                                                      bMandatory=True,
                                                      vDefault='')
                     uTo: str = GetXMLTextAttribute(oXMLNode=oCommand,
                                                    uTag=u'to',
                                                    bMandatory=True,
                                                    vDefault='')
                     self.dTranslations[uFrom] = uTo
         except ParseError as e:
             ShowErrorPopUp(uMessage=LogError(
                 uMsg=u'IRDB: Error:Loading Translations file',
                 oException=e))
Beispiel #2
0
    def ConvertItach2CCF(self) -> None:
        #todo : remove when we know, it is not used anymore
        oXMLCode: Element
        uFile: str
        uCmd: str
        uRepeat: str
        uFileName: str
        uFinal: str
        aFiles: List[str] = Globals.oPathCodesets.GetFolderList()
        aFiles2: List[str] = []
        for uFile in aFiles:
            if uFile.startswith("CODESET_iTach_"):
                aFiles2.append(uFile)

        for uFile in aFiles2:
            oFile: cFileName = cFileName(Globals.oPathCodesets) + uFile
            oXMLCodeset: Element = LoadXMLFile(oFile=oFile)
            oXMLCodes: List[Element] = oXMLCodeset.findall('code')
            for oXMLCode in oXMLCodes:
                uCmd = GetXMLTextAttribute(oXMLNode=oXMLCode,
                                           uTag="cmd",
                                           bMandatory=False,
                                           vDefault="")
                if uCmd.startswith("sendir,"):
                    uRepeat, uCmd = ITach2CCF(uCmd)
                    oXMLCode.set("cmd_ccf", uCmd)
                    oXMLCode.set("repeatcount", uRepeat)
                    del oXMLCode.attrib["cmd"]
            uFileName = oFile.string.replace("_iTach_", "_infrared_ccf_")
            uFinal = ToUnicode(XMLPrettify(oElem=oXMLCodeset))
            uFinal = uFinal.replace(u'<?xml version="1.0"?>',
                                    u'<?xml version="1.0" encoding="UTF-8"?>')
            with codecs.open(uFileName, 'w', 'utf-8') as oOutfile:
                oOutfile.write(uFinal)
Beispiel #3
0
 def ParseIconsFromXMLNode(self, *, oXMLNode: Element) -> None:
     """
     Parses all icon definitions from the xml objects
     """
     oXMLIcons: Element = oXMLNode.find('icons')
     if oXMLIcons is not None:
         Logger.info(u'Loading Icons')
         for oXMLIcon in oXMLIcons.findall('icon'):
             uIconName: str = GetXMLTextAttribute(oXMLNode=oXMLIcon,
                                                  uTag=u'name',
                                                  bMandatory=True,
                                                  vDefault=u'')
             oFnIconFont: cFileName = cFileName("").ImportFullPath(
                 uFnFullName=GetXMLTextAttribute(oXMLNode=oXMLIcon,
                                                 uTag=u'font',
                                                 bMandatory=True,
                                                 vDefault=u''))
             uIconChar: str = GetXMLTextAttribute(oXMLNode=oXMLIcon,
                                                  uTag=u'char',
                                                  bMandatory=True,
                                                  vDefault=u'')
             uFontName: str = oFnIconFont.basename
             fIconScale: float = GetXMLFloatAttribute(oXMLNode=oXMLIcon,
                                                      uTag=u'scale',
                                                      bMandatory=False,
                                                      fDefault=1.0)
             Globals.dIcons[uIconName] = {
                 "fontfile": oFnIconFont.string,
                 "char": uIconChar,
                 "fontname": uFontName,
                 "scale": fIconScale
             }
             Globals.oTheScreen.oFonts.ParseDirect(
                 uFontName=uFontName, uFontFileNormal=oFnIconFont.string)
Beispiel #4
0
    def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor):
        """ Reads further Widget attributes from a xml node """
        bRet = self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor)
        if bRet:
            self.oFnPictureNormal = cFileName(u'').ImportFullPath(
                GetXMLTextAttributeVar(oXMLNode, u'picturenormal', False, u''))
            self.oFnPictureButton = cFileName(u'').ImportFullPath(
                GetXMLTextAttributeVar(oXMLNode, u'picturebutton', False, u''))

            self.fMin = GetXMLTextAttribute(oXMLNode, u'mindatavalue', False,
                                            u'0.0')
            self.fMax = GetXMLTextAttribute(oXMLNode, u'maxdatavalue', False,
                                            u'100.0')
            self.uDestVar = GetXMLTextAttribute(oXMLNode, u'destvar', False,
                                                self.uDestVar)
            #roundpos: the position, the  number should be rounded
            self.iRoundPos = GetXMLIntAttribute(oXMLNode, u'roundpos', False,
                                                0)
            self.uDeviceOrientation = GetXMLTextAttribute(
                oXMLNode, u'orientation', False, self.uDeviceOrientation)
            self.bDiscardMoves = GetXMLBoolAttributeVar(
                oXMLNode, u'discardmoves', False, False)
            self.fValue = self.fMin

        return bRet
Beispiel #5
0
    def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor):

        uCaption = GetXMLTextAttribute(oXMLNode, "caption", False, "")

        bRet = super(cWidgetDropDown,
                     self).InitWidgetFromXml(oXMLNode, oParentScreenPage,
                                             uAnchor)
        oXMLNode.set("caption", uCaption)

        if bRet:
            self.tFrameColor = GetColorFromHex(
                GetXMLTextAttribute(oXMLNode, u'framecolor', False,
                                    u'$var(dimmed)'))
            self.iFrameWidth = GetXMLIntAttribute(
                oXMLNode, u'framewidth', False,
                self.oDef.iDefMaxX / self.fRationX) * 0.02
            self.aCaptions = GetXMLTextAttribute(oXMLNode, u'captions', False,
                                                 u'unknown').split(u',')

            self.aActionNames = GetXMLTextAttribute(oXMLNode, u'actions',
                                                    False, u'').split(u',')
            self.aOrgActionNames = copy(self.aActionNames)
            self.bSorted = GetXMLBoolAttribute(oXMLNode, u'sorted', False,
                                               False)
            self.oXMLNode = oXMLNode

            # this is a little bit tricky
            # we should parse all dropdown button here as well, but then,
            # updatewidget for the dropdown would not work
            # so we do it in create, but at that time, the dimensions of the achor is losr
            # so, we need to save the anchor dimensions here
            self.iTmpAnchorWidth = self.oTmpAnchor.iWidth
            self.iTmpAnchorHeight = self.oTmpAnchor.iHeight

        return bRet
Beispiel #6
0
    def ConvertItach2CCF(self):
        #todo : remove when we know, it is not used anymore
        from ORCA.utils.XML import GetXMLTextAttribute
        import codecs
        aFiles = Globals.oPathCodesets.GetFolderList()
        aFiles2 = []
        for uFile in aFiles:
            if uFile.startswith("CODESET_iTach_"):
                aFiles2.append(uFile)

        for uFile in aFiles2:
            oFile = cFileName(Globals.oPathCodesets) + uFile
            oXMLCodeset = ElementTree(file=oFile.string).getroot()
            oXMLCodes = oXMLCodeset.findall('code')
            for oXMLCode in oXMLCodes:
                uCmd = GetXMLTextAttribute(oXMLCode, "cmd", False, "")
                if uCmd.startswith("sendir,"):
                    uRepeat, uCmd = ITach2CCF(uCmd)
                    oXMLCode.set("cmd_ccf", uCmd)
                    oXMLCode.set("repeatcount", uRepeat)
                    del oXMLCode.attrib["cmd"]
            uFileName = oFile.string.replace("_iTach_", "_infrared_ccf_")
            uFinal = ToUnicode(XMLPrettify(oXMLCodeset))
            uFinal = uFinal.replace(u'<?xml version="1.0"?>',
                                    u'<?xml version="1.0" encoding="UTF-8"?>')
            with codecs.open(uFileName, 'w', 'utf-8') as outfile:
                outfile.write(uFinal)
Beispiel #7
0
    def LoadSoundsDescription(self) -> None:
        """ Loads the sound description (tunes) """
        try:
            Logger.debug(u'TheScreen: Loading Sounds')
            oET_Root: Element = LoadXMLFile(oFile=Globals.oFnSoundsXml)

            if oET_Root is not None:
                for oXMLSound in oET_Root.findall('sound'):
                    uSoundName: str = GetXMLTextAttribute(oXMLNode=oXMLSound,
                                                          uTag=u'name',
                                                          bMandatory=False,
                                                          vDefault=u'')
                    oFnSound: cFileName = cFileName('').ImportFullPath(
                        uFnFullName=GetXMLTextAttribute(oXMLNode=oXMLSound,
                                                        uTag=u'file',
                                                        bMandatory=False,
                                                        vDefault=u''))
                    if uSoundName in self.aSounds:
                        self.aSounds[uSoundName]["oFnSound"] = oFnSound
                    else:
                        Logger.warning(u'Unknown Sound:' + oFnSound)
        except Exception as e:
            ShowErrorPopUp(uMessage=LogError(
                uMsg=
                u'TheScreen:  LoadSoundDescription: can\'t load SoundDescription',
                oException=e))
Beispiel #8
0
    def _ReadCodeset(self, uFN):
        del self.aCodesetCmds[:]
        try:
            oXMLCodeset = LoadXMLFile(cFileName(Globals.oPathCodesets) + uFN)
            Orca_include(oXMLCodeset, orca_et_loader)
            if oXMLCodeset is not None:
                # First read imported codesets
                oXMLImports = oXMLCodeset.find('imports')
                if oXMLImports is not None:
                    oXMLImportCodesets = oXMLImports.find('codeset')
                    if oXMLImportCodesets is not None:
                        oXMLImportCodes = oXMLImportCodesets.findall('code')
                        for oXMLCode in oXMLImportCodes:
                            uCmd = GetXMLTextAttribute(oXMLCode, 'action',
                                                       False, '')
                            if uCmd:
                                self.aCodesetCmds.append(uCmd)

                oXMLCodes = oXMLCodeset.findall('code')
                for oXMLCode in oXMLCodes:
                    uCmd = GetXMLTextAttribute(oXMLCode, 'action', False, '')
                    if uCmd:
                        self.aCodesetCmds.append(uCmd)

        except Exception as e:
            LogError('Error Reading Codeset', e)
Beispiel #9
0
    def InitWidgetFromXml(self, *, oXMLNode: Element,
                          oParentScreenPage: cScreenPage,
                          uAnchor: str) -> bool:
        """ Reads further Widget attributes from a xml node """
        bRet: bool = self.ParseXMLBaseNode(oXMLNode, oParentScreenPage,
                                           uAnchor)
        if bRet:
            self.SetPictureNormal(
                GetXMLTextAttribute(oXMLNode=oXMLNode,
                                    uTag=u'picturenormal',
                                    bMandatory=False,
                                    vDefault=u''))
            self.SetPicturePressed(
                GetXMLTextAttribute(oXMLNode=oXMLNode,
                                    uTag=u'picturepressed',
                                    bMandatory=False,
                                    vDefault=u''))
            #self.SetPictureDisabled (GetXMLTextAttribute(oXMLNode,u'picturedisabled',    False,u''))
            self.bAutoHide = GetXMLBoolAttribute(oXMLNode=oXMLNode,
                                                 uTag=u'autohide',
                                                 bMandatory=False,
                                                 bDefault=False)

            if self.bAutoHide:
                if self.uCaption == u'':
                    self.EnableWidget(bEnable=False)
            if not self.oFnButtonPictureNormal.string.rfind('*') == -1:
                if self.oFnButtonPicturePressed.IsEmpty():
                    self.oFnButtonPicturePressed.ImportFullPath(
                        uFnFullName=self.oFnButtonPictureNormal.string.replace(
                            u'*', u' pressed'))
                self.oFnButtonPictureNormal.ImportFullPath(
                    uFnFullName=self.oFnButtonPictureNormal.string.replace(
                        u'*', u' normal'))
        return bRet
Beispiel #10
0
    def InitWidgetFromXml(self,*,oXMLNode:Element,oParentScreenPage:cScreenPage, uAnchor:str) -> bool:

        uCaption:str = GetXMLTextAttribute(oXMLNode=oXMLNode,uTag="caption",bMandatory=False,vDefault="")
        bRet:bool    = super().InitWidgetFromXml(oXMLNode=oXMLNode,oParentScreenPage=oParentScreenPage, uAnchor=uAnchor)
        bDummy:bool

        oXMLNode.set("caption", uCaption)

        if bRet:
            self.aFrameColor        = GetColorFromHex(GetXMLTextAttribute(oXMLNode=oXMLNode,uTag=u'framecolor',bMandatory=False,vDefault=u'$var(dimmed)'))
            # uFramewidth:str         = GetXMLTextAttribute(oXMLNode=oXMLNode,uTag=u'framewidth',  bMandatory=False,vDefault=str(int((self.oDef.iDefMaxX/self.fRationX)*0.03)))
            uFramewidth:str         = GetXMLTextAttribute(oXMLNode=oXMLNode,uTag=u'framewidth',  bMandatory=False,vDefault=str(int((self.oDef.iDefMaxX/self.fRationX)*0.05)))
            self.iFrameWidth,bDummy = self.CalculateWidth(uWidth=uFramewidth,iAnchorWidth=self.iWidth)
            self.iFrameWidth        = self.iFrameWidth / self.fRationX
            self.aCaptions          = GetXMLTextAttribute(oXMLNode=oXMLNode,uTag=u'captions', bMandatory=False,vDefault=u'unknown').split(u',')
            self.aActionNames       = GetXMLTextAttribute(oXMLNode=oXMLNode,uTag=u'actions',  bMandatory=False,vDefault=u'').split(u',')
            self.aOrgActionNames    = copy(self.aActionNames)
            self.bSorted            = GetXMLBoolAttribute(oXMLNode=oXMLNode,uTag=u'sorted',   bMandatory=False,bDefault=False)
            self.bSetCaption        = GetXMLBoolAttribute(oXMLNode=oXMLNode,uTag=u'setcaption', bMandatory=False,bDefault=False)
            self.oXMLNode           = oXMLNode

            # this is a little bit tricky
            # we should parse all dropdown button here as well, but then,
            # updatewidget for the dropdown would not work
            # so we do it in create, but at that time, the dimensions of the anchor is lost
            # so, we need to save the anchor dimensions here
            self.iTmpAnchorWidth = self.oTmpAnchor.iWidth
            self.iTmpAnchorHeight = self.oTmpAnchor.iHeight
        return bRet
Beispiel #11
0
    def _ReadCodeset(self, uFN: str) -> None:

        oXMLCode: Element
        uCmd: str
        del self.aCodesetCmds[:]
        try:
            oXMLCodeset: Element = LoadXMLFile(
                oFile=cFileName(Globals.oPathCodesets) + uFN)
            Orca_include(oXMLCodeset, orca_et_loader)
            if oXMLCodeset is not None:
                # First read imported codesets
                oXMLImports: Element = oXMLCodeset.find('imports')
                if oXMLImports is not None:
                    oXMLImportCodesets: Element = oXMLImports.find('codeset')
                    if oXMLImportCodesets is not None:
                        for oXMLCode in oXMLImportCodesets.findall('code'):
                            uCmd = GetXMLTextAttribute(oXMLNode=oXMLCode,
                                                       uTag='action',
                                                       bMandatory=False,
                                                       vDefault='')
                            if uCmd:
                                self.aCodesetCmds.append(uCmd)

                for oXMLCode in oXMLCodeset.findall('code'):
                    uCmd = GetXMLTextAttribute(oXMLNode=oXMLCode,
                                               uTag='action',
                                               bMandatory=False,
                                               vDefault='')
                    if uCmd:
                        self.aCodesetCmds.append(uCmd)

        except Exception as e:
            LogError(uMsg='Error Reading Codeset', oException=e)
Beispiel #12
0
    def LoadActionsSub(self,
                       oET_Root,
                       uSegmentTag,
                       uListTag,
                       aTargetDic,
                       uFileName=u''):
        """
            replaceoptions
            * appendtoexisting
            * replaceexisting = replace current action
            * renameexisting = rename original actions if exist
            * renamemeifexist = rename this action
        """

        try:

            if uSegmentTag:
                oET_SegmentsStart = oET_Root.find(uSegmentTag)
            else:
                oET_SegmentsStart = oET_Root

            if oET_SegmentsStart is not None:
                for oET_Includes in oET_SegmentsStart:
                    if oET_Includes.tag == u'includes':
                        self.LoadActionsSub(oET_Includes, None, uListTag,
                                            aTargetDic, uFileName)
                    elif oET_Includes.tag == uListTag:
                        uName = GetXMLTextAttribute(oET_Includes, 'name', True,
                                                    u'')
                        uReplaceOption = GetXMLTextAttribute(
                            oET_Includes, 'replaceoption', False,
                            u'appendtoexisting')

                        uNewname = GetXMLTextAttribute(oET_Includes, 'newname',
                                                       False, u'')
                        aActions = []
                        bOldExist = True
                        aActionsOrg = aTargetDic.get(uName)
                        if aActionsOrg is None:
                            aActionsOrg = []
                            bOldExist = False

                        if uReplaceOption == 'appendtoexisting':
                            aActions = aActionsOrg

                        if uReplaceOption == 'renameexisting' and bOldExist:
                            aTargetDic[uNewname] = aActionsOrg

                        if uReplaceOption == 'renamemeifexist' and bOldExist:
                            uName = uNewname

                        self.__ParseXMLActions(oET_Includes, aActions)
                        aTargetDic[uName] = aActions

        except Exception as e:
            uMsg = LogError(u'TheScreen: Fatal Error:Load Action XmlFile:', e)
            ShowErrorPopUp(uTitle="Fatal Error", uMessage=uMsg, bAbort=True)
Beispiel #13
0
 def InitWidgetFromXml(self,oXMLNode,oParentScreenPage, uAnchor):
     """ Reads further Widget attributes from a xml node """
     bRet=super(cWidgetSwitch, self).InitWidgetFromXml(oXMLNode,oParentScreenPage, uAnchor)
     self.uDestVar          = GetXMLTextAttribute(oXMLNode,u'destvar',    False,self.uName+'_switchstate')
     self.uGroup            = GetXMLTextAttribute(oXMLNode,u'group',      False,'')
     self.oFnButtonPictureNormalOrg        = cFileName(self.oFnButtonPictureNormal)
     self.oFnButtonPicturePressedOrg       = cFileName(self.oFnButtonPicturePressed)
     if GetVar(uVarName = self.uDestVar)=='1':
         self.oFnButtonPictureNormal,self.oFnButtonPicturePressed=self.oFnButtonPicturePressed,self.oFnButtonPictureNormal
     return bRet
Beispiel #14
0
 def ParseXMLLocales(self,oXMLLocales):
     """ reads the locales information from the xml (kodi file) """
     self.uName      = GetXMLTextAttribute(oXMLLocales,u'name',True,u'')
     self.uLocale    = GetXMLTextAttribute(oXMLLocales,u'locale',False,u'EN')
     self.uDateShort = GetXMLTextValue(oXMLLocales,u'dateshort',False,u'DD.MM.YYYY')
     self.uDateLong  = GetXMLTextValue(oXMLLocales,u'datelong',False,u'DDDD, D MMMM YYYY')
     self.uTimeFormat= GetXMLTextValue(oXMLLocales,u'time',False,u'H:mm:ss')
     oXMLTime=oXMLLocales.find('time')
     if oXMLTime is not None:
         self.uTimeSymbolAM=GetXMLTextAttribute(oXMLTime,u'symbolAM',False,u'')
         self.uTimeSymbolPM=GetXMLTextAttribute(oXMLTime,u'symbolPM',False,u'')
Beispiel #15
0
 def __AddSettingDefaults(self, *, oXMLSetting: Element) -> None:
     uVar: str = GetXMLTextAttribute(oXMLNode=oXMLSetting,
                                     uTag=u'var',
                                     bMandatory=True,
                                     vDefault=u'NoVar')
     uDefault: str = GetXMLTextAttribute(oXMLNode=oXMLSetting,
                                         uTag=u'default',
                                         bMandatory=True,
                                         vDefault=u'')
     #Logger.debug( "setdefault: Definition:%s Var:%s  Default:%s" % (self.uAlias,uVar,uDefault))
     self.oDefinitions.dSettingsDefaults[uVar] = uDefault
Beispiel #16
0
 def InitInterFaceSettings(self, *, oXMLRoot: Element) -> None:
     """ sub routine to recursive load setups """
     oXMLInterfaceSetup: Element
     oConfiguration: Element
     oSetting: Element
     oXMLInterfaceSetupTag: Element = oXMLRoot.find('interface_setup')
     if oXMLInterfaceSetupTag is not None:
         aXMLInterfaceSetups: List[Element] = oXMLInterfaceSetupTag.findall(
             'interface')
         for oXMLInterfaceSetup in aXMLInterfaceSetups:
             uInterFaceName: str = GetXMLTextAttribute(
                 oXMLNode=oXMLInterfaceSetup,
                 uTag='name',
                 bMandatory=True,
                 vDefault=u'')
             if self.oDefinitions.dInitInterfaceSettings.get(
                     uInterFaceName) is None:
                 self.oDefinitions.dInitInterfaceSettings[
                     uInterFaceName] = {}
             aConfigurations: List[Element] = oXMLInterfaceSetup.findall(
                 'configuration')
             for oConfiguration in aConfigurations:
                 uConfigurationName: str = GetXMLTextAttribute(
                     oXMLNode=oConfiguration,
                     uTag='name',
                     bMandatory=True,
                     vDefault=u'')
                 if self.oDefinitions.dInitInterfaceSettings[
                         uInterFaceName].get(uConfigurationName) is None:
                     self.oDefinitions.dInitInterfaceSettings[
                         uInterFaceName][uConfigurationName] = {}
                 oSettings: List[Element] = oConfiguration.findall(
                     'setting')
                 for oSetting in oSettings:
                     uSettingName: str = GetXMLTextAttribute(
                         oXMLNode=oSetting,
                         uTag='name',
                         bMandatory=True,
                         vDefault=u'')
                     uSettingParameter: str = GetXMLTextAttribute(
                         oXMLNode=oSetting,
                         uTag='parameter',
                         bMandatory=True,
                         vDefault=u'')
                     self.oDefinitions.dInitInterfaceSettings[
                         uInterFaceName][uConfigurationName][
                             uSettingName.upper()] = uSettingParameter
         self.InitInterFaceSettings(oXMLRoot=oXMLInterfaceSetupTag)
Beispiel #17
0
    def ParseFontFromXMLNode(self, *, oXMLNode: Element) -> int:
        """
        Parses a font definition from an xml node

        :return: The Number of fonts, defined in the XML
        :param oXMLNode: An elementree xml node
        """

        uFontStyle: str
        self.uName = GetXMLTextValue(oXMLNode=oXMLNode,
                                     uTag=u'name',
                                     bMandatory=True,
                                     vDefault=u'NoName')
        iCount: int = 0
        for oXMLSingleFont in oXMLNode.findall(u'file'):
            iCount += 1
            uFontStyle = GetXMLTextAttribute(oXMLNode=oXMLSingleFont,
                                             uTag=u'face',
                                             bMandatory=True,
                                             vDefault=u'')
            if uFontStyle == u'normal':
                self.oFnNormal.ImportFullPath(uFnFullName=oXMLSingleFont.text)
            elif uFontStyle == u'bold':
                self.oFnBold.ImportFullPath(uFnFullName=oXMLSingleFont.text)
            elif uFontStyle == u'italic':
                self.oFnItalic.ImportFullPath(uFnFullName=oXMLSingleFont.text)
            elif uFontStyle == u'bolditalic':
                self.oFnBoldItalic.ImportFullPath(
                    uFnFullName=oXMLSingleFont.text)
            else:
                ShowErrorPopUp(uMessage=LogError(
                    uMsg=u'FontParser: Invalid Tag:' + uFontStyle))
        return iCount
Beispiel #18
0
 def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor):
     """ Reads further Widget attributes from a xml node """
     bRet = self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor)
     if bRet:
         self.oFnPictureNormal = cFileName("").ImportFullPath(
             GetXMLTextAttributeVar(oXMLNode, u'picturenormal', False, u''))
         self.fMin = GetXMLFloatAttributeVar(oXMLNode, u'mindatavalue',
                                             False, u'0')
         self.fMax = GetXMLFloatAttributeVar(oXMLNode, u'maxdatavalue',
                                             False, u'100')
         self.iLeftBoundaryAngle = GetXMLIntAttributeVar(
             oXMLNode, u'leftboundaryangle', False, u'0')
         self.iRightBoundaryAngle = GetXMLIntAttributeVar(
             oXMLNode, u'rightboundaryangle', False, u'0')
         self.uDestVar = GetXMLTextAttribute(oXMLNode, u'destvar', False,
                                             u'knob')
         self.bDiscardMoves = GetXMLBoolAttributeVar(
             oXMLNode, u'discardmoves', False, False)
         #roundpos: the position, the  number should be rounded
         self.iRoundPos = GetXMLIntAttribute(oXMLNode, u'roundpos', False,
                                             0)
         self.fValue = 0.0
         self.fOldValue = 10000.23445
         self.iAbsAngle = 0
     return bRet
Beispiel #19
0
    def ParseFontFromXMLNode(self, oXMLFont):
        """
        Parses a font definition from an xml node

        :rtype: int
        :return: The Number of fonts, defined in the XML
        :param Element oXMLFont: An elementree xml node
        """
        self.uName = GetXMLTextValue(oXMLFont, u'name', True, u'NoName')
        iCount = 0
        for oXMLSingleFont in oXMLFont.findall(u'file'):
            iCount = iCount + 1
            uFontStyle = GetXMLTextAttribute(oXMLSingleFont, u'face', True,
                                             u'')
            if uFontStyle == u'normal':
                self.oFnNormal.ImportFullPath(oXMLSingleFont.text)
            elif uFontStyle == u'bold':
                self.oFnBold.ImportFullPath(oXMLSingleFont.text)
            elif uFontStyle == u'italic':
                self.oFnItalic.ImportFullPath(oXMLSingleFont.text)
            elif uFontStyle == u'bolditalic':
                self.oFnBoldItalic.ImportFullPath(oXMLSingleFont.text)
            else:
                uMsg = LogError(u'FontParser: Invalid Tag:' + uFontStyle)
                ShowErrorPopUp(uMessage=uMsg)
        return iCount
Beispiel #20
0
def LoadGesturesFromXML(oET_Root, uSegmentTag, uListTag):
    """
    Parses the gesture settings from a xml node

    :param Element oET_Root: An elementree object which holds the gesture definition
    :param string uSegmentTag: The segment name in the xml tree to start search
    :param string uListTag: The list name in the xml tree to find the gesture definition
    """

    try:
        oET_SegmentsStart = oET_Root.find(uSegmentTag)
        if oET_SegmentsStart is not None:
            oET_Includes = oET_SegmentsStart.findall('includes')
            if oET_Includes:
                for oET_Include in oET_Includes:
                    oET_Segments = oET_Include.findall(uListTag)
                    if oET_Segments:
                        for oET_Segment in oET_Segments:
                            uName = GetXMLTextAttribute(
                                oET_Segment, u'name', True, u'')
                            oGesture = cGesture()
                            oGesture.ParseGestureFromXMLNode(oET_Segment)
                            oGesture.oGesture = Globals.oTheScreen.oGdb.str_to_gesture(
                                oGesture.uGestureString)
                            oGesture.oGesture.Name = uName
                            Globals.oTheScreen.oGdb.add_gesture(
                                oGesture.oGesture)
                            Globals.oTheScreen.dGestures[uName] = oGesture
    except ParseError as e:
        uMsg = LogError(u'Fatal Error:Load Gesture XmlFile:', e)
        ShowErrorPopUp(uTitle="Fatal Error", uMessage=uMsg, bAbort=True)
Beispiel #21
0
    def InitWidgetFromXml(self,oXMLNode,oParentScreenPage, uAnchor):
        """ Reads further Widget attributes from a xml node """
        bRet=self.ParseXMLBaseNode(oXMLNode,oParentScreenPage , uAnchor)
        if bRet:
            self.SetPictureNormal   (GetXMLTextAttribute(oXMLNode,u'picturenormal',    False,u''))
            self.SetPicturePressed  (GetXMLTextAttribute(oXMLNode,u'picturepressed',    False,u''))
            #self.SetPictureDisabled (GetXMLTextAttribute(oXMLNode,u'picturedisabled',    False,u''))
            self.bAutoHide  = GetXMLBoolAttribute(oXMLNode,u'autohide',False,False)
            if self.bAutoHide:
                if self.uCaption == u'':
                    self.bEnabled = False
            if not self.oFnButtonPictureNormal.string.rfind('*')==-1:
                if self.oFnButtonPicturePressed.IsEmpty():
                    self.oFnButtonPicturePressed.ImportFullPath(self.oFnButtonPictureNormal.string.replace(u'*',u' pressed'))
                self.oFnButtonPictureNormal.ImportFullPath(self.oFnButtonPictureNormal.string.replace(u'*',u' normal'))

        return bRet
Beispiel #22
0
 def InitWidgetFromXml(self,*,oXMLNode:Element,oParentScreenPage:cScreenPage, uAnchor:str) -> bool:
     """ Reads further Widget attributes from a xml node """
     bRet:bool = super(cWidgetTextInput, self).InitWidgetFromXml(oXMLNode=oXMLNode,oParentScreenPage=oParentScreenPage, uAnchor=uAnchor)
     self.uDestVar = GetXMLTextAttribute(oXMLNode=oXMLNode,uTag=u'destvar', bMandatory=False,vDefault=u'inputstring')
     uTmp:str = GetVar(uVarName = self.uDestVar)
     if uTmp:
         self.uCaption=uTmp
     return bRet
Beispiel #23
0
 def ParseFromXMLNode(self, oXMLEntry):
     """ Parses an xms string into object vars """
     oXMLDescriptions = oXMLEntry.findall('description')
     for oXMLDescription in oXMLDescriptions:
         uLanguage = GetXMLTextAttribute(oXMLDescription, 'language', False,
                                         'English')
         self.aDescriptions[uLanguage] = GetXMLTextValue(
             oXMLDescription, '', False, '')
Beispiel #24
0
 def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor):
     """ Reads further Widget attributes from a xml node """
     self.oPathStart = cPath(GetVar(uVarName="filebrowserfile"))
     self.uActionNameCancel = GetXMLTextAttribute(oXMLNode, u'actioncancel',
                                                  False, u'')
     self.bDirSelect = GetXMLBoolAttribute(oXMLNode, u'dirselect', False,
                                           False)
     return self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor)
Beispiel #25
0
    def LoadSoundsDescription(self):
        """ Loads the sound description (tunes) """
        try:
            Logger.debug (u'TheScreen: Loading Sounds')
            oET_Root = LoadXMLFile(Globals.oFnSoundsXml)

            if oET_Root is not None:
                for oXMLSound in oET_Root.findall('sound'):
                    uSoundName  = GetXMLTextAttribute(oXMLSound,u'name',False,u'')
                    oFnSound  = cFileName('').ImportFullPath(GetXMLTextAttribute(oXMLSound,u'file',False,u''))
                    if uSoundName in self.aSounds:
                        self.aSounds[uSoundName][0]=oFnSound
                    else:
                        uMsg=Logger.warning(u'Unknown Sound:'+oFnSound)
        except Exception as e:
            uMsg=LogError(u'TheScreen:  LoadSoundDescription: can\'t load SoundDescription',e)
            ShowErrorPopUp(uMessage=uMsg)
Beispiel #26
0
 def InitWidgetFromXml(self, *, oXMLNode: Element,
                       oParentScreenPage: cScreenPage,
                       uAnchor: str) -> bool:
     """ Reads further Widget attributes from a xml node """
     bRet = self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor)
     if bRet:
         self.oFnPictureNormal = cFileName(u'').ImportFullPath(
             uFnFullName=GetXMLTextAttributeVar(oXMLNode=oXMLNode,
                                                uTag=u'picturenormal',
                                                bMandatory=False,
                                                uDefault=u''))
         self.oFnPictureButton = cFileName(u'').ImportFullPath(
             uFnFullName=GetXMLTextAttributeVar(oXMLNode=oXMLNode,
                                                uTag=u'picturebutton',
                                                bMandatory=False,
                                                uDefault=u''))
         self.uMin = GetXMLTextAttribute(oXMLNode=oXMLNode,
                                         uTag=u'mindatavalue',
                                         bMandatory=False,
                                         vDefault=u'0.0')
         self.uMax = GetXMLTextAttribute(oXMLNode=oXMLNode,
                                         uTag=u'maxdatavalue',
                                         bMandatory=False,
                                         vDefault=u'100.0')
         self.uDestVar = GetXMLTextAttribute(oXMLNode=oXMLNode,
                                             uTag=u'destvar',
                                             bMandatory=False,
                                             vDefault=self.uDestVar)
         self.iRoundPos = GetXMLIntAttribute(
             oXMLNode=oXMLNode,
             uTag=u'roundpos',
             bMandatory=False,
             iDefault=0
         )  #roundpos: the position, the  number should be rounded
         self.uDeviceOrientation = GetXMLTextAttribute(
             oXMLNode=oXMLNode,
             uTag=u'orientation',
             bMandatory=False,
             vDefault=self.uDeviceOrientation)
         self.bDiscardMoves = GetXMLBoolAttributeVar(oXMLNode=oXMLNode,
                                                     uTag=u'discardmoves',
                                                     bMandatory=False,
                                                     bDefault=False)
         self.fValue = self.fMin
     return bRet
Beispiel #27
0
 def GetWidgetTypeFromXmlNode(self, oXMLNode: Element) -> None:
     self.uTypeString = GetXMLTextAttribute(oXMLNode=oXMLNode,
                                            uTag=u'type',
                                            bMandatory=True,
                                            vDefault=u'')
     self.eWidgetType = dWidgetTypeToId.get(self.uTypeString,
                                            eWidgetType.ERROR)
     if not CheckCondition(oPar=oXMLNode):
         self.eWidgetType = eWidgetType.SkipWidget
Beispiel #28
0
 def InitWidgetFromXml(self, *, oXMLNode: Element,
                       oParentScreenPage: cScreenPage,
                       uAnchor: str) -> bool:
     """ Reads further Widget attributes from a xml node """
     self.uDestVar = GetXMLTextAttribute(oXMLNode=oXMLNode,
                                         uTag=u'destvar',
                                         bMandatory=False,
                                         vDefault=u'colorpicker')
     return self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor)
Beispiel #29
0
 def ParseIconsFromXMLNode(self, oET_Root):
     oXMLIcons = oET_Root.find('icons')
     if oXMLIcons is not None:
         Logger.info(u'Loading Icons')
         for oXMLIcon in oXMLIcons.findall('icon'):
             uIconName = GetXMLTextAttribute(oXMLIcon, u'name', True, u'')
             oFnIconFont = cFileName("").ImportFullPath(
                 GetXMLTextAttribute(oXMLIcon, u'font', True, u''))
             uIconChar = GetXMLTextAttribute(oXMLIcon, u'char', True, u'')
             uFontName = oFnIconFont.basename
             fIconScale = GetXMLFloatAttribute(oXMLIcon, u'scale', False, 1)
             Globals.dIcons[uIconName] = {
                 "fontfile": oFnIconFont.string,
                 "char": uIconChar,
                 "fontname": uFontName,
                 "scale": fIconScale
             }
             Globals.oTheScreen.oFonts.ParseDirect(
                 uFontName=uFontName, uFontFileNormal=oFnIconFont.string)
Beispiel #30
0
 def InitWidgetFromXml(self, oXMLNode, oParentScreenPage, uAnchor):
     self.uSettingsType = GetXMLTextAttribute(oXMLNode, u'settingstype',
                                              False, u'interface')
     self.bHasText = False
     self.oXMLNode = oXMLNode
     bRet = super(cWidgetSettings,
                  self).InitWidgetFromXml(oXMLNode, oParentScreenPage,
                                          uAnchor)
     if bRet:
         bRet = self.ParseXMLBaseNode(oXMLNode, oParentScreenPage, uAnchor)
     return bRet