def Create(self,oParent,iWidgetIndex): ''' Creates the Widget ''' self.oObject = None if oORCA.bShowBorders: self.CreateBase(Parent=oParent, WidgetIndex=iWidgetIndex,Class='') self.AddArg('background_color',[1.0,0.0,1.0,1.0]) self.AddArg('linewidth',"2") self.oBorder=cBorder(**self.aKwArgs) self.oParent.add_widget(self.oBorder) return True
def Create(self, oParent): """ Creates the Widget """ self.oObject = None if Globals.oParameter.bShowBorders: self.CreateBase(Parent=oParent, Class='') self.AddArg('background_color', [1.0, 0.0, 1.0, 1.0]) self.AddArg('linewidth', "2") self.oBorder = cBorder(**self.aKwArgs) self.oParent.add_widget(self.oBorder) return True
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
def FlipBorder(self) -> None: if self.oObject is not None: if Globals.bShowBorders: if self.oBorder is None: if (not isinstance(self.oObject, Layout)) and ( not self.eWidgetType == eWidgetType.FileViewer ) and (not self.eWidgetType == eWidgetType.Border): self.oBorder = cBorder(**self.dKwArgs) self.oObject.add_widget(self.oBorder) else: if self.oBorder is not None: self.oObject.remove_widget(self.oBorder) self.oBorder = None
def CreateBase(self,Parent,WidgetIndex,Class): try: self.oParent = Parent self.iWidgetIndex = WidgetIndex self.iPosX = self.iPosXInit/self.oDef.fRationX self.iPosY = self.iPosYInit/self.oDef.fRationY self.iWidth = self.iWidthInit/self.oDef.fRationX self.iHeight = self.iHeightInit/self.oDef.fRationY self.iFontSize = self.iFontSizeInit/self.oDef.fRationX if self.iWidgetType==oWidgetType.BackGround: self.iGapX = 0 self.iGapY = 0 self.iHeight = oORCA.iAppHeight self.iWidth = oORCA.iAppWidth iKivyPosX = self.iPosX+self.iGapX iKivyPosY = oORCA.iAppHeight-self.iHeight-self.iPosY-self.iGapY self.AddArg('pos',(iKivyPosX,iKivyPosY )) self.AddArg('size',(self.iWidth,self.iHeight)) if not self.tBackGroundColor==[0.0,0.0,0.0,0.0]: self.AddArg('background_color',self.tBackGroundColor) if not self.bEnabled: self.AddArg('opacity',0) if self.bHasText: self.AddArg('halign', self.uhTextAlign) self.AddArg('valign', self.uvTextAlign) self.AddArg('color', self.tTextColor) self.AddArg('foreground_color', self.tTextColor) self.AddArg('italic', self.bItalic) self.AddArg('bold', self.bBold) if not self.bNoTextSize: self.AddArg('text_size', (self.iWidth,self.iHeight)) self.AddArg('font_name', self.uFontIndex) self.AddArg('text' , self.uCaption) self.SetCaption2(self.uCaption) #self.oObject.shorten= True if self.iFontSize > 0: # a further unicode bug in kivy: font_size just except strings not unicode strings self.AddArg('font_size',str(self.iFontSize)+'px') # Fonts are loaded at initialisation, but if we load elements at runtime, the font might not be registered if not self.uFontIndex in oORCA.oTheScreen.aUsedFonts: oFont=oORCA.oTheScreen.aFonts[self.uFontIndex] Logger.debug (u'Register Font at runtime: '+self.uFontIndex) LabelBase.register(oFont.uName, oFont.uFileNameNormal, oFont.uFileNameItalic, oFont.uFileNameBold, oFont.uFileNameBoldItalic) oORCA.oTheScreen.aUsedFonts[self.uFontIndex]=oFont if not Class=='': self.oObject = Class(**self.aKwArgs) self.oObject.oOrcaWidget = self if oORCA.bShowBorders: if (not isinstance(self.oObject, Layout)) and (not self.iWidgetType == oWidgetType.Knob): self.oBorder = cBorder(**self.aKwArgs) self.oObject.add_widget(self.oBorder) return True except Exception as e: LogError(u'Can''t create widget:'+self.uName,e) return False
def CreateBase(self, Parent, Class): try: self.oParent = Parent self.iPosX = self.iPosXInit / self.oDef.fRationX self.iPosY = self.iPosYInit / self.oDef.fRationY self.iWidth = self.iWidthInit / self.oDef.fRationX self.iHeight = self.iHeightInit / self.oDef.fRationY self.CalcFontSize() if self.iWidgetType == oWidgetType.BackGround: self.iGapX = 0 self.iGapY = 0 self.iHeight = Globals.iAppHeight self.iWidth = Globals.iAppWidth iKivyPosX = self.iPosX + self.iGapX iKivyPosY = Globals.iAppHeight - self.iHeight - self.iPosY - self.iGapY self.AddArg('pos', (iKivyPosX, iKivyPosY)) self.AddArg('size', (self.iWidth, self.iHeight)) if not self.tBackGroundColor == [0.0, 0.0, 0.0, 0.0]: self.AddArg('background_color', self.tBackGroundColor) if not self.bEnabled: self.AddArg('opacity', 0) if self.bHasText: self.AddArg('halign', self.uhTextAlign) self.AddArg('valign', self.uvTextAlign) self.AddArg('italic', self.bItalic) self.AddArg('bold', self.bBold) if not self.bNoTextSize: self.AddArg('text_size', (self.iWidth, self.iHeight)) self.AddArg('color', self.tTextColor) self.AddArg('foreground_color', self.tTextColor) self.AddArg('font_name', self.uFontIndex) self.AddArg('text', self.uCaption) self.SetCaption(self.uCaption) #self.oObject.shorten= True if self.iFontSize > 0: # a further unicode bug in kivy: font_size just except strings not unicode strings self.AddArg('font_size', str(self.iFontSize) + 'px') # Fonts are loaded at initialisation, but if we load elements at runtime, the font might not be registered if not self.uFontIndex in Globals.oTheScreen.oFonts.dUsedFonts: oFont = Globals.oTheScreen.oFonts.dFonts[self.uFontIndex] oFont.Register() Globals.oTheScreen.oFonts.dUsedFonts[ self.uFontIndex] = oFont if not Class == '': if Class.__name__.startswith("c"): # Just add to ORCA classes, passing custom parameter to Kivy classes crashes on Python 3 self.aKwArgs['ORCAWIDGET'] = self self.oObject = Class(**self.aKwArgs) self.oObject.oOrcaWidget = self if Globals.oParameter.bShowBorders: if (not isinstance(self.oObject, Layout) ) and (not self.iWidgetType == oWidgetType.Knob) and ( not self.iWidgetType == oWidgetType.FileViewer): self.oBorder = cBorder(**self.aKwArgs) self.oObject.add_widget(self.oBorder) return True except Exception as e: LogError(u'Can' 't create widget:' + self.uName, e) return False