def main(self): wid = gui.VBox(width=500, height=500, style={ 'margin': '5px auto', 'padding': '10px' }) lbl_description = gui.Label("""Example about TableWidget usage. Change rows and columns count in order to see the behaviour. After changing the size, 'Fill the table' content by means of the button.""" ) wid.append(lbl_description) table = gui.TableWidget(10, 3, True, True, width=300, height=300) table.style['font-size'] = '8px' container = gui.HBox(width='100%') lbl_row_count = gui.Label('Rows:') spin_row_count = gui.SpinBox(10, 0, 15) spin_row_count.onchange.do(self.on_row_count_change, table) container.append(lbl_row_count) container.append(spin_row_count) wid.append(container) container = gui.HBox(width='100%') lbl_column_count = gui.Label('Columns:') spin_column_count = gui.SpinBox(3, 0, 4) spin_column_count.onchange.do(self.on_column_count_change, table) container.append(lbl_column_count) container.append(spin_column_count) wid.append(container) bt_fill_table = gui.Button('Fill table', width=100) bt_fill_table.onclick.do(self.fill_table, table) wid.append(bt_fill_table) chk_use_title = gui.CheckBoxLabel('Use title', True) chk_use_title.onchange.do(self.on_use_title_change, table) wid.append(chk_use_title) self.fill_table(table, table) table.on_item_changed.do(self.on_table_item_changed) wid.append(table) # returning the root widget return wid
def build_services_box(self): """Build the services box from remi components""" lb_title = gui.Label("Services", style=ServicesBoxStyles["title"]) self.vbox_services_table = gui.TableWidget( 0, 3, use_title=False, style=ServicesBoxStyles["table"]) vbox_services_section = gui.VBox(style=ServicesBoxStyles["container"]) hbox_refresh_bar = self.refresh_bar.build_refresh_bar() vbox_services_section.append(lb_title) vbox_services_section.append(self.vbox_services_table) vbox_services_section.append(hbox_refresh_bar) return vbox_services_section
def build_script_box(self): """Build the Scripts box/list from remi components""" lb_title = gui.Label("Scripts", style=ScriptBoxStyles["title"]) self.lb_lastrun_script = gui.Label( "No script run this session.", style=ScriptBoxStyles["lastrun_lb_title"]) hbox_lastrun = gui.HBox(style=ScriptBoxStyles["lastrun_hbox_style"]) hbox_lastrun.append(self.lb_lastrun_script) self.vbox_scripts_table = gui.TableWidget( 0, 2, use_title=False, style=ScriptBoxStyles["table"]) vbox_script_section = gui.VBox(style=ScriptBoxStyles["container"]) vbox_script_section.append(lb_title) vbox_script_section.append(self.vbox_scripts_table) vbox_script_section.append(hbox_lastrun) return vbox_script_section
def test_init(self): widget = gui.TableWidget(2, 3, use_title=True, editable=False) assertValidHTML(widget.repr())
def generateAnnotatedTranscript(self): retval = [] #creating the table to see tList = self.userProfile.data[self.userProfile.date-1]['turnList'] numRows = len(tList)+1 for x in tList: numRows += len(x['Argumentation'])-1 print("\t\t", numRows) table = gui.TableWidget(n_rows = numRows, n_columns = 6, width="90%") table.style['margin'] = "auto" #table.style['overflow'] = "hidden" table.item_at(0,0).set_text('Turn') table.item_at(0,0).attributes['annotTranscript'] = "0" table.item_at(0,1).set_text('Speaker') table.item_at(0,1).attributes['annotTranscript'] = "0" table.item_at(0,2).set_text('Talk') table.item_at(0,2).attributes['annotTranscript'] = "0" table.item_at(0,2).style['width'] = "60%" #table.item_at(0,3).set_text("ArgMove") table.item_at(0,3).attributes['annotTranscript'] = "0" aDropDown = gui.DropDown.new_from_list(['ArgMove','claim','evidence','explanation']) aDropDown.onchange.do(self.tableFunc) aDropDown.set_value("ArgMove") table.item_at(0,3).append(aDropDown) table.item_at(0,3).style['width'] = "10%" #table.item_at(0,4).set_text('Specificity') table.item_at(0,4).attributes['annotTranscript'] = "0" sDropDown = gui.DropDown.new_from_list(['Specificity', 'low', 'med', 'high']) sDropDown.onchange.do(self.tableFunc) sDropDown.set_value("Specificity") table.item_at(0,4).append(sDropDown) table.item_at(0,4).style['width'] = "10%" #table.item_at(0,5).set_text('Collaboration') table.item_at(0,5).attributes['annotTranscript'] = "0" cDropDown = gui.DropDown.new_from_list(['Collaboration', 'new','extension','challenge','agree']) cDropDown.onchange.do(self.tableFunc) cDropDown.set_value("Collaboration") table.item_at(0,5).append(cDropDown) table.item_at(0,5).style['width'] = "10%" rowIdx = 1 turnIdx = 1 for turn in tList: #add in the turnnum table.item_at(rowIdx,0).set_text(turn['TurnNum']) table.item_at(rowIdx,0).attributes['rowspan'] = len(turn['Argumentation']) table.item_at(rowIdx,0).attributes['tColor'] = turnIdx%2 #speaker info table.item_at(rowIdx,1).set_text(turn['Student']) table.item_at(rowIdx,1).attributes['rowspan'] = len(turn['Argumentation']) table.item_at(rowIdx,1).attributes['tColor'] = turnIdx%2 #collablabel table.item_at(rowIdx,5).set_text(turn['Collaboration']) table.item_at(rowIdx,5).attributes['rowspan'] = len(turn['Argumentation']) table.item_at(rowIdx,5).attributes['tColor'] = turnIdx%2 table.item_at(rowIdx,5).attributes[turn['Collaboration']] = 0 for idx, x in enumerate(turn['Argumentation']): table.item_at(rowIdx, 2).set_text(x['Text']) table.item_at(rowIdx, 2).style['text-align'] = 'left' table.item_at(rowIdx, 2).attributes['tColor'] = turnIdx%2 table.item_at(rowIdx,3).set_text(x['ArgMove']) table.item_at(rowIdx,3).attributes['tColor'] = turnIdx%2 table.item_at(rowIdx,3).attributes[x['ArgMove']] = 0 table.item_at(rowIdx,4).set_text(x['Specificity']) table.item_at(rowIdx,4).attributes['tColor'] = turnIdx%2 table.item_at(rowIdx,4).attributes[x['Specificity']] = 0 # delete the table items so that the cells don't get shifted # setting to empty string because 'None' causes the text 'none' # to be printed for some reason if(idx != 0): table.children[str(rowIdx)].children["0"] = "" table.children[str(rowIdx)].children["1"] = "" table.children[str(rowIdx)].children["5"] = "" rowIdx += 1 turnIdx += 1 #doing some table styling #for key in table.children: # if(key != "0"): # table.children[key].attributes['onMouseOver']="this.style.color=\'#0F0\'" # table.children[key].attributes['onMouseOut']="this.style.color=\'#00F\'" retval.append(table) return retval
def create_track_content(self, discIDX, goalType, goalCat, goal): #how many students improved their number of warrants. print( "This function is for making the tables on tracking at student level" ) print("This function is currently unused") #loop through prior discussion students = {} for turn in self.data[discIDX - 1]['turnList']: if (turn['Student'] != 'teacher'): if (turn['Student'] not in students): students[turn['Student']] = [0, 0] if (goalType == "Argumentation"): for elem in turn['Argumentation']: if (elem[goalCat] == goal): students[turn['Student']][0] += 1 for turn in self.data[discIDX]['turnList']: if (turn['Student'] != 'teacher'): if (turn['Student'] not in students): students[turn['Student']] = [0, 0] if (goalType == "Argumentation"): for elem in turn['Argumentation']: if (elem[goalCat] == goal): students[turn['Student']][1] += 1 #create a table of how many students improved their score tableElems = [["Number Improved", "Number did not Improve"], [0, 0]] for k in students: if (students[k][0] < students[k][1]): students[k] = True tableElems[1][0] += 1 else: students[k] = False tableElems[1][1] += 1 tableElems[1][0] = str(tableElems[1][0]) tableElems[1][1] = str(tableElems[1][1]) table = gui.Table(width="25%", style={'background-color': 'light-blue'}) table.append_from_list(tableElems, fill_title=True) self.data[discIDX]['improvementDetail'] = students json.dump( self.data[discIDX], open(findByDate(BASEPATH, self.teacher, str(discIDX + 1), classifier=self.userProfile.classifier), 'w', encoding="utf-8")) #ask about what the teacher did lbl = gui.Label("What did you do to achieve this goal?", width="25%") improvement = gui.DropDown(width="50%") #init with default values improvement.append("Activity") improvement.append("Mini-Lesson") improvement.append("More discussions") #when they select improvement.onchange.do(partial(self.improvementDropdown, discIDX)) #checkBoxes = [] #checkBoxes.append(gui.CheckBoxLabel(label="Activity")) #checkBoxes.append(gui.CheckBoxLabel(label="Mini-Lesson")) #checkBoxes.append(gui.CheckBoxLabel(label="More Discussions")) #create a table of the students and what they were improved by self.studentDetail = gui.TableWidget(width="100%") if ('improvementAction' in self.data[discIDX]): improvement.select_by_value( self.data[discIDX]['improvementAction']) else: self.data[discIDX]['improvementAction'] = "None Set" self.fill_improvement_table(discIDX) #butt = gui.Button("refresh table") #butt.onclick.do(partial(self.update_improvement_table, discIDX)) cont = DEFAULT_HIDDEN_CONTAINER() cont.append([table, lbl, improvement, self.studentDetail]) cont.attributes['discID'] = str(discIDX + 1) return cont
def main(self): ''' Set up structure of gui webpage, write initial data to the table. ''' # Current machine: self.currentMachine = 0 cont = gui.Container(width="75%", style={ "display": "block", "margin-left": "auto", "margin-right": "auto" }) ser = serial.Serial() self.title = gui.Label("Auto IP Config", width="100%", margin="10px", style={ "margin-top": "20px", "font-size": "20px", "text-align": "center" }) self.table = gui.TableWidget(2, 5, True, True) self.table.item_at(0, 0).set_text("Machine #") self.table.item_at(0, 1).set_text("IP") self.table.item_at(0, 2).set_text("Netmask") self.table.item_at(0, 3).set_text("Gateway") self.table.item_at(0, 4).set_text("Rack Number") self.spin = gui.SpinBox(self.currentMachine, 0, 100, width=200, height=30, margin="10px") self.screenTable = gui.TableWidget(9, 1, True, True, width="100%") writeMachine2Table(yeet, self.table, self.currentMachine) nextBT = gui.Button("Next Machine!", width=200, height=30, margin="10px") prevBT = gui.Button("Previous Machine!", width=200, height=30, margin="10px") self.connBT = gui.Button("Connect Machine!", width=200, height=30, margin="10px", style={"background-color": "red"}) self.confBT = gui.Button("Configure Machine!", width=200, height=30, margin="10px", style={"background-color": "red"}) self.exitBT = gui.Button("Exit!", width=200, height=30, margin="10px", style={ "display": "block", "margin-left": "auto", "margin-right": "auto" }) nextBT.onclick.do(self.nextMachinePressed) prevBT.onclick.do(self.prevMachinePressed) self.connBT.onclick.do(self.connMachinePressed) self.confBT.onclick.do(self.confMachinePressed) self.exitBT.onclick.do(self.exitPressed) cont.append([ self.title, self.table, nextBT, prevBT, self.connBT, self.confBT, self.spin, self.screenTable, self.exitBT ]) self.spin.onchange.do(self.on_spin_change) return cont