def test_validation(self): d = Dropdown(['a', 'b', 'c']) for good_object in ('a', 'b', 'c', u'a'): d.value = good_object for bad_object in (0, []): with self.assertRaises(TypeError): d.value = bad_object for bad_object in ('not in it'): with self.assertRaises(ValueError): d.value = bad_object
def test_validation(self): d = Dropdown(['a', 'b', 'c']) for good_object in ('a', 'b', 'c', u'a'): d.value = good_object for bad_object in (0, []): with self.assertRaises(TypeError): d.value = bad_object for bad_object in ('not in it'): with self.assertRaises(ValueError): d.value = bad_object
def test_def_change_callback(self): xs = [] d = Dropdown(['a', 'b']) @d.def_change_callback def _(): xs.append(1) d.value = 'b' self.assertEqual([1], xs)
def test_def_change_callback(self): xs = [] d = Dropdown(['a', 'b']) @d.def_change_callback def _(): xs.append(1) d.value = 'b' self.assertEqual([1], xs)
def guiEditPlaylist(self, pl): # self.cleanUI() self.GuiMain_BtnGrid() self.plsnggrid = Grid(n_rows=len(pl.songs), n_columns=10) # playlistlist = PLs.Playlistlist[:] for num, sng in enumerate(pl.songs[:]): # print(f"song {song} song.name {song.name} num {num}") n = Text(str(num)) t = Text(sng.name) plsongdata = pl.used_songs[sng.name] delaytime = Text(text=plsongdata[0]) delayset = TextField(value=str(plsongdata[0])) songlengthset = TextField(value=str(plsongdata[1])) # songlengthset.value = str(plsongdata[1])str videodd = Dropdown(FM.videolist) videodd.value = plsongdata[2] rup = self.plsngupBtn(pl, sng) rdown = self.plsngdownBtn(pl, sng) rsngupdate = self.plsngupdateBtn(pl, sng, delayset) rdelete = self.plsngdeleteBtn(pl, sng) # rreboot = self.raspsrebootBtn(rasp) self.plsnggrid[num, 0] = n self.plsnggrid[num, 1] = t self.plsnggrid[num, 2] = delaytime self.plsnggrid[num, 3] = delayset self.plsnggrid[num, 4] = songlengthset self.plsnggrid[num, 5] = videodd self.plsnggrid[num, 6] = rup self.plsnggrid[num, 7] = rdown self.plsnggrid[num, 8] = rsngupdate self.plsnggrid[num, 9] = rdelete # self.plgrid[num, 6] = rreboot self.plsong = Dropdown(Songs.get_DDList()) pausefield = TextField("0") songlengthfield = TextField("120") # songlengthfield = TextField("120") videodd = Dropdown(FM.videolist) self.newsngBtn = self.plsngnewBtn(pl, self.plsong, pausefield, songlengthfield, videodd) self.body.append(self.plsnggrid) self.body.append(self.plsong) self.body.append(pausefield) self.body.append(songlengthfield) self.body.append(videodd) self.body.append(self.newsngBtn)
def test_set_value(self): d = Dropdown(['a', 'b', 'c']) d.value = 'b' self.assertEqual('b', d.value) d.value = 'c' self.assertEqual('c', d.value)
def editRaspMenu(self, rasp): self.GuiMain_BtnGrid() self.raspedgrid = Grid(n_rows=3, n_columns=3) RaspMenuTitle = Text(f"Editiere {rasp.name}") n1 = Text("Name") n2 = Text("IP") n3 = Text("Description") nda1 = Text(rasp.name) nda2 = Text(str(rasp.IP)) nda3 = Text(rasp.description) self.rnamefield = TextField(value=rasp.name) self.rIPfield = TextField(value=rasp.IP) self.rDescfield = TextField(value=rasp.description) self.raspedgrid[0, 0] = n1 self.raspedgrid[1, 0] = n2 self.raspedgrid[2, 0] = n3 self.raspedgrid[0, 1] = nda1 self.raspedgrid[1, 1] = nda2 self.raspedgrid[2, 1] = nda3 self.raspedgrid[0, 2] = self.rnamefield self.raspedgrid[1, 2] = self.rIPfield self.raspedgrid[2, 2] = self.rDescfield trenner = Text( "---------------------------------------------------------------------" ) # Songlist self.raspSonglistgrid = Grid(n_rows=len(rasp.songs), n_columns=8) for num, sng in enumerate(rasp.songs): sngname = Text(sng) files = rasp.songs[sng] sngfilename = Text(files[0]) # self.sngFiletextfield = TextField(value=rasp.songs[sng]) filedropdown = Dropdown(FM.filelist) if sngfilename.text in FM.filelist: filedropdown.value = sngfilename.text sngscriptname = Text(files[1]) scriptdropdown = Dropdown(FM.scriptlist) if sngscriptname.text in FM.scriptlist: scriptdropdown.value = sngscriptname.text updateBtn = self.rsngupdateBtn(rasp.songs, sng, rasp, filedropdown, scriptdropdown) uploadBtn = self.rsnguploadBtn(rasp, filedropdown, scriptdropdown) deleteBtn = self.rsngdeleteBtn(rasp.songs, sng, rasp) self.raspSonglistgrid[num, 0] = sngname self.raspSonglistgrid[num, 1] = sngfilename self.raspSonglistgrid[num, 2] = filedropdown self.raspSonglistgrid[num, 3] = sngscriptname self.raspSonglistgrid[num, 4] = scriptdropdown self.raspSonglistgrid[num, 5] = updateBtn self.raspSonglistgrid[num, 6] = uploadBtn self.raspSonglistgrid[num, 7] = deleteBtn # self.raspSonglistgrid[num, 5] = deleteBtn # new song dropdown newText = Text("New Song") SongNamelist = Songs.get_DDList() print(SongNamelist) print(rasp.songs) for son in SongNamelist[:]: if son in rasp.songs: SongNamelist.remove(son) self.rsongdrop = Dropdown(SongNamelist) self.newsongfile = Dropdown(FM.filelist) self.newsongfile.value = FM.filelist[1] self.newsongscript = Dropdown(FM.scriptlist) self.newsongscript.value = FM.scriptlist[1] self.raddButton = self.appendsongtoraspbtn(rasp) self.NewRSongCont = Container(newText, self.rsongdrop, self.newsongfile, self.newsongscript, self.raddButton) # SaveButton saveraspeditBtn = self.saveraspeditBtn(rasp) self.body.append(RaspMenuTitle) self.body.append(self.raspedgrid) self.body.append(trenner) self.body.append(self.raspSonglistgrid) self.body.append(self.NewRSongCont) self.body.append(saveraspeditBtn)
def EditSong(self, song): self.GuiMain_BtnGrid() # print(song.name) self.soedgrid = Grid(n_rows=3, n_columns=3) # if self.soedgrid in self.body: # self.body.remove(self.soedgrid) n1 = Text("Name") n2 = Text("used_pis") n3 = Text("description") nda1 = Text(song.name) nda2 = Text(str(song.used_pis)) nda3 = Text(song.description) self.ns1 = TextField(value=song.name) self.ns2 = TextField("pis") self.ns3 = TextField(value=song.description) self.soedgrid[0, 0] = n1 self.soedgrid[1, 0] = n2 self.soedgrid[2, 0] = n3 self.soedgrid[0, 1] = nda1 self.soedgrid[1, 1] = nda2 self.soedgrid[2, 1] = nda3 self.soedgrid[0, 2] = self.ns1 # self.soedgrid[1, 2] = self.ns2 self.soedgrid[2, 2] = self.ns3 trenner = Text( "---------------------------------------------------------------------" ) # Rasplist of this song with filename self.rasedgrid = Grid(n_rows=len(song.used_pis), n_columns=6) for num, rasp in enumerate(song.used_pis): print(str(num) + rasp) rname = Text(str(rasp)) rfilename = Text(str(song.used_pis[rasp])) # self.rfilenameTfield = TextField(value=song.used_pis[rasp]) dropdown = Dropdown(FM.filelist) if rfilename.text in FM.filelist: dropdown.value = rfilename.text # str rasp --> rasp obj raspname = rasp for ra in RBs.Rasplist: if ra.name == rasp: rasp = ra break rupdate = self.sng_raspUpdateBtn(song.used_pis, rasp.name, song, dropdown) # better take the saved not the dropdown rupload = self.rsnguploadBtn(rasp, rfilename.text) rdelete = self.sng_raspDeleteBtn(song, rasp.name) self.rasedgrid[num, 0] = rname self.rasedgrid[num, 1] = rfilename self.rasedgrid[num, 2] = dropdown # self.rfilenameTfield self.rasedgrid[num, 3] = rupdate self.rasedgrid[num, 4] = rupload self.rasedgrid[num, 5] = rdelete dropdown = Dropdown(FM.filelist) newText = Text("New Rasp") RaspNamelist = [] for ra in RBs.Rasplist: if ra.name not in song.used_pis: RaspNamelist.append(ra.name) RaspNamelist.append(" ") raspsdrop = Dropdown(RaspNamelist) # self.newrasfilename = TextField(value="Unknown File") filedropdown = Dropdown(FM.filelist) raddButton = self.appendRasptoSongBtn(song, raspsdrop, filedropdown) self.NewRaspCont = Container(newText, raspsdrop, filedropdown, raddButton) # print("appending EditSong UI") self.body.append(self.title) self.body.append(self.soedgrid) # self.body.append(self.rasedgrid) self.body.append(self.rasedgrid) self.body.append(self.NewRaspCont) saveBtn = self.songeditsaveBtn(song) self.body.append(saveBtn)
def test_set_value(self): d = Dropdown(['a', 'b', 'c']) d.value = 'b' self.assertEqual('b', d.value) d.value = 'c' self.assertEqual('c', d.value)