Ejemplo n.º 1
0
 def test_tag(self):
     self.assertUnstyledHTMLLike('<table></table>',
                                 Grid(n_rows=0, n_columns=0))
     self.assertUnstyledHTMLLike('<table></table>',
                                 Grid(n_rows=0, n_columns=1))
     self.assertUnstyledHTMLLike('<table><tr></tr></table>',
                                 Grid(n_rows=1, n_columns=0))
     self.assertUnstyledHTMLLike('<table><tr><td /></tr></table>',
                                 Grid(n_rows=1, n_columns=1))
     self.assertUnstyledHTMLLike('<table><tr><td /><td /></tr></table>',
                                 Grid(n_rows=1, n_columns=2))
Ejemplo n.º 2
0
    def test_construction(self):
        Grid(n_rows=3, n_columns=3)

        with self.assertRaises(TypeError):
            Grid(n_rows=-3, n_columns=3)

        with self.assertRaises(TypeError):
            Grid(n_rows='hi', n_columns=3)
        with self.assertRaises(TypeError):
            Grid(n_rows=3, n_columns='hi')

        with self.assertRaises(TypeError):
            Grid([['hi']])
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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()
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
  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)
Ejemplo n.º 9
0
    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])
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
 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
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
    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)
Ejemplo n.º 15
0
 def test_set_n_columns_to_0(self):
     g = Grid(n_rows=1, n_columns=2)
     g.n_columns = 0
     self.assertUnstyledHTMLLike('<table><tr></tr></table>', g)
     g.n_columns = 1
     self.assertUnstyledHTMLLike('<table><tr><td /></tr></table>', g)
Ejemplo n.º 16
0
 def test_set_n_columns_to_0(self):
   g = Grid(n_rows=1, n_columns=2)
   g.n_columns = 0
   self.assertUnstyledHTMLLike('<table><tr></tr></table>', g)
   g.n_columns = 1
   self.assertUnstyledHTMLLike('<table><tr><td /></tr></table>', g)
Ejemplo n.º 17
0
 def test_cell_styling(self):
     g = Grid(n_rows=1, n_columns=1)
     self.assertEqual(
         'border: 1px solid black',
         g.tag.childNodes[0].childNodes[0].getAttribute('style'))
Ejemplo n.º 18
0
 def test_constructor_guesses_dimensions(self):
     g = Grid([[Text('a')], [Text('b'), None, Text('d')]])
     self.assertEqual(2, g.n_rows)
     self.assertEqual(3, g.n_columns)
Ejemplo n.º 19
0
    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)
Ejemplo n.º 20
0
    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)
Ejemplo n.º 21
0
 def test_setitem__marks_dirty(self):
     g = Grid([[Text('before')]])
     with self.assertMarksDirty(g):
         g[0, 0] = Text('after')
Ejemplo n.º 22
0
 def test_delitem__marks_dirty(self):
     g = Grid([[Text('a')]])
     with self.assertMarksDirty(g):
         del g[0, 0]