def main(self): #creating a container GridBox type main_container = gui.GridBox(width='100%', height='100%', style={'margin': '0px auto'}) label = gui.Label('This is a label') label.style['background-color'] = 'lightgreen' button = gui.Button('Change layout', height='100%') button.onclick.do(self.redefine_grid, main_container) text = gui.TextInput() main_container.set_from_asciiart( """ |label |button | |label |text | |label |text | |label |text | |label |text | """, 10, 10) main_container.append({'label': label, 'button': button, 'text': text}) # returning the root widget return main_container
def main(self): #creating a container GridBox type main_container = gui.GridBox(width='100%', height='100%', style={'margin': '0px auto'}) label = gui.Label('This is a label') label.style['background-color'] = 'lightgreen' button = gui.Button('Change layout', height='100%') button.onclick.connect(self.redefine_grid, main_container) text = gui.TextInput() #defining layout matrix, have to be iterable of iterable main_container.define_grid(['ab', 'ac']) main_container.append({'a': label, 'b': button, 'c': text}) #setting sizes for rows and columns main_container.style.update({ 'grid-template-columns': '10% 90%', 'grid-template-rows': '10% 90%' }) # returning the root widget return main_container
def buildRow(self, rowName, rowStatus, header=False): gridStyle = { 'grid-template-columns': '33% 33% 33%', 'margin': '0px auto' } headerStyle = { 'background-color': 'lavender', 'text-align': 'center', 'vertical-align': 'middle', 'font-weight': 'bold' } rowStyle = {'text-align': 'center', 'vertical-align': 'middle'} nameLabel = gui.Label(rowName, style=rowStyle) statusLabel = gui.Label(rowStatus, style=rowStyle) # need to reconcile what's in the directory when we startup with the statuses on the table. if Path(f"{sem_path}/{rowName}").exists(): statusLabel.style['background-color'] = 'lightcoral' statusLabel.text = 'Blocked' else: statusLabel.style['background-color'] = 'lightgreen' statusLabel.text = 'Open' if header: changeButton = gui.Label("Change") changeButton.style.update(headerStyle) nameLabel.style.update(headerStyle) statusLabel.style.update(headerStyle) height = 25 else: changeButton = gui.Button("ChangeState") changeButton.associatedLabel = statusLabel self.statuses[rowName] = statusLabel changeButton.onclick.do(self.on_change_rule_state, statusLabel, rowName) height = 50 gridContainer = gui.GridBox(width='100%', height=height, style=gridStyle) gridContainer.set_from_asciiart( '|name |status |change |') gridContainer.append({ 'name': nameLabel, 'status': statusLabel, 'change': changeButton }) return gridContainer
def main(self): # creating a container GridBox type self.main_container = gui.GridBox(width='100%', height='100%', style={ 'margin': '0px auto', 'font-family': 'Verdana' }) title = gui.Label('Hallo, herzlich willkommen zu Werwolf!', width='100%', style={ 'font-size': '2em', 'display': 'block', 'margin': 'auto' }) login = gui.Button('Anmelden', height='20%', style={ 'display': 'block', 'margin': 'auto' }) login.onclick.do(self.on_button_pressed) config = gui.Button('Spiel konfigurieren', height='20%', style={ 'display': 'block', 'margin': 'auto' }) config.onclick.do(self.on_button_pressed) # defining layout matrix, have to be iterable of iterable self.main_container.define_grid(['t', 'a', 'c']) self.main_container.append({'t': title, 'a': login, 'c': config}) # setting sizes for rows and columns self.main_container.style.update({ 'grid-template-columns': '100%', 'grid-template-rows': '10% 45% 45%' }) # returning the root widget return self.main_container
def initWheelControls(self, robot): wheelControlsBox = self.sectionBox() def resetWheelButtons(widget): for controller in self.wheelBtns: controller.reset() resetBtn = gui.Button("Reset") resetBtn.onclick.connect(resetWheelButtons) wheelControlsBox.append(resetBtn) grid = gui.GridBox() grid.define_grid([['Cd', 'Dd', 'space1', 'Cs', 'Ds'], ['Ad', 'Bd', 'space1', 'As', 'Bs']]) wheelControlsBox.append(grid) self.wheelBtns = [] def addButton(b): grid.append(b.button, b.name) self.wheelBtns.append(b) for wheelIndex in range(4): addButton( WheelButtonController( wheelIndex, robot.superDrive.wheels[wheelIndex].angledWheel, robot, False)) addButton( WheelButtonController(wheelIndex, robot.superDrive.wheels[wheelIndex], robot, True)) grid.append(self.spaceBox(), 'space1') grid.append(self.spaceBox(), 'space2') return wheelControlsBox
def test_init(self): w = gui.GridBox() l = gui.Label('box_label') w.append(l) self.assertIn('box_label',w.repr()) assertValidHTML(w.repr())
def addContent(self): #strength and weakness box swBox = DEFAULT_VISIBLE_CONTAINER() #swBox.attributes['width'] = '95%' swBox.style['width'] = '95%' swBox.style['margin'] = '10px auto' swBox.style['float'] = 'none' swBox.style['background-color'] = 'cyan' #Text one lblOne = gui.Label('1. Strengths and Weaknesses of the Discussion: ', margin='1%') lblOne.style['background-color'] = 'white' swBox.append(lblOne) #grid of strenghts and weaknesses swGrid = gui.GridBox(width="98%", margin="10px 1% 20px") swGrid.style['float'] = 'none' grid = [['pos00', 'pos01']] swGrid.define_grid(grid) strength = gui.Container(width="100%", style={ 'background-color': 'palegreen', 'padding': "10px 0px 10px" }) weakness = gui.Container(width="100%", style={ 'background-color': 'lightgoldenrodyellow', 'padding': "10px 0px 10px" }) strength.append(gui.Label("Strengths:")) strength.append( gui.Label("-%s" % (self.strengths_text['Strengths'][self.userProfile.data[ int(self.userProfile.date - 1)]['strengths'][0]]), style={'padding-left': '2%'})) strength.append( gui.Label("-%s" % (self.strengths_text['Strengths'][self.userProfile.data[ int(self.userProfile.date - 1)]['strengths'][1]]), style={'padding-left': '2%'})) weakness.append(gui.Label("Weaknesses:")) weakness.append( gui.Label("-%s" % (self.strengths_text['Weaknesses'][self.userProfile.data[ int(self.userProfile.date - 1)]['weaknesses'][0]]), style={'padding-left': '2%'})) weakness.append( gui.Label("-%s" % (self.strengths_text['Weaknesses'][self.userProfile.data[ int(self.userProfile.date - 1)]['weaknesses'][1]]), style={'padding-left': '2%'})) swGrid.append(strength, 'pos00') swGrid.append(weakness, 'pos01') swBox.append(swGrid) #creating the goal setting box gsBox = DEFAULT_VISIBLE_CONTAINER() gsBox.style['width'] = '95%' gsBox.style['margin'] = '10px auto' gsBox.style['float'] = 'none' gsBox.style['background-color'] = 'cyan' lblTwo = gui.Label( "2. Select a Goal for Improving the Next Student Discussion:", margin="1%", style={'background-color': 'white'}) gsBox.append(lblTwo) radioBox = gui.VBox(width='98%', margin="10px 1% 20px") radioBox.style['display'] = 'block' self.gsRadio1 = RadioButtonWithLabel(self.strengths_text['Goals'][ self.userProfile.getCurrentTranscript()['weaknesses'][0]], False, 'groupGoal', margin="5px 0px", style={'padding-left': '1px'}) self.gsRadio2 = RadioButtonWithLabel(self.strengths_text['Goals'][ self.userProfile.getCurrentTranscript()['weaknesses'][1]], False, 'groupGoal', margin="5px 0px", style={'padding-left': '1px'}) #adding a custom field to know what shit is happening self.gsRadio1.idx = self.userProfile.data[int(self.userProfile.date - 1)]['weaknesses'][0] self.gsRadio2.idx = self.userProfile.data[int(self.userProfile.date - 1)]['weaknesses'][1] #enabling the action self.gsRadio1.onchange.do(self.radio_changed) self.gsRadio2.onchange.do(self.radio_changed) #selecting option self.selectButton() radioBox.append([self.gsRadio1, self.gsRadio2]) #register the javascript code for selecting the button so it occurs on load to self.onload_functions_js.append( ('activate_radio_button', partial(self.selectButtonJS))) #self.onload_functions.append(('activate_radio_button', partial(self.selectButton))) gsBox.append(radioBox) #creating the box for the instructional resources isBox = DEFAULT_VISIBLE_CONTAINER() isBox.style['display'] = 'none' isBox.style['width'] = '95%' isBox.style['margin'] = '10px auto' isBox.style['float'] = 'none' isBox.style['background-color'] = 'cyan' lblThree = gui.Label( '3. Look at these instructional resources and incorporate them in your lessons before your next discussion:', margin='1%', style={'background-color': 'white'}) isBox.append(lblThree) linkBox = gui.VBox(width="98%", margin="10px 1% 20px", style={"background-color": 'white'}) linkBox.style['display'] = 'block' tTalk = gui.Label("Teacher Talk", margin="1px") tTalk.attributes['href'] = "/" tTalk.type = "a" mLess = gui.Label("Minilesson", margin="1px") mLess.attributes['href'] = "/" mLess.type = "a" acivi = gui.Label("Activity", margin="1px") acivi.attributes['href'] = "/" acivi.type = "a" linkBox.append(tTalk) linkBox.append(gui.Label(" ")) linkBox.append(mLess) linkBox.append(gui.Label(" ")) linkBox.append(acivi) self.isLinkKey = isBox.append(linkBox) self.page.append(swBox) self.page.append(gsBox) self.isKey = self.page.append(isBox) #activate the isBox if appropriate self.activateIS()
def generateOverviewInfo(self): labelText = ["Teacher: %s" % (self.userProfile.data[int(self.userProfile.date)-1]['Teacher']), "Date: %s" % (self.userProfile.data[int(self.userProfile.date)-1]['Date']), "Topic: %s" % (self.userProfile.data[int(self.userProfile.date)-1]['Topic']), "Number of Students: %s" % (self.userProfile.data[int(self.userProfile.date)-1]['NumStudents']), "Students Speaking: %s" % (self.userProfile.data[int(self.userProfile.date)-1]['NumStudentSpeakers']), "Number of Turns: %s" % (self.userProfile.data[int(self.userProfile.date)-1]['NumTurns']), "Teacher Turns: %.4s%%" % (self.userProfile.data[int(self.userProfile.date)-1]['TeacherPercentage']*100), "Avg Turns per Speaking Student: %.4s" % (self.userProfile.data[int(self.userProfile.date)-1]['AvgNumStudentTurns']),] retval = [gui.Label(x, width="100%", style={'text-align':'center', 'margin-top':'5px', 'margin-bottom':'5px'}) for x in labelText] for i in range(3): retval[i].style['font-size'] = '20px' graphics = gui.GridBox(width="100%") grid = [list(range(3)),list(range(3))] for i in range(len(grid)): for j in range(len(grid[i])): grid[i][j] = 'pos%s%s'%(i,j) graphics.append( gui.Label("Argumentation", style={'text-align':'center', 'font-size':'20px'}),'pos00') graphics.append( gui.Label("Specificity", style={'text-align':'center', 'font-size':'20px'}),'pos01') graphics.append( gui.Label("Collaboration", style={'text-align':'center', 'font-size':'20px'}),'pos02') argElems = list(self.userProfile.data[int(self.userProfile.date)-1]['graphData']['argMoveCount'].items()) argElems[1], argElems[2] = argElems[2], argElems[1] labels, plot_data = zip(*argElems) #print(plot_data) argPlot = MatplotImage() argPlot.style['margin'] = 'auto' argPlot.ax.pie(plot_data, labels=labels, autopct='%1.1f%%' ) #argPlot.ax.bar(range(len(labels)), plot_data, tick_label=labels) #argPlot.ax.legend(loc='lower center') argPlot.redraw() graphics.append(argPlot, 'pos10') labels, plot_data = zip(*self.userProfile.data[int(self.userProfile.date)-1]['graphData']['specifiCount'].items()) specPlot = MatplotImage() specPlot.style['margin'] = 'auto' specPlot.ax.pie(plot_data, labels=labels, autopct='%1.1f%%' ) #specPlot.ax.bar(range(len(labels)), plot_data, tick_label=labels ) #specPlot.ax.legend(loc='lower center') specPlot.redraw() graphics.append(specPlot, 'pos11') labels, plot_data = zip(*self.userProfile.data[int(self.userProfile.date)-1]['graphData']['collabCount'].items()) colPlot = MatplotImage() colPlot.style['margin'] = 'auto' colPlot.ax.pie(plot_data, labels=labels, autopct='%1.1f%%' ) #colPlot.ax.bar(range(len(labels)), plot_data, tick_label=labels ) #colPlot.ax.legend(loc='lower center') colPlot.redraw() graphics.append(colPlot, 'pos12') graphics.define_grid(grid) retval += [graphics] return retval
def create_disc_hist_objects(self): retval = [] title = gui.Label('Discussion History', width="100%", margin='auto', style={ 'text-align': 'center', 'font-size': '20px', 'margin-top': '5px', 'margin-bottom': '5px' }) retval.append(title) ##create some plots of the prior discussion if (self.userProfile.date == 1): retval.append( gui.Label('No prior discussions yet', width="100%", style={ 'text-align': 'center', 'margin-top': '5px', 'margin-bottom': '5px' })) return retval #default if date is not one #should add in switching between discussions table = gui.Table(width="100%", height="200px", style={'background-color': 'light-blue'}) tableCells = [("Discussion Number", "Instructional Goal", "Achieved")] #pull in the all of the date-1 goal files. for i in range(1, self.userProfile.date): goalPath = findByDate(BASEPATH, self.userProfile.teacher, str(i), filetype='goal', classifier=self.userProfile.classifier) print(goalPath) goalData = readGoalFile(goalPath) #check the next transcript for if the goal is in the strengths strList = self.userProfile.data[i]['strengths'] if (goalData['goalID'] in strList): achievedMsg = "Yes" else: achievedMsg = "No" tableCells.append((str(i), goalData['GoalText'], achievedMsg)) #tableCells.append(("2", "Increase the number of explanations the students give", "No??")) table.append_from_list(tableCells, fill_title=True) #modify the inspect so that someone can click it # ti = table.children["1"].children["3"] # ti.set_text("") # tib = gui.Button("Click to Inspect") # ti.append(tib) # self.trackContainer = self.DEFAULT_VISIBLE_CONTAINER() # self.trackContainer.style['background-color'] = 'aqua' # self.trackContainer.style['padding'] = "5px" # if(self.date == 3): # self.trackContainer.append(self.create_track_content(self.date-2, "Argumentation", "ArgMove" ,"explanation")) # self.trackContainer.append(self.create_track_content(self.date-1, "Argumentation", "ArgMove" ,"explanation")) # tib.onclick.do(partial(self.track_container_clicked, "2")) # if(self.date==3): # ti2 = table.children["2"].children["3"] # ti2.set_text("") # tib2 = gui.Button("Click to Inspect") # ti2.append(tib2) # tib2.onclick.do(partial(self.track_container_clicked, "3")) # #for i in table.children: # # if(i != "0"): # # ti = table.children[i].children # # ti["3"].set_text("") # # # # ti["3"].append() retval.append(table) # retval.append(self.trackContainer) #make a plot of the prior discussion graphics = gui.GridBox(width="100%") grid = [list(range(3))] for i in range(len(grid)): for j in range(len(grid[i])): grid[i][j] = 'pos%s%s' % (i, j) argLabels = list(self.userProfile.getCurrentTranscript()['graphData'] ['argMoveCount'].keys()) argY = [] argY_labels = [] indices = np.arange(self.userProfile.date - 1, max(-1, self.userProfile.date - 6), -1) for x in indices: arr = np.array([ self.userProfile.data[x]['graphData']['argMoveCount'][k] for k in argLabels ]) arr = arr / sum(arr) argY.insert(0, arr) argY_labels.insert(0, "Discussion %d" % (x + 1)) argPlot = self.create_graph_object(argY, argLabels, argY_labels) graphics.append(argPlot, 'pos00') specLabels = list(self.userProfile.getCurrentTranscript()['graphData'] ['specifiCount'].keys()) specY = [] specY_labels = [] indices = np.arange(self.userProfile.date - 1, max(-1, self.userProfile.date - 6), -1) for x in indices: arr = np.array([ self.userProfile.data[x]['graphData']['specifiCount'][k] for k in specLabels ]) arr = arr / sum(arr) specY.insert(0, arr) specY_labels.insert(0, "Discussion %d" % (x + 1)) specPlot = self.create_graph_object(specY, specLabels, specY_labels) graphics.append(specPlot, 'pos01') colLabels = list(self.userProfile.getCurrentTranscript()['graphData'] ['collabCount'].keys()) colY = [] colY_labels = [] indices = np.arange(self.userProfile.date - 1, max(-1, self.userProfile.date - 6), -1) for x in indices: arr = np.array([ self.userProfile.data[x]['graphData']['collabCount'][k] for k in colLabels ]) arr = arr / sum(arr) colY.insert(0, arr) colY_labels.insert(0, "Discussion %d" % (x + 1)) colPlot = self.create_graph_object(colY, colLabels, colY_labels) graphics.append(colPlot, 'pos02') graphics.define_grid(grid) retval += [graphics] return retval