def show_load(self, *largs): alargs = { 'select_string': ReplaceVars('$lvar(563)'), 'cancel_string': ReplaceVars('$lvar(5009)'), 'libraries_string': ReplaceVars('$lvar(5018)'), 'favorites_string': ReplaceVars('$lvar(5019)'), 'computer_string': ReplaceVars('$lvar(5020)'), 'location_string': ReplaceVars('$lvar(5021)'), 'listview_string': ReplaceVars('$lvar(5022)'), 'iconview_string': ReplaceVars('$lvar(5023)'), 'transition ': FadeTransition(), 'size_hint': (1, 1), 'favorites': [(Globals.oPathRoot.string, 'ORCA')], 'show_fileinput': False, 'show_filterinput': False, 'dirselect': False, 'path': Globals.oPathCodesets.string, 'filters': [ '*.xml', ] } #alargs['filters']= ['CODESET_iTach_*.xml',] #alargs['filters']= [self.MyFilter,] self.oContent = FileBrowser(**alargs) self.oContent.bind(on_success=self.load, on_canceled=self.dismiss_popup) self._popup = Popup(title=ReplaceVars("$lvar(5027)"), content=self.oContent, size_hint=(1, 1)) self._popup.open()
def _create_popup(self, instance): """ create popup layout """ content = BoxLayout(orientation='vertical', spacing=5) self.popup = popup = Popup(title=self.title, content=content, size_hint=(0.95, 0.95)) # create the filechooser uRoot, uName = split(self.value) uRoot = ReplaceVars(uRoot) self.textinput = textinput = FileBrowser(select_string = ReplaceVars('$lvar(563)'), \ cancel_string = ReplaceVars('$lvar(5009)'), \ libraries_string = ReplaceVars('$lvar(5018)'), \ favorites_string = ReplaceVars('$lvar(5019)'), \ computer_string = ReplaceVars('$lvar(5020)'), \ location_string = ReplaceVars('$lvar(5021)'), \ listview_string = ReplaceVars('$lvar(5022)'), \ iconview_string = ReplaceVars('$lvar(5023)'), \ path = uRoot, dirselect=False, \ transition = FadeTransition(), \ size_hint = (1, 1), \ favorites = [(Globals.oPathRoot.string, 'ORCA')], \ show_fileinput = False, \ show_filterinput = False \ ) # construct the content content.add_widget(textinput) textinput.bind(on_success=self._validate, on_canceled=self._dismiss) # all done, open the popup ! popup.open()
def show_load(self,*largs): alargs={} alargs['select_string']= ReplaceVars('$lvar(563)') alargs['cancel_string']= ReplaceVars('$lvar(5009)') alargs['libraries_string']= ReplaceVars('$lvar(5018)') alargs['favorites_string']= ReplaceVars('$lvar(5019)') alargs['computer_string']= ReplaceVars('$lvar(5020)') alargs['location_string']= ReplaceVars('$lvar(5021)') alargs['listview_string']= ReplaceVars('$lvar(5022)') alargs['iconview_string']= ReplaceVars('$lvar(5023)') alargs['transition ']= FadeTransition() alargs['size_hint']= (1, 1) alargs['favorites']= [(oORCA.uAppPath, 'ORCA')] alargs['show_fileinput']= False alargs['show_filterinput']= False alargs['dirselect']= False alargs['path']= oORCA.uCodesetsPath #alargs['filters']= ['CODESET_iTach_*.xml',] alargs['filters']= ['*.xml',] #alargs['filters']= [self.MyFilter,] self.oContent=FileBrowser(**alargs) self.oContent.bind(on_success=self.load,on_canceled=self.dismiss_popup) self._popup = Popup(title=ReplaceVars("$lvar(5027)"), content=self.oContent, size_hint=(1, 1)) self._popup.open()
class cITachToKeene(BoxLayout): def __init__(self, **kwargs): kwargs['orientation'] = 'vertical' super(cITachToKeene, self).__init__(**RemoveNoClassArgs(kwargs, BoxLayout)) self.uCodesetFileName = '' self.oLayoutHeaders = BoxLayout(size_hint_y=None, height=30) self.oLayoutButtons = BoxLayout(size_hint_y=None, height=30) self.oLayoutPanels = BoxLayout() self.add_widget(self.oLayoutHeaders) self.add_widget(SettingSpacer()) self.add_widget(self.oLayoutPanels) self.add_widget(SettingSpacer()) self.add_widget(self.oLayoutButtons) self.oTextInput = TextInput() self.oTextInput2 = TextInput() self.oLayoutPanels.add_widget(self.oTextInput) self.oLayoutPanels.add_widget(self.oTextInput2) self.oButtonLoad = Button(text=ReplaceVars('$lvar(563)')) self.oButtonSave = Button(text=ReplaceVars('$lvar(5025)')) self.oButtonLoad.bind(on_release=self.show_load) self.oButtonSave.bind(on_release=self.show_save) self.oLayoutButtons.add_widget(self.oButtonLoad) self.oLayoutButtons.add_widget(self.oButtonSave) self.oLabelITach = Label(text="ITach", halign='center') self.oLabelKeene = Label(text="Keene Kira", halign='center') self.oLayoutHeaders.add_widget(self.oLabelITach) self.oLayoutHeaders.add_widget(self.oLabelKeene) def show_load(self, *largs): alargs = { 'select_string': ReplaceVars('$lvar(563)'), 'cancel_string': ReplaceVars('$lvar(5009)'), 'libraries_string': ReplaceVars('$lvar(5018)'), 'favorites_string': ReplaceVars('$lvar(5019)'), 'computer_string': ReplaceVars('$lvar(5020)'), 'location_string': ReplaceVars('$lvar(5021)'), 'listview_string': ReplaceVars('$lvar(5022)'), 'iconview_string': ReplaceVars('$lvar(5023)'), 'transition ': FadeTransition(), 'size_hint': (1, 1), 'favorites': [(Globals.oPathRoot.string, 'ORCA')], 'show_fileinput': False, 'show_filterinput': False, 'dirselect': False, 'path': Globals.oPathCodesets.string, 'filters': [ '*.xml', ] } #alargs['filters']= ['CODESET_iTach_*.xml',] #alargs['filters']= [self.MyFilter,] self.oContent = FileBrowser(**alargs) self.oContent.bind(on_success=self.load, on_canceled=self.dismiss_popup) self._popup = Popup(title=ReplaceVars("$lvar(5027)"), content=self.oContent, size_hint=(1, 1)) self._popup.open() def MyFilter(self, uFolder, uFile): if "CODESET_iTach" in uFile: return True return False def dismiss_popup(self, *largs): self._popup.dismiss() def load(self, instance): if len(instance.selection) != 0: self.uCodesetFileName = instance.selection[0] try: self.oXMLCodeset = ElementTree() self.oXMLCodeset.parse(self.uCodesetFileName, CommentedTreeBuilder()) if self.oXMLCodeset is not None: self.oXMLRoot = self.oXMLCodeset.getroot() self.oTextInput.text = tostring(self.oXMLRoot) for oCode in self.oXMLRoot: sCmd = oCode.get('cmd') if sCmd is not None: oCode.set('cmd', GlobalCacheToKeene(sCmd)) self.AdjustRepManagerITachToKeene(self.oXMLRoot) self.oTextInput2.text = tostring(self.oXMLRoot) except ParseError as sErrMsg: sMsg = 'Error ' + str(sErrMsg) print(sMsg) except Exception as e: sMsg = 'Error ' + str(e) print(sMsg) self.dismiss_popup() def AdjustRepManagerITachToKeene(self, oXMLRoot): oXMLRepMgr = oXMLRoot.find("repositorymanager") if oXMLRepMgr is not None: oXMLRepMgrEntry = oXMLRepMgr.find("entry") if oXMLRepMgrEntry is not None: oXMLRepMgrDescriptions = oXMLRepMgrEntry.findall("description") if oXMLRepMgrDescriptions is not None: for oDes in oXMLRepMgrDescriptions: oDes.text = oDes.text.replace("iTach IR", "Keene Kira IR") oXMLRepMgrName = oXMLRepMgrEntry.find("name") if oXMLRepMgrName is not None: oXMLRepMgrName.text = oXMLRepMgrName.text.replace( "iTach", "Keene Kira") oXMLRepMgrDependencies = oXMLRepMgrEntry.findall( "dependencies") if oXMLRepMgrDependencies is not None: for oDep in oXMLRepMgrDependencies: oDEDep = oDep.find("dependency") if oDEDep is not None: oName = oDEDep.find("name") if oName is not None: oName.text = oName.text.replace( "iTach IR Control", "Keene Kira IR Control") oXMLRepMgSources = oXMLRepMgrEntry.findall("sources") if oXMLRepMgSources is not None: oXMLRepMgSource = oXMLRepMgSources.find("source") if oXMLRepMgSource is not None: for oSource in oXMLRepMgSource: oSource.text = oSource.text.replace( "_iTach_", "_Keene_Kira_") def AdjustRepManagerITachToCCF(self, oXMLRoot): oXMLRepMgr = oXMLRoot.find("repositorymanager") if oXMLRepMgr is not None: oXMLRepMgrEntry = oXMLRepMgr.find("entry") if oXMLRepMgrEntry is not None: oXMLRepMgrDescriptions = oXMLRepMgrEntry.findall("description") if oXMLRepMgrDescriptions is not None: for oDes in oXMLRepMgrDescriptions: oDes.text = oDes.text.replace("iTach IR", "CCF IR Codes") oXMLRepMgrName = oXMLRepMgrEntry.find("name") if oXMLRepMgrName is not None: oXMLRepMgrName.text = oXMLRepMgrName.text.replace( "iTach", "CCF IR Codes") oXMLRepMgrDependencies = oXMLRepMgrEntry.findall( "dependencies") if oXMLRepMgrDependencies is not None: for oDep in oXMLRepMgrDependencies: oDEDep = oDep.find("dependency") if oDEDep is not None: oName = oDEDep.find("name") if oName is not None: oName.text = oName.text.replace( "iTach IR Control", "CCF IR Codes") oXMLRepMgSources = oXMLRepMgrEntry.findall("sources") if oXMLRepMgSources is not None: oXMLRepMgSource = oXMLRepMgSources.find("source") if oXMLRepMgSource is not None: for oSource in oXMLRepMgSource: oSource.text = oSource.text.replace( "_iTach_", "_infrared_ccf_") def show_save(self, *largs): if self.oTextInput2.text != "": sOutput = self.uCodesetFileName + "3" sOutput = sOutput.replace("_iTach_", "_Keene_Kira_") self.oXMLCodeset.write( sOutput, encoding="UTF-8", xml_declaration='<?xml version="1.0" encoding="UTF-8"?>') self.oTextInput.text = "" self.oTextInput2.text = ""
class cITachToKeene(BoxLayout): def __init__(self, **kwargs): kwargs['orientation'] = 'vertical' super(cITachToKeene, self).__init__( **RemoveNoClassArgs(dInArgs=kwargs, oObject=BoxLayout)) self.uCodesetFileName: str = '' self.oLayoutHeaders: BoxLayout = BoxLayout(size_hint_y=None, height=30) self.oLayoutButtons: BoxLayout = BoxLayout(size_hint_y=None, height=30) self.oLayoutPanels: BoxLayout = BoxLayout() self.add_widget(self.oLayoutHeaders) self.add_widget(SettingSpacer()) self.add_widget(self.oLayoutPanels) self.add_widget(SettingSpacer()) self.add_widget(self.oLayoutButtons) self.oTextInput: TextInput = TextInput() self.oTextInput2: TextInput = TextInput() self.oLayoutPanels.add_widget(self.oTextInput) self.oLayoutPanels.add_widget(self.oTextInput2) self.oButtonLoad: Button = Button(text=ReplaceVars('$lvar(563)')) self.oButtonSave: Button = Button(text=ReplaceVars('$lvar(5025)')) self.oButtonLoad.bind(on_release=self.show_load) self.oButtonSave.bind(on_release=self.show_save) self.oLayoutButtons.add_widget(self.oButtonLoad) self.oLayoutButtons.add_widget(self.oButtonSave) self.oLabelITach: Label = Label(text="ITach", halign='center') self.oLabelKeene: Label = Label(text="Keene Kira", halign='center') self.oLayoutHeaders.add_widget(self.oLabelITach) self.oLayoutHeaders.add_widget(self.oLabelKeene) self.oContent: Union[FileBrowser, None] = None self._popup: Union[Popup, None] = None self.oXMLCodeset: Union[Element, None] = None # noinspection PyUnusedLocal def show_load(self, *largs) -> None: alargs = { 'select_string': ReplaceVars('$lvar(563)'), 'cancel_string': ReplaceVars('$lvar(5009)'), 'libraries_string': ReplaceVars('$lvar(5018)'), 'favorites_string': ReplaceVars('$lvar(5019)'), 'computer_string': ReplaceVars('$lvar(5020)'), 'location_string': ReplaceVars('$lvar(5021)'), 'listview_string': ReplaceVars('$lvar(5022)'), 'iconview_string': ReplaceVars('$lvar(5023)'), 'transition': FadeTransition(), 'size_hint': (1, 1), 'favorites': [(Globals.oPathRoot.string, 'ORCA')], 'show_fileinput': False, 'show_filterinput': False, 'dirselect': False, 'path': Globals.oPathCodesets.string, 'filters': [ '*.xml', ] } #alargs['filters']= ['CODESET_iTach_*.xml',] #alargs['filters']= [self.MyFilter,] self.oContent = FileBrowser(**alargs) self.oContent.bind(on_success=self.load, on_canceled=self.dismiss_popup) self._popup = Popup(title=ReplaceVars("$lvar(5027)"), content=self.oContent, size_hint=(1, 1)) self._popup.open() # noinspection PyMethodMayBeStatic,PyUnusedLocal def MyFilter(self, uFolder: str, uFile: str) -> bool: if "CODESET_iTach" in uFile: return True return False # noinspection PyUnusedLocal def dismiss_popup(self, *largs) -> None: self._popup.dismiss() def load(self, oFileBrowser: FileBrowser) -> None: oCode: Element oXMLRoot: Element uCmd: str if len(oFileBrowser.selection) != 0: self.uCodesetFileName = oFileBrowser.selection[0] try: oParser = XMLParser(target=CommentedTreeBuilder()) oXMLRoot = LoadXMLFile(oFile=cFileName().ImportFullPath( uFnFullName=self.uCodesetFileName), oParser=oParser) # oXMLRoot = LoadXMLFile(oFile=cFileName().ImportFullPath(uFnFullName=self.uCodesetFileName)) if oXMLRoot is not None: self.oTextInput.text = tostring(oXMLRoot) for oCode in oXMLRoot: uCmd = oCode.get('cmd') if uCmd is not None: oCode.set('cmd', GlobalCacheToKeene(uCmd)) self.AdjustRepManagerITachToKeene(oXMLRoot) self.oTextInput2.text = tostring(oXMLRoot) except ParseError as uErrMsg: uMsg = 'Parse Error ' + str(uErrMsg) Logger.error(uMsg) except Exception as e: uMsg = 'General Error ' + str(e) Logger.error(uMsg) self.dismiss_popup() # noinspection PyMethodMayBeStatic def AdjustRepManagerITachToKeene(self, oXMLRoot: Element) -> None: oXMLRepMgr: Element oXMLRepMgrEntry: Element aXMLRepMgrDescriptions: List[Element] oDes: Element oXMLRepMgrName: Element aXMLRepMgrDependencies: List[Element] oDEDep: Element oName: Element oXMLRepMgSources: List[Element] oXMLRepMgSource: Element oXMLRepMgr = oXMLRoot.find("repositorymanager") if oXMLRepMgr is not None: oXMLRepMgrEntry = oXMLRepMgr.find("entry") if oXMLRepMgrEntry is not None: aXMLRepMgrDescriptions = oXMLRepMgrEntry.findall("description") if aXMLRepMgrDescriptions is not None: for oDes in aXMLRepMgrDescriptions: oDes.text = oDes.text.replace("iTach IR", "Keene Kira IR") oXMLRepMgrName = oXMLRepMgrEntry.find("name") if oXMLRepMgrName is not None: oXMLRepMgrName.text = oXMLRepMgrName.text.replace( "iTach", "Keene Kira") aXMLRepMgrDependencies = oXMLRepMgrEntry.findall( "dependencies") if aXMLRepMgrDependencies is not None: for oDep in aXMLRepMgrDependencies: oDEDep = oDep.find("dependency") if oDEDep is not None: oName = oDEDep.find("name") if oName is not None: oName.text = oName.text.replace( "iTach IR Control", "Keene Kira IR Control") aXMLRepMgSources = oXMLRepMgrEntry.findall("sources") if aXMLRepMgSources is not None: for oXMLRepMgSource in aXMLRepMgSources: for oSource in oXMLRepMgSource: oSource.text = oSource.text.replace( "_iTach_", "_Keene_Kira_") # noinspection PyMethodMayBeStatic def AdjustRepManagerITachToCCF(self, oXMLRoot: Element) -> None: oXMLRepMgr: Element oXMLRepMgr = oXMLRoot.find("repositorymanager") if oXMLRepMgr is not None: oXMLRepMgrEntry = oXMLRepMgr.find("entry") if oXMLRepMgrEntry is not None: oXMLRepMgrDescriptions = oXMLRepMgrEntry.findall("description") if oXMLRepMgrDescriptions is not None: for oDes in oXMLRepMgrDescriptions: oDes.text = oDes.text.replace("iTach IR", "CCF IR Codes") oXMLRepMgrName = oXMLRepMgrEntry.find("name") if oXMLRepMgrName is not None: oXMLRepMgrName.text = oXMLRepMgrName.text.replace( "iTach", "CCF IR Codes") oXMLRepMgrDependencies = oXMLRepMgrEntry.findall( "dependencies") if oXMLRepMgrDependencies is not None: for oDep in oXMLRepMgrDependencies: oDEDep = oDep.find("dependency") if oDEDep is not None: oName = oDEDep.find("name") if oName is not None: oName.text = oName.text.replace( "iTach IR Control", "CCF IR Codes") oXMLRepMgSources = oXMLRepMgrEntry.find("sources") if oXMLRepMgSources is not None: oXMLRepMgSourceBlock = oXMLRepMgSources.findall("source") if oXMLRepMgSourceBlock is not None: for oXMLRepMgSource in oXMLRepMgSourceBlock: for oSource in oXMLRepMgSource: oSource.text = oSource.text.replace( "_iTach_", "_infrared_ccf_") # noinspection PyUnusedLocal def show_save(self, *largs) -> None: if self.oTextInput2.text != "": uOutput: str = self.uCodesetFileName + "3" uOutput = uOutput.replace("_iTach_", "_Keene_Kira_") WriteXMLFile(oFile=cFileName().ImportFullPath(uFnFullName=uOutput), oElem=self.oXMLCodeset) self.oTextInput.text = "" self.oTextInput2.text = ""
class cITachToKeene(BoxLayout): def __init__(self, **kwargs): kwargs['orientation']='vertical' super(cITachToKeene, self).__init__(**kwargs) self.uCodesetFileName = '' self.oLayoutHeaders = BoxLayout(size_hint_y= None , height= 30) self.oLayoutButtons = BoxLayout(size_hint_y= None , height= 30) self.oLayoutPanels = BoxLayout() self.add_widget(self.oLayoutHeaders) self.add_widget(SettingSpacer()) self.add_widget(self.oLayoutPanels) self.add_widget(SettingSpacer()) self.add_widget(self.oLayoutButtons) self.oTextInput=TextInput() self.oTextInput2=TextInput() self.oLayoutPanels.add_widget(self.oTextInput) self.oLayoutPanels.add_widget(self.oTextInput2) self.oButtonLoad=Button(text = ReplaceVars('$lvar(563)')) self.oButtonSave=Button(text = ReplaceVars('$lvar(5025)')) self.oButtonLoad.bind(on_release = self.show_load) self.oButtonSave.bind(on_release = self.show_save) self.oLayoutButtons.add_widget(self.oButtonLoad) self.oLayoutButtons.add_widget(self.oButtonSave) self.oLabelITach=Label(text = "ITach", halign='center') self.oLabelKeene=Label(text = "Keene Kira", halign='center') self.oLayoutHeaders.add_widget(self.oLabelITach) self.oLayoutHeaders.add_widget(self.oLabelKeene) def show_load(self,*largs): alargs={} alargs['select_string']= ReplaceVars('$lvar(563)') alargs['cancel_string']= ReplaceVars('$lvar(5009)') alargs['libraries_string']= ReplaceVars('$lvar(5018)') alargs['favorites_string']= ReplaceVars('$lvar(5019)') alargs['computer_string']= ReplaceVars('$lvar(5020)') alargs['location_string']= ReplaceVars('$lvar(5021)') alargs['listview_string']= ReplaceVars('$lvar(5022)') alargs['iconview_string']= ReplaceVars('$lvar(5023)') alargs['transition ']= FadeTransition() alargs['size_hint']= (1, 1) alargs['favorites']= [(oORCA.uAppPath, 'ORCA')] alargs['show_fileinput']= False alargs['show_filterinput']= False alargs['dirselect']= False alargs['path']= oORCA.uCodesetsPath #alargs['filters']= ['CODESET_iTach_*.xml',] alargs['filters']= ['*.xml',] #alargs['filters']= [self.MyFilter,] self.oContent=FileBrowser(**alargs) self.oContent.bind(on_success=self.load,on_canceled=self.dismiss_popup) self._popup = Popup(title=ReplaceVars("$lvar(5027)"), content=self.oContent, size_hint=(1, 1)) self._popup.open() def MyFilter(self,uFolder,uFile): if "CODESET_iTach" in uFile: return True return False def dismiss_popup(self,*largs): self._popup.dismiss() def load(self,instance): if len(instance.selection)!=0: self.uCodesetFileName=instance.selection[0] try: self.oXMLCodeset = ElementTree() self.oXMLCodeset.parse(self.uCodesetFileName, CommentedTreeBuilder()) if not self.oXMLCodeset==None: self.oXMLRoot = self.oXMLCodeset.getroot() self.oTextInput.text=tostring(self.oXMLRoot) for oCode in self.oXMLRoot: sCmd=oCode.get('cmd') if not sCmd==None: oCode.set('cmd',GlobalCacheToKeene(sCmd)) self.AdjustRepManager(self.oXMLRoot) self.oTextInput2.text=tostring(self.oXMLRoot) except ParseError,sErrMsg: sMsg='Error '+str(sErrMsg) print sMsg except Exception,e: sMsg='Error '+str(e) print sMsg