def test_children_must_be_elements(self):
   with self.assertRaises(TypeError):
     Container(0)
   with self.assertRaises(TypeError):
     Container().append(0)
   with self.assertRaises(TypeError):
     Container(Container())[0] = 0
  def test_hash_static(self):
    c = Container()
    h = hash(c)

    self.assertEqual(h, hash(c))

    c.append(Container())
    self.assertEqual(h, hash(c))

    c.callbacks[Click] = self.set_last_event
    self.assertEqual(h, hash(c))
Example #3
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()
  def test_children(self):
    container = Container()
    first = Container()
    second = Container()

    self.assertEqual(list(container.children), [])

    container.append(first)
    self.assertEqual(list(container.children), [first])

    container.insert(container.index(first)+1, second)
    self.assertEqual(list(container.children), [first, second])

    container.remove(first)
    self.assertEqual(list(container.children), [second])

    container.remove(second)
    self.assertEqual(list(container.children), [])
 def test_construction(self):
   left = Container()
   right = Container()
   top = Container(left, right)
   self.assertEqual(list(top.children), [left, right])
 def test_tag(self):
   self.assertHTMLLike('<div />', Container())
   self.assertHTMLLike('<span />', Container(tag_name='span'))
Example #7
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)
Example #8
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)