Ejemplo n.º 1
0
    def Create(self, oParent: Widget) -> bool:
        """ creates the Widget """
        try:
            if not self.oFnButtonPictureNormal.IsEmpty():
                self.AddArg('border', (0, 0, 0, 0))
                self.AddArg('background_normal',
                            ToAtlas(oFileName=self.oFnButtonPictureNormal))
                if not self.oFnButtonPicturePressed.IsEmpty():
                    self.AddArg(
                        'background_down',
                        ToAtlas(oFileName=self.oFnButtonPicturePressed))

            if self.uActionNameUpOnly:
                self.AddArg('forceup', '1')

            if self.CreateBase(Parent=oParent, Class=self.ClassName):
                self.oObject.bind(on_q_release=self.On_Button_Up)
                self.oObject.bind(on_q_press=self.On_Button_Down)
                self.oObject.bind(on_gesture=self.On_Gesture)
                self.oParent.add_widget(self.oObject)
                return True
            return False
        except Exception as e:
            LogError(uMsg=u'cWidgetButton:Unexpected error Creating Object:',
                     oException=e)
            return False
Ejemplo n.º 2
0
    def __init__(self, **kwargs):

        self.oLayout = FloatLayout(size_hint=(1, 1))
        super(SettingPicture,
              self).__init__(**RemoveNoClassArgs(kwargs, SettingFile))

        try:
            oFnPic = cFileName().ImportFullPath(self.value)
            self.oPic = Image(source=UnEscapeUnicode(ToAtlas(oFnPic)),
                              size_hint=(1, 1),
                              pos_hint={
                                  'x': 0.0,
                                  'y': 0.0
                              })
            oFnBack = cFileName(Globals.oPathResources +
                                "pics") + "imagepicker_background.png"
            self.oBack = Image(source=ToAtlas(oFnBack),
                               size_hint=(1, 1),
                               pos_hint={
                                   'x': 0.0,
                                   'y': 0.0
                               })
            self.oLayout.add_widget(self.oBack)
            self.oLayout.add_widget(self.oPic)
            self.add_widget(self.oLayout)
            self.content.children[1].text = ''
        except Exception as e:
            uMsg = u'Settings: Picture: can\'t load image file: ' + ToUnicode(
                e) + " " + oFnPic
            Logger.error(uMsg)
Ejemplo n.º 3
0
    def Create(self, oParent: Widget) -> bool:
        """ creates the Widget """
        try:
            self.fMin = ToFloat(ReplaceVars(self.uMin))
            self.fMax = ToFloat(ReplaceVars(self.uMax))
            self.AddArg('min', self.fMin)
            self.AddArg('max', self.fMax)
            self.AddArg('orientation', self.uDeviceOrientation)
            self.AddArg('value', self.fMin)
            self.AddArg('background_pic',
                        ToAtlas(oFileName=self.oFnPictureNormal))
            self.AddArg('button_pic', ToAtlas(oFileName=self.oFnPictureButton))
            if self.CreateBase(Parent=oParent, Class=cSliderEx):
                self.fDataRange = abs(self.fMax - self.fMin)
                self.oObject.bind(on_slider_moved=self.OnNotifyChange)
                # Capability to click on Knobs as well (needs to be implemented)
                if not self.uActionName == u'':
                    self.oObject.bind(on_release=self.On_Button_Up)
                    self.oObject.bind(on_press=self.On_Button_Down)

                self.oParent.add_widget(self.oObject)
                self.UpdateWidget()
                return True
            return False
        except Exception as e:
            LogError(uMsg=u'cWidgetSlider:Unexpected error Creating Object:',
                     oException=e)
            return False
Ejemplo n.º 4
0
    def SetPictureNormal(self, uPictureNormal, bClearCache=False):
        """ sets the picture """

        try:
            uNewDefinitionContext = u''

            if "DEFINITIONPATH[" in uPictureNormal:
                uNewDefinitionContext, uPictureNormal = GetSetDefinitionName(
                    uPictureNormal)
            elif Globals.uDefinitionContext != self.uDefinitionContext:
                uNewDefinitionContext = self.uDefinitionContext
                SetDefinitionContext(uNewDefinitionContext)
            self.uPictureNormalVar = uPictureNormal
            self.oFnPictureNormal = self.oFnPictureNormal.Clear(
            ).ImportFullPath(ReplaceVars(uPictureNormal))

            if self.oObject:
                self.oObject.source = ToAtlas(self.oFnPictureNormal)
                if bClearCache:
                    self.oObject.reload()

            if uNewDefinitionContext != '':
                RestoreDefinitionContext()
        except Exception as e:
            LogError(u"Can't set picture:" + uPictureNormal, e)
            return False

        return True
Ejemplo n.º 5
0
    def SetPictureNormal(self,
                         uFnPictureNormal: str,
                         bClearCache: bool = False) -> bool:
        """ sets the picture """

        try:
            uNewDefinitionContext: str = u''

            if "DEFINITIONPATH[" in uFnPictureNormal:
                uNewDefinitionContext, uFnPictureNormal = GetSetDefinitionName(
                    uText=uFnPictureNormal)
            elif Globals.uDefinitionContext != self.uDefinitionContext:
                uNewDefinitionContext = self.uDefinitionContext
                SetDefinitionContext(uDefinitionName=uNewDefinitionContext)
            self.uFnPictureNormalVar = uFnPictureNormal
            self.oFnPictureNormal = self.oFnPictureNormal.Clear(
            ).ImportFullPath(uFnFullName=ReplaceVars(uFnPictureNormal))
            if self.oObject:
                self.oObject.source = ToAtlas(oFileName=self.oFnPictureNormal)
                if bClearCache:
                    if self.oObject._coreimage.filename is not None:
                        self.oObject.reload()
            if uNewDefinitionContext != '':
                RestoreDefinitionContext()
        except Exception as e:
            LogError(uMsg=u"Can't set picture:" + uFnPictureNormal,
                     oException=e)
            return False

        return True
Ejemplo n.º 6
0
 def SetPictureNormal(self,uPictureNormal,bClearCache=False):
     """ sets the unpressed picture """
     if uPictureNormal!='':
         self.oFnButtonPictureNormal.ImportFullPath(uPictureNormal)
     if self.oObject:
         self.oObject.background_normal  =  ToAtlas(self.oFnButtonPictureNormal)
         # self.SetCaption(self.uCaption)
     return True
Ejemplo n.º 7
0
    def SetPicturePressed(self,uPicturePressed):
        """ sets the pressed picture """

        if uPicturePressed!='':
            self.oFnButtonPicturePressed.ImportFullPath(uPicturePressed)

        if self.oObject:
            self.oObject.background_down = ToAtlas(self.oFnButtonPicturePressed)
        return True
Ejemplo n.º 8
0
    def Create(self, oParent):
        """ creates the Widget """
        self.AddArg('allow_stretch', True)
        self.AddArg('keep_ratio', False)
        self.AddArg('source', ToAtlas(self.oFnPictureNormal))
        self.CreateBase(Parent=oParent, Class=Image)
        self.oObjectPicture = self.oObject
        self.AddArg('do_scale', False)
        self.AddArg('do_translation_y', False)
        self.AddArg('auto_bring_to_front', False)
        if self.CreateBase(Parent=oParent, Class=cRotateScatter):

            self.oObjectPicture.pos = (0, 0)

            self.fDataRange = abs(self.fMax - self.fMin)
            '''
            # Todo : Check and rework
            if self.fMin>0:
                self.fDataRange=self.fMin
            else:
                self.fDataRange=abs(self.fMin)

            if self.fMax>0:
                self.fDataRange=self.fMax-self.fDataRange
            else:
                self.fDataRange=self.fDataRange+abs(self.fMax)
            '''

            if self.iLeftBoundaryAngle > 0:
                self.iRange = self.iLeftBoundaryAngle
            else:
                self.iRange = abs(self.iLeftBoundaryAngle)

            if self.iRightBoundaryAngle > 0:
                self.iRange = self.iRange + self.iRightBoundaryAngle
            else:
                self.iRange = self.iRange + abs(self.iRightBoundaryAngle)

            self.oObject.iLeftBoundaryAngle = self.iLeftBoundaryAngle
            self.oObject.iRightBoundaryAngle = self.iRightBoundaryAngle
            self.oObject.bind(on_widget_turned=self.OnNotifyChange)

            # Capability to click on Knobs as well (seems not to work by now)
            if not self.uActionName == u'':
                self.oObject.bind(on_q_release=self.On_Button_Up)
                self.oObject.bind(on_q_press=self.On_Button_Down)

            self.oParent.add_widget(self.oObject)
            self.oObject.add_widget(self.oObjectPicture)

            if Globals.oParameter.bShowBorders:
                self.oBorder = cBorder(**self.aKwArgs)
                self.oParent.add_widget(self.oBorder)
            return True
        return False
Ejemplo n.º 9
0
    def SetPicturePressed(self, uPicturePressed: str) -> bool:
        """ sets the pressed picture """

        if uPicturePressed != '':
            self.oFnButtonPicturePressed.ImportFullPath(
                uFnFullName=uPicturePressed)

        if self.oObject:
            self.oObject.background_down = ToAtlas(
                oFileName=self.oFnButtonPicturePressed)
        return True
Ejemplo n.º 10
0
 def SetPictureNormal(self,
                      uPictureNormal: str,
                      bClearCache: bool = False) -> bool:
     """ sets the unpressed picture """
     if uPictureNormal != '':
         self.oFnButtonPictureNormal.ImportFullPath(
             uFnFullName=uPictureNormal)
     if self.oObject:
         self.oObject.background_normal = ToAtlas(
             oFileName=self.oFnButtonPictureNormal)
         # self.SetCaption(self.uCaption)
     return True
Ejemplo n.º 11
0
    def Create(self, oParent):
        """ creates the Widget """
        self.AddArg('allow_stretch', True)
        self.AddArg('keep_ratio', False)
        self.AddArg('source', ToAtlas(self.oFnPictureNormal))

        if self.CreateBase(Parent=oParent, Class=cTouchImage):
            if self.uActionName != u'' or self.uActionNameDoubleTap != u'':
                self.oObject.bind(on_q_release=self.On_Button_Up)
                self.oObject.bind(on_q_press=self.On_Button_Down)
            self.oObject.bind(on_gesture=self.On_Gesture)
            self.oParent.add_widget(self.oObject)
            return True
        return False
Ejemplo n.º 12
0
 def Create(self,oParent):
     self.AddArg('source',       ToAtlas(self.oFnPictureNormal))
     self.AddArg('angle_start',  self.fStartAngle)
     self.AddArg('angle_end',    self.fEndAngle)
     return super(cWidgetCircle, self).Create(oParent)
Ejemplo n.º 13
0
    def _validate(self, instance) -> None:
        """ displays the folder """

        SettingFile._validate(self,instance)
        self.oPic.source=ToAtlas(oFileName=cFileName('').ImportFullPath(uFnFullName=self.value))
        self.content.children[1].text=''