def determineLayout(self): self.noteHeight = 5 * d.py self.interNoteSpace = 1 * d.py yNoteCent = self.y - self.ydim / 2 + self.interNoteSpace + self.noteHeight / 2 self.yNoteCents = [] while yNoteCent < self.y + self.ydim / 2 - self.noteHeight / 2: self.yNoteCents.append(yNoteCent) yNoteCent += (self.noteHeight + self.interNoteSpace) self.startIndex = 0 self.endIndex = min(len(self.yNoteCents) - 1, len(self.list) - 1) self.itemsAvUplbl = rl.RectLabel( app=self.app, pos=(self.x, self.yNoteCents[0] - self.noteHeight - self.interNoteSpace), dim=(self.xdim, self.noteHeight), text='...', font=self.app.nlFont) # self.itemsAvUplbl = rl.RectLabel(self.app, # {'x': self.x, 'y': self.yNoteCents[0]- self.noteHeight - self.interNoteSpace, 'xdim': self.xdim,'ydim': self.noteHeight}, # {'txt': '...', 'txtDim': 4*d.px, 'color': self.app.textView_col}) self.itemsAvDownlbl = rl.RectLabel( app=self.app, pos=(self.x, self.yNoteCents[-1] + self.noteHeight + self.interNoteSpace), dim=(self.xdim, self.noteHeight), text='...', font=self.app.nlFont)
def __init__(self, app, geoData, txtData, focus): self.app = app self.disp = self.app.disp self.x = geoData['x'] self.y = geoData['y'] self.xdim = geoData['xdim'] self.ydim = geoData['ydim'] self.label = txtData['txt'] self.txtDim = txtData['txtDim'] txtData[ 'color'] = self.app.font_col #d.light_blue if self.focus else d.light_gray self.rectLabel = rl.RectLabel(app=self.app, pos=(self.x, self.y), dim=(self.xdim, self.ydim), text=self.label, font=self.app.nlFont) # self.rectLabel = rl.RectLabel(self.app, geoData, txtData, wrap = 'single-inline') self.focus = focus # self.rectLabel.setBcgCol(d.light_blue if self.focus else d.light_gray) self.rectLabel.setHasBorder(True if self.focus else False) self.setIsSelected(False)
def addBtns(self): self.focusNum = 0 self.btns = [] self.value = self.app.getSetting(self.valueName) val = self.value for i in range(self.numDigits): exp = self.numDigits - i - 1 divider = 10**exp quot = val // divider val -= quot * divider xPos = self.x - 14 * d.px + i * 10 * d.px self.btns.append( self.NumBtn(self.app, quot, { 'x': xPos, 'y': self.y, 'xdim': 8 * d.px, 'ydim': 8 * d.px }, i == self.focusNum)) if self.unitPos == 'suffix': xPos = self.x - 14 * d.px + len(self.btns) * 10 * d.px elif self.unitPos == 'prefix': xPos = self.x - 14 * d.px - 10 * d.px self.unitLabel = rl.RectLabel(app=self.app, pos=(xPos, self.y), dim=(8 * d.px, 8 * d.px), text=self.valueUnit, font=self.app.numKeyFont)
def initLayout(self): self.nls = [] self.nls.append(nl.NoteList(self.app, self.disp, {'x':self.cax - self.caxdim/2 + 2*d.px,'y':self.cay, 'xdim':10*d.px, 'ydim': 45*d.py}, list = [], listName='REAL', hasFocus = True) ) self.nls.append(nl.NoteList(self.app, self.disp, {'x':self.cax - self.caxdim/2 + 13*d.px,'y':self.cay, 'xdim':10*d.px, 'ydim': 45*d.py}, list = [], listName='ADC', hasFocus = True) ) self.infoBtnDefs = ( {'label': 'REAL', 'id': REAL, 'value': '_','funct': None}, {'label': 'ADC', 'id': ADC,'value': '_','funct': None}, {'label': 'a', 'id': 'a','value': '_', 'funct': None}, {'label': 'b', 'id': 'b','value': '_', 'funct': None} ) self. infoBtns = [] self.infoBtnsCols = (self.cax - self.caxdim/2 + 1*self.caxdim/8, self.cax - self.caxdim/2 + 3*self.caxdim/8, self.cax - self.caxdim/2 + 5*self.caxdim/8, self.cax - self.caxdim/2 + 7*self.caxdim/8) self.infoBtnsRows = [self.cay + 42*d.py] self.numInfoBtnRow = len(self.infoBtnsRows) self.numInfoBtnCom = len(self.infoBtnsCols) for i in range(len(self.infoBtnDefs)): row = self.infoBtnsRows[i // self.numInfoBtnCom] col = self.infoBtnsCols[i % self.numInfoBtnCom] self.infoBtns.append(vb.ViewBtn(app = self.app, pos = (col, row), dim = (16*d.px, 14*d.py), label = self.infoBtnDefs[i]['label'], value = self.infoBtnDefs[i]['value'], id = self.infoBtnDefs[i]['id'], formating = lambda lab, val: lab + ':\n' +(str("%.2f" % val) if type(val) == type(0.0) else str(val)) + (self.sensorData['unit'] if self.infoBtnDefs[i]['id'] == REAL or self.infoBtnDefs[i]['id'] == ADC else '') ) ) # self.infoBtns.append(self.SettingBtn(self.app, {'x': col, 'y': row}, self.infoBtnDefs[i], self.sensorData['unit'] if self.infoBtnDefs[i]['label'] == REAL else '')) self.inPrRect = rl.RectLabel(app = self.app, pos = (self.cax, self.cay), dim = (70*d.px, 70*d.py), text = 'DATA COLLECTION\nIN PROGRESS', font = self.app.viewTtlFont, fontCol = self.app.font_col, bcgCol = d.light_green, scaleFactor = 0.7 )#in progress rectangle self.graph = self.app.testingView.graph self.graph.updatePlot( xlabel = 'REAL ' + self.sensorType + ' [' + self.sensorData['unit'] + ']', ylabel = self.sensorType + ' ADC' )
def addTtlRect(self): self.ttlRect = rl.RectLabel(app=self.app, pos=(self.x, self.y - self.ydim / 2 - 8 * d.py), dim=(self.xdim, self.noteHeight), text=self.listName, font=self.app.nlFont, fontCol=d.invertColor(self.app.bcg_col), bcgCol=d.transparent)
def __init__(self, app, value, butGeo, focus): self.app = app self.disp = self.app.disp self.value = value self.focus = focus color = d.textView_highlight_col if self.focus else self.app.textView_col self.rectLabel = rl.RectLabel(app=self.app, pos=(butGeo['x'], butGeo['y']), dim=(butGeo['xdim'], butGeo['ydim']), text=value, font=self.app.numKeyFont, bcgCol=color)
def __init__(self, char, app, geoData): self.app = app self.disp = self.app.disp self.char = char self.x = geoData['x'] self.y = geoData['y'] self.xdim = geoData['xdim'] self.ydim = geoData['ydim'] self.rectLabel = rl.RectLabel(app=self.app, pos=(self.x, self.y), dim=(self.xdim, self.ydim), text=char, font=self.app.kbKeyFont)
def __init__(self, app, prevView=None, type=d.NUM, dataName='Data', retKey='', input='', maxlen=20, suffix=''): self.title = 'INPUT: ' + dataName self.btnDefs = [({ 'label': 'OK', 'id': 'saveBtn', 'funct': self.save }, { 'label': 'SELECT', 'id': 'selectBtn', 'funct': self.addChar }, { 'label': 'BACK\nSPACE', 'id': 'bckSpaceBtn', 'funct': self.backSpace }, { 'label': 'CANCEL', 'id': 'bckBtn', 'funct': self.back })] super().__init__(app, prevView) self.type = type self.retKey = retKey self.maxlen = maxlen self.currNotesX = self.cax self.currNotesY = self.cay self.input = str(input) self.suffix = suffix self.inputRect = rl.RectLabel( app=self.app, pos=(self.cax, self.cay - 24 * d.py), dim=(58 * d.px, 8 * d.py), text=self.input + ' ' + self.suffix, font=self.app.nlFont, ) self.initKeyBoard(type)
def __init__(self, app, pos, dim, label, value='', id='', font=None, funct=None, focus=False, formating=lambda lab, val: lab, txtMode='mpte'): self.app = app self.disp = self.app.disp #geo data self.x = pos[0] self.y = pos[1] self.xdim = dim[0] self.ydim = dim[1] #meta data self.label = label self.value = value self.id = id self.funct = funct self.focus = focus self.formating = formating self.txtMode = txtMode self.rl = rl.RectLabel( app=self.app, pos=(self.x, self.y), dim=(self.xdim, self.ydim), text=self.formating(self.label, self.value), font=font if font is not None else self.app.stnBtnFont, bcgCol=d.textView_highlight_col if self.focus else self.app.textView_col, txtMode=self.txtMode)
def __init__(self, app, view, disp, ttlTxt, msgTxt, geoData={ 'x': 62.5 * d.px, 'y': 50 * d.py, 'xdim': 70 * d.px, 'ydim': 50 * d.py }, btnDefs=None, ttlData=None, bdData=None): self.app = app self.disp = disp self.view = view self.ttlTxt = ttlTxt self.msgTxt = msgTxt self.btnDefs = btnDefs self.x = geoData['x'] self.y = geoData['y'] self.xdim = geoData['xdim'] self.ydim = geoData['ydim'] self.bcg = pg.Surface((self.xdim, self.ydim), pg.SRCALPHA) # per-pixel alpha self.bcg.fill(self.app.textView_col) ttlYdim = ttlProp * self.ydim ttlY = self.y - (self.ydim - ttlYdim) / 2 bdDim = self.ydim - ttlYdim bdY = self.y + (self.ydim - bdDim) / 2 if bdData is not None: bdFont = bdData['font'] else: bdFont = self.app.msgBdFont self.ttlRect = rl.RectLabel( app=self.app, pos=(self.x, ttlY), dim=(70 * d.px, ttlYdim), text=self.ttlTxt, font=self.app.msgTtlFont, # fontCol = d.font_col_inv, bcgCol=d.brightenColor(self.app.textView_col)) # self.ttl = rl.RectLabel(self.app, # {'x':self.x, 'y': self.y - self.ydim/2 + 5*d.py, 'xdim': 70*d.px, 'ydim': 10*d.py}, # {'txt':self.ttlTxt,'txtDim':4*d.px,'color':d.brightenColor(self.app.textView_col)}) self.msgRect = rl.RectLabel( app=self.app, pos=(self.x, bdY), dim=(70 * d.px, bdDim), text=self.msgTxt, font=bdFont, # fontCol = d.font_col_inv, # bcgCol = d.brightenColor(self.app.textView_col) txtMode='mpta', scaleFactor=0.85) # self.msg = rl.RectLabel(self.app, # {'x':self.x, 'y': self.y, 'xdim': 70*d.px, 'ydim': 10*d.py}, # {'txt':self.msgTxt,'txtDim':2.5*d.px,'color':self.app.textView_col}) # self.font = pg.font.SysFont('Arial', int(4*d.px)) self.initButArea()
def __init__(self, app, prevView=None): self.title = 'TESTING' self.btnDefs = [({ 'label': 'START', 'id': 'startBtn', 'funct': self.startTest }, { 'label': 'TESTS', 'id': 'testFilesBtn', 'funct': self.toTestFiles }, { 'label': 'EDIT', 'id': 'editBtn', 'funct': self.edit }, { 'label': 'BACK', 'id': 'bckBtn', 'funct': self.back }), ({}, { 'label': 'STOP', 'id': 'stopBtn', 'funct': self.stopTest }, {}, {}), ({ 'label': 'BREAK\nHEIGHT', 'id': 'selectBtn', 'funct': self.setBreakHeight }, { 'label': 'SELECT', 'id': 'selectBtn', 'funct': self.selectBtn }, {}, { 'label': 'REJECT', 'id': 'bckBtn', 'funct': self.drop })] self.saveBtnDef = { 'label': 'SAVE', 'id': 'saveBtn', 'funct': self.save } super().__init__(app, prevView) self.streaming = False self.numBtnX = self.cax self.numBtnY = self.cay self.resetVectors() self.drawPots = False self.drawXY = False self.tests = 0 self.startGraph() self.lastDataT = t.time() self.dataInt = 0.1 self.inVals = 0 self.tr = 0 self.ta = 0 self.initPreTestInfoLayout() self.inPrRect = rl.RectLabel(app=self.app, pos=(self.cax, self.cay), dim=(70 * d.px, 70 * d.py), text='TESTING\nIN PROGRESS', font=self.app.viewTtlFont, fontCol=self.app.font_col, bcgCol=d.light_green, scaleFactor=0.7) #in progress rectangle self.postItems = [] self.setPostItemFocusNum(0) self.envDataFlags = [0] * 4 self.initConfMsgsShown = False self.postItems.append( nl.NoteList(self.app, self.disp, { 'x': self.cax - 28 * d.px, 'y': self.cay, 'xdim': 20 * d.px, 'ydim': 25 * d.py }, listName='postTestNotes', hasFocus=True)) self.postItems.append( vb.ViewBtn(app=self.app, pos=(self.cax - 4 * d.px, self.cay + 42 * d.py), dim=(22 * d.px, 12 * d.py), label='Load', value='F', funct=self.switchLoadMode, focus=False, formating=lambda lab, val: lab + ': ' + str(val))) self.postItems.append( vb.ViewBtn(app=self.app, pos=(self.cax + 22 * d.px, self.cay + 42 * d.py), dim=(22 * d.px, 12 * d.py), label='Rot.', value='IMU', funct=self.switchRotMode, focus=False, formating=lambda lab, val: lab + ': ' + str(val)))
def __init__(self, app, prevView=None): self.btnDefs = [( { 'label': 'SAVE', 'id': 'saveBtn', 'funct': self.save }, {}, #'label': 'SELECT', 'id': 'selectBtn', 'funct': self.select {}, { 'label': 'BACK', 'id': 'bckBtn', 'funct': self.back })] self.title = 'COLOR TESTING' super().__init__(app, prevView) self.stnBtnDefs = ({ 'label': 'R_BCG', 'id': 'R_BCG', 'funct': None }, { 'label': 'G_BCG', 'id': 'G_BCG', 'funct': None }, { 'label': 'B_BCG', 'id': 'B_BCG', 'funct': None }, { 'label': 'R_BOX', 'id': 'R_BOX', 'funct': None }, { 'label': 'G_BOX', 'id': 'G_BOX', 'funct': None }, { 'label': 'B_BOX', 'id': 'B_BOX', 'funct': None }, { 'label': 'R_FONT', 'id': 'R_FONT', 'funct': None }, { 'label': 'G_FONT', 'id': 'G_FONT', 'funct': None }, { 'label': 'B_FONT', 'id': 'B_FONT', 'funct': None }) self.origBcgCol = self.app.bcg_col # self.colors = [[0]*3 for i in range(3)] self.colors = [ list(self.app.bcg_col), list(self.app.textView_col), list(self.app.font_col) ] self.rL = rl.RectLabel(app=self.app, pos=(84 * d.px, 35 * d.py), dim=(23 * d.px, 20 * d.py), text='Testing', font=self.app.msgTtlFont) # self.rL = rl.RectLabel(self.app, # {'x': 80*d.px, 'y': 35*d.py, 'xdim':25*d.px, 'ydim': 20*d.py}, # {'txt': 'Testing', 'txtDim': 6*d.px, 'color': self.app.textView_col}) self.rL2 = rl.RectLabel(app=self.app, pos=(84 * d.px, 65 * d.py), dim=(20 * d.px, 15 * d.py), text='T', font=self.app.stnBtnFont) # self.rL2 = rl.RectLabel(self.app, # {'x': 80*d.px, 'y': 65*d.py, 'xdim':20*d.px, 'ydim': 15*d.py}, # {'txt': 'T', 'txtDim': 6*d.px, 'color': self.app.textView_col}) self.numStnBtnRow = 3 self.numStnBtnCom = 3 self.setStnFocusNum(0) self.stnBtnsCols = (self.cax - 30 * d.px, self.cax - 15 * d.px, self.cax) self.stnBtnsRows = (self.cay - 18 * d.py, self.cay, self.cay + 18 * d.py) self.addStnBtns()