def guisonglist(self): # if len(self.body) > 1: # self.body.remove(self.songgrid) self.GuiMain_BtnGrid() self.songgrid = Grid(n_rows=len(self.songlist), n_columns=5) snglist = Songs.Songlist[:] for num, song in enumerate(snglist): # print(f"song {song} song.name {song.name} num {num}") n = Text(str(num)) edit = self.sngEditBtn(song) play = self.sngPlayBtn(song) delete = self.sngDeleteBtn(song) t = Text(song.name) self.songgrid[num, 0] = n self.songgrid[num, 1] = t self.songgrid[num, 2] = edit self.songgrid[num, 3] = delete self.songgrid[num, 4] = play # self.body.append(self.songgrid) sngnameTF = TextField(value="Default") self.newSngBtn = self.newsongBtn(sngnameTF) self.spacer = Text(" --------------- ") # self.RaspMenuButton = self.raspMenuBtn() # PLMenuButton = self.PLMenuBtn() self.Bottombutton = Container(sngnameTF, self.newSngBtn) # self.body.append(self.newSngBtn) # prinbody(self.body) # self.cleanUI() self.updatesonggrid()
def test_construction(self): gui = GUI() GUI(Text("left"), Text("hi")) with self.assertRaises(TypeError): gui = GUI(0)
def guiRasplist(self): # if len(self.body) > 1: # self.body.remove(self.songgrid) self.GuiMain_BtnGrid() self.raspgrid = Grid(n_rows=len(RBs.Rasplist), n_columns=7) rasplist = RBs.Rasplist[:] for num, rasp in enumerate(rasplist): # print(f"song {song} song.name {song.name} num {num}") n = Text(str(num)) t = Text(rasp.name) ip = Text(rasp.IP) redit = self.raspEditBtn(rasp) rdelete = self.raspDeleteBtn(rasp) rshutdown = self.raspshutdownBtn(rasp) rreboot = self.raspsrebootBtn(rasp) self.raspgrid[num, 0] = n self.raspgrid[num, 1] = t self.raspgrid[num, 2] = ip self.raspgrid[num, 3] = redit self.raspgrid[num, 4] = rdelete self.raspgrid[num, 5] = rshutdown self.raspgrid[num, 6] = rreboot self.newRaspBtn = Button(text="New Rasp", callback=self.newrasp) # self.songmenubtn = self.songMenuBtn() self.body.append(self.raspgrid) self.body.append(self.newRaspBtn)
def guiPlaylists(self): # if len(self.body) > 1: # self.body.remove(self.songgrid) self.GuiMain_BtnGrid() self.plgrid = Grid(n_rows=len(PLs.Playlistlist), n_columns=5) playlistlist = PLs.Playlistlist[:] for num, pl in enumerate(playlistlist): # print(f"song {song} song.name {song.name} num {num}") n = Text(str(num)) t = Text(pl.name) used_songs = Text(str(pl.used_songs)) redit = self.plEditBtn(pl) rdelete = self.plDeleteBtn(pl) # rshutdown = self.raspshutdownBtn(rasp) # rreboot = self.raspsrebootBtn(rasp) self.plgrid[num, 0] = n self.plgrid[num, 1] = t self.plgrid[num, 2] = used_songs self.plgrid[num, 3] = redit self.plgrid[num, 4] = rdelete # self.plgrid[num, 5] = rshutdown # self.plgrid[num, 6] = rreboot self.nfNewpl = TextField(value='Default') # Button(text="New Playlist", callback=PLs.add() self.newPLBtn = self.newplBtn() self.body.append(self.plgrid) self.body.append(self.nfNewpl) self.body.append(self.newPLBtn)
def test_set_target(self): old_target = Text('hi') viewport = Viewport(old_target, width=100, height=100) new_target = Text('bye') viewport.target = new_target self.assertIs(new_target, viewport.target) self.assertIs(viewport, new_target.parent) self.assertIsNone(old_target.parent)
def test_getitem(self): first = Text('1') second = Text('2') top = List(items=(first, second)) self.assertEqual(top[0], first) self.assertEqual(top[1], second) with self.assertRaises(IndexError): top[2]
def test_delitem(self): a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d') g = Grid([[a], [c, d]]) del g[1, 0] self.assertIsNone(c.parent) self.assertEqual([a, d], list(g.children)) self.assertUnstyledHTMLLike(grid_of_text_xml(['a', None], [None, 'd']), g)
def test_construction_requires_dimensions(self): with self.assertRaises(TypeError): Viewport(Text('hi')) with self.assertRaises(TypeError): Viewport(Text('hi'), width=100) with self.assertRaises(TypeError): Viewport(Text('hi'), height=100)
def test_run(self): # Just make sure that modifications before/during/after runs don't blow up, # and that stop_running() terminates the run()-thread. gui = GUI(Text('before first run')) with self.running_in_background(gui): gui.body.append(Text('during first run')) gui.body.append(Text('before second fun')) with self.running_in_background(gui): gui.body.append(Text('during second run'))
def test_setitem(self): first = Text('1') second = Text('2') new = Text('new') top = List(items=(first, second)) top[0] = new self.assertEqual(top[0], new) self.assertIsNone(first.parent) self.assertEqual(top, new.parent) self.assertEqual(list(top.children), [new, second]) self.assertHTMLLike(list_of_texts_xml('new', '2'), top)
def main(): now = Text("") def update_now_forever(): while True: now.text = time.strftime("%Y-%m-%d %H:%M:%S") time.sleep(1) t = threading.Thread(target=update_now_forever) t.daemon = True t.start() GUI(Text("The time is: "), now).run()
def test_delitem(self): first = Text('1') second = Text('2') top = List(items=(first, second)) del top[0] self.assertIsNone(first.parent) self.assertEqual(list(top.children), [second]) self.assertEqual(second, top[0]) with self.assertRaises(IndexError): top[1] self.assertHTMLLike(list_of_texts_xml('2'), top)
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_getitem(self): a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d') g = Grid([[a, b], [c, d]]) with self.assertRaises(TypeError): g[0] with self.assertRaises(TypeError): g[0, 'hi'] with self.assertRaises(IndexError): g[3, 0] self.assertEqual(a, g[0, 0]) self.assertEqual([a, b], g[0, :]) self.assertEqual([a, c], g[:, 0])
def test_tag(self): self.assertHTMLLike('<ol style="list-style-type: disc"/>', List(numbered=False)) self.assertHTMLLike('<ol style="list-style-type: decimal"/>', List(numbered=True)) self.assertHTMLLike( '<ol style="list-style-type: disc"><li><span>hi</span></li></ol>', List(items=[Text("hi")]))
def test_dimensions_must_be_numeric(self): viewport = Viewport(Text('hi'), width=200, height=100) with self.assertRaises(TypeError): viewport.width = 'a' with self.assertRaises(TypeError): viewport.height = 'a' self.assertEqual(200, viewport.width) self.assertEqual(100, viewport.height)
def test_setitem(self): a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d') g = Grid([[a], [c, d]]) g[0, 1] = b self.assertEqual(g, b.parent) self.assertEqual([a, b, c, d], list(g.children)) self.assertEqual(b, g[0, 1]) self.assertUnstyledHTMLLike(grid_of_text_xml(['a', 'b'], ['c', 'd']), g) t = Text('t') g[0, 1] = t self.assertIsNone(b.parent) self.assertEqual(g, t.parent) self.assertEqual([a, t, c, d], list(g.children)) self.assertEqual(t, g[0, 1]) self.assertUnstyledHTMLLike(grid_of_text_xml(['a', 't'], ['c', 'd']), g)
def test_dimensions_are_gettable_and_settable(self): viewport = Viewport(Text('hi'), width=200, height=100) self.assertEqual(200, viewport.width) self.assertEqual(100, viewport.height) viewport.width = 50 self.assertEqual(50, viewport.width) viewport.height = 70 self.assertEqual(70, viewport.height)
def test_insert(self): first = Text('1') second = Text('2') third = Text('3') fourth = Text('4') top = List() top.insert(0, second) self.assertEqual(top, second.parent) self.assertEqual(list(top.children), [second]) top.insert(0, first) self.assertEqual(list(top.children), [first, second]) top.insert(99, fourth) self.assertEqual(list(top.children), [first, second, fourth]) top.insert(-1, third) self.assertEqual(list(top.children), [first, second, third, fourth]) self.assertHTMLLike(list_of_texts_xml('1', '2', '3', '4'), top)
def __init__(self, **kwargs): super(Lyout1, self).__init__(**kwargs) self.songlist = Songs.Songlist self.title = Text("Marshall AR.TS Live Suit") self.body.append(self.title) # prinbody(self.body) self.soedgrid = None self.guisonglist()
def test_set_n_rows(self): a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d') g = Grid([[a, b], [c, d]]) g.n_rows = 1 self.assertEqual(g, a.parent) self.assertEqual(g, b.parent) self.assertIsNone(c.parent) self.assertIsNone(d.parent) self.assertEqual([a, b], list(g.children)) self.assertEqual(1, g.n_rows) with self.assertRaises(IndexError): g[1, 0] self.assertUnstyledHTMLLike(grid_of_text_xml(['a', 'b']), g) g.n_rows = 2 self.assertIsNone(g[1, 0]) self.assertEqual([a, b], list(g.children)) g[1, 0] = c self.assertEqual(g, c.parent) self.assertEqual([a, b, c], list(g.children)) self.assertUnstyledHTMLLike(grid_of_text_xml(['a', 'b'], ['c', None]), g)
def test_set_dimensions__marks_dirty(self): g = Grid([[Text('a')]]) with self.assertMarksDirty(g): g.n_rows = 2 with self.assertMarksDirty(g): g.n_rows = 0 with self.assertMarksDirty(g): g.n_rows = 1 with self.assertMarksDirty(g): g.n_columns = 2 with self.assertMarksDirty(g): g.n_columns = 0 with self.assertMarksDirty(g): g.n_columns = 1
def GuiMain_BtnGrid(self): self.cleanUI() self.title = Text("Marshall AR.TS Live Suit") PLMenuButton = self.PLMenuBtn() songmenubtn = self.songMenuBtn() RaspMenuButton = self.raspMenuBtn() PlayMenuBtn = self.playMenuBtn() self.MainButtongrid = Grid(n_rows=1, n_columns=4) self.MainButtongrid[0, 0] = songmenubtn self.MainButtongrid[0, 1] = RaspMenuButton self.MainButtongrid[0, 2] = PLMenuButton self.MainButtongrid[0, 3] = PlayMenuBtn self.body.append(self.title) self.body.append(self.MainButtongrid)
def test_setitem__marks_dirty(self): l = List([Text('a')]) with self.assertMarksDirty(l): l[0] = Text('b')
def test_initial_css(self): self.assertNotIn('color', self.text.css) self.assertEqual('red', Text('hi', css={'color': 'red'}).css['color'])
def setUp(self): self.element = Text('') self.tag = self.element.tag self.callback_setter = self.element.callbacks
def test_delitem__marks_dirty(self): l = List([Text('a')]) with self.assertMarksDirty(l): del l[0]
def test_insert__marks_dirty(self): l = List() with self.assertMarksDirty(l): l.append(Text('a'))
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 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)