コード例 #1
0
ファイル: bordcomputer.py プロジェクト: Inz999/OpenBM
	def setData(self, value, push = False):
		if (push == False):
			return LBL_SET
			
		# what is the current value
		old = self.getControl(self.LabelList[value][0]).getLabel()
		
		# show dialog to set a value
		dialog = SetValueDialog("bc-setvalue.xml", os.getcwd())
		dialog.setLabel(self.getControl(self.LabelList[value][0]))
		dialog.setMaxLen(self.LabelList[value][4])
		dialog.doModal()
		
		# check if user liked to reset the value, then just restore old value
		if (dialog.canceled == True):
			self.getControl(self.LabelList[value][0]).setLabel(old)
		else:
			tts.sayAsync( ("%s set to %s")%(self.LabelList[value][6], self.getControl(self.LabelList[value][0]).getLabel()) )
			
			# set new value
			openbm.bcSetOBCValue(self.LabelList[value][1], int(self.getControl(self.LabelList[value][0]).getLabel()))
			self.getControl(self.LabelList[value][0]).setLabel("")
			
		
		# request of the value update
		openbm.bcReqOBCValue(self.LabelList[value][1])
			
		# release memory	
		del dialog
		
		pass
コード例 #2
0
ファイル: bordcomputer.py プロジェクト: Inz999/OpenBM
	def setup_all( self ):
		
		tts.sayAsync("On board computer")
			
		# disable all subwindows
		for i in range(len(MODE)):		
			self.getControl(MODE[i]).setVisible(False)

		# activate default window			
		self.getControl(MODE[self.obcMode]).setVisible(True)
		self.setFocusId(MODE[self.obcMode])
		
		self.getControl(OBC_LIMIT_LOGO_ID).setVisible(False)
		
		# update all labels
		openbm.bcSetOnStateCallback(self.onOBCStateChange)
		openbm.bcReqOBCState()
		
		# first setup update methods for the OBC data
		for i in self.LabelList:
			openbm.bcSetOnValueCallback(i[1], i[2])
			openbm.bcReqOBCValue(i[1])
			xbmc.sleep(50)
		
		# set repeatable timer to update labels without any value
		self.updateTimer.start()
		
		pass
コード例 #3
0
    def setup_all(self):

        tts.sayAsync("On board computer")

        # disable all subwindows
        for i in range(len(MODE)):
            self.getControl(MODE[i]).setVisible(False)

        # activate default window
        self.getControl(MODE[self.obcMode]).setVisible(True)
        self.setFocusId(MODE[self.obcMode])

        self.getControl(OBC_LIMIT_LOGO_ID).setVisible(False)

        # update all labels
        openbm.bcSetOnStateCallback(self.onOBCStateChange)
        openbm.bcReqOBCState()

        # first setup update methods for the OBC data
        for i in self.LabelList:
            openbm.bcSetOnValueCallback(i[1], i[2])
            openbm.bcReqOBCValue(i[1])
            xbmc.sleep(50)

        # set repeatable timer to update labels without any value
        self.updateTimer.start()

        pass
コード例 #4
0
    def setData(self, value, push=False):
        if (push == False):
            return LBL_SET

        # what is the current value
        old = self.getControl(self.LabelList[value][0]).getLabel()

        # show dialog to set a value
        dialog = SetValueDialog("bc-setvalue.xml", os.getcwd())
        dialog.setLabel(self.getControl(self.LabelList[value][0]))
        dialog.setMaxLen(self.LabelList[value][4])
        dialog.doModal()

        # check if user liked to reset the value, then just restore old value
        if (dialog.canceled == True):
            self.getControl(self.LabelList[value][0]).setLabel(old)
        else:
            tts.sayAsync(
                ("%s set to %s") %
                (self.LabelList[value][6],
                 self.getControl(self.LabelList[value][0]).getLabel()))

            # set new value
            openbm.bcSetOBCValue(
                self.LabelList[value][1],
                int(self.getControl(self.LabelList[value][0]).getLabel()))
            self.getControl(self.LabelList[value][0]).setLabel("")

        # request of the value update
        openbm.bcReqOBCValue(self.LabelList[value][1])

        # release memory
        del dialog

        pass
コード例 #5
0
ファイル: bordcomputer.py プロジェクト: Inz999/OpenBM
	def update(self):

		if ((not self.nextUpdateLabel == self.selectedButton) and (len(self.getControl(self.LabelList[self.nextUpdateLabel][0]).getLabel()) == 0)):
			openbm.bcReqOBCValue(self.LabelList[self.nextUpdateLabel][1])

		self.nextUpdateLabel = self.nextUpdateLabel + 1
		if (self.nextUpdateLabel >= len(self.LabelList)):
			self.nextUpdateLabel = 0
コード例 #6
0
ファイル: bordcomputer.py プロジェクト: Inz999/OpenBM
	def onAction1(self, action):

		# close window	
		if (action == ACTION_PREVIOUS_MENU) or (action == ACTION_CLOSE_DIALOG):
			self.onStop()

		# we are in the BC mode
		if (self.obcMode == MODE_BC):

			if (action == ACTION_MOVE_LEFT):
				if (self.selectedButton >= 0):
					self.selectedSubButton = (self.selectedSubButton - 1) % len(self.LabelList[self.selectedButton][3])
					self.getControl(self.LabelList[self.selectedButton][0]).setLabel(self.LabelList[self.selectedButton][3][self.selectedSubButton](self.selectedButton, False))
			elif (action == ACTION_MOVE_RIGHT):
				if (self.selectedButton >= 0):
					self.selectedSubButton = (self.selectedSubButton + 1) % len(self.LabelList[self.selectedButton][3])
					self.getControl(self.LabelList[self.selectedButton][0]).setLabel(self.LabelList[self.selectedButton][3][self.selectedSubButton](self.selectedButton, False))
	
			# if selected, then ask for user action
			elif (action == ACTION_SELECT_ITEM):
				buttonId = self.getFocusId() - OBC_BUTTON_BASE
				
				# button was selected before, so now execute the selected action function
				if (self.selectedButton >= 0):
	
					self.getControl(self.LabelList[self.selectedButton][0]).setLabel("")
					
					if (self.selectedButton == buttonId):
						self.LabelList[buttonId][3][self.selectedSubButton](buttonId, True)
						
					openbm.bcReqOBCValue(self.LabelList[self.selectedButton][1])
					self.selectedButton = -1
					self.selectedSubButton = 0
					
				# select button, however only if actions for this buttons exists
				elif (len(self.LabelList[buttonId][3])):
					self.getControl(self.LabelList[buttonId][0]).setLabel(self.LabelList[buttonId][3][0](buttonId, False))
					self.selectedButton = buttonId
					self.selectedSubButton = 0
					
			# on any other action rather then select, we remove the selected button
			else:
				ss = self.selectedButton
				self.selectedButton = -1
				self.selectedSubButton = 0
				if (ss >= 0):
					self.getControl(self.LabelList[ss][0]).setLabel("")
					openbm.bcReqOBCValue(self.LabelList[ss][1])
		
	   
		# if no button is activated and we pressed left or right, then switch current modes
		if (self.selectedButton < 0):
			if (action == ACTION_MOVE_LEFT): self.switchMode(False);
			if (action == ACTION_MOVE_RIGHT): self.switchMode(True);
コード例 #7
0
    def update(self):

        if ((not self.nextUpdateLabel == self.selectedButton) and (len(
                self.getControl(
                    self.LabelList[self.nextUpdateLabel][0]).getLabel())
                                                                   == 0)):
            openbm.bcReqOBCValue(self.LabelList[self.nextUpdateLabel][1])

        self.nextUpdateLabel = self.nextUpdateLabel + 1
        if (self.nextUpdateLabel >= len(self.LabelList)):
            self.nextUpdateLabel = 0
コード例 #8
0
    def onAction1(self, action):

        # close window
        if (action == ACTION_PREVIOUS_MENU) or (action == ACTION_CLOSE_DIALOG):
            self.onStop()

        # we are in the BC mode
        if (self.obcMode == MODE_BC):

            if (action == ACTION_MOVE_LEFT):
                if (self.selectedButton >= 0):
                    self.selectedSubButton = (
                        self.selectedSubButton - 1) % len(
                            self.LabelList[self.selectedButton][3])
                    self.getControl(
                        self.LabelList[self.selectedButton][0]).setLabel(
                            self.LabelList[self.selectedButton][3][
                                self.selectedSubButton](self.selectedButton,
                                                        False))
            elif (action == ACTION_MOVE_RIGHT):
                if (self.selectedButton >= 0):
                    self.selectedSubButton = (
                        self.selectedSubButton + 1) % len(
                            self.LabelList[self.selectedButton][3])
                    self.getControl(
                        self.LabelList[self.selectedButton][0]).setLabel(
                            self.LabelList[self.selectedButton][3][
                                self.selectedSubButton](self.selectedButton,
                                                        False))

            # if selected, then ask for user action
            elif (action == ACTION_SELECT_ITEM):
                buttonId = self.getFocusId() - OBC_BUTTON_BASE

                # button was selected before, so now execute the selected action function
                if (self.selectedButton >= 0):

                    self.getControl(
                        self.LabelList[self.selectedButton][0]).setLabel("")

                    if (self.selectedButton == buttonId):
                        self.LabelList[buttonId][3][self.selectedSubButton](
                            buttonId, True)

                    openbm.bcReqOBCValue(
                        self.LabelList[self.selectedButton][1])
                    self.selectedButton = -1
                    self.selectedSubButton = 0

                # select button, however only if actions for this buttons exists
                elif (len(self.LabelList[buttonId][3])):
                    self.getControl(self.LabelList[buttonId][0]).setLabel(
                        self.LabelList[buttonId][3][0](buttonId, False))
                    self.selectedButton = buttonId
                    self.selectedSubButton = 0

            # on any other action rather then select, we remove the selected button
            else:
                ss = self.selectedButton
                self.selectedButton = -1
                self.selectedSubButton = 0
                if (ss >= 0):
                    self.getControl(self.LabelList[ss][0]).setLabel("")
                    openbm.bcReqOBCValue(self.LabelList[ss][1])

        # if no button is activated and we pressed left or right, then switch current modes
        if (self.selectedButton < 0):
            if (action == ACTION_MOVE_LEFT): self.switchMode(False)
            if (action == ACTION_MOVE_RIGHT): self.switchMode(True)