예제 #1
0
 def __init__(self, x=0, y=0, data=None):
     Text.__init__(self)
     self.x = x
     self.y = y
     self.data = None
     self.true = "✔"
     self.false = "✘"
     self.none = "❓"
예제 #2
0
 def __init__(self, x=0, y=0, w=0):
     Text.__init__(self)
     self.x     = x
     self.y     = y
     self.w     = w
     self.data  = "" # text buffer
     self.cursor= 0
     self.offset= 0  # where to start printing - important when data is larger than input element
     self.textfg   = "1;37"
     self.textbg   = "44"
     self.cursorbg = "46"
예제 #3
0
    def __init__(self, align="left"):
        Text.__init__(self)
        self.buttons = []

        align = align[0]
        # middle = center
        if align == "m":
            align = "c"

        if align in ["l", "r", "c"]:
            self.align = align
        else:
            self.align = "l"
예제 #4
0
파일: add.py 프로젝트: whiteblue3/musicdb
    def MDBM_Main(self, args):

        self.cli = Text()
        self.maxw, self.maxh = self.cli.GetScreenSize()

        newalbums = self.FindNewAlbums()
        if newalbums:
            albumpath = self.ShowAlbumView(newalbums)
        else:
            print("\033[1;33mNo new albums found")
            return 0

        if albumpath:
            data = self.ShowImportDialog(albumpath)
        else:
            data = None
            print("\033[1;33mImport process canceled by user")

        if data:
            self.RunImportProcess(data)
            self.UpdateServerCache()
        else:
            self.cli.ClearScreen()
            self.cli.SetCursor(0, 0)

        self.cli.SetColor("0", "40")
        self.cli.ShowCursor(True)
        return 0
예제 #5
0
    def ShowUI(self):
        cli = Text()
        cli.ShowCursor(False)
        cli.ClearScreen()
        cli.SetCursor(1, 1)
        cli.SetColor("1;30", "40")
        cli.PrintText("Ctrl-D to exit.")

        maxw, maxh = cli.GetScreenSize()

        # Calculate the positions of the UI elements
        gridx = 1
        gridy = 3
        gridw = maxw - 2  # -2 for some space around
        gridh = 2 + 2 * 3  # 2 for the frame + 2 rows with height 3
        listx = 1
        listy = gridy + gridh + 1  # start where the grind ends + 1 space
        listw = maxw - 2  # -2 for some space around
        listh = maxh - (listy + 3)  # +3 for the button bar below

        # List Views
        self.moodlist = MoodView(self.cfg, self.db, "Mood list", listx, listy,
                                 listw, listh)
        self.moodgrid = MoodGrid(self.cfg, self.db, "Mood grid", gridx, gridy,
                                 gridw, gridh)

        self.moodgrid.moodlistcrossref = self.moodlist
        self.moodlist.moodgridcrossref = self.moodgrid

        # Buttons
        self.buttons = ButtonView(align="middle")
        self.buttons.AddButton("a", "Add new tag")
        self.buttons.AddButton("e", "Edit tag")
        self.buttons.AddButton("r", "Remove tag")
        self.buttons.AddButton("↹", "Select view")

        # Composition
        tabgroup = TabGroup()
        tabgroup.AddPane(self.moodlist)
        tabgroup.AddPane(self.moodgrid)

        # Draw once
        self.buttons.Draw(0, maxh - 2, maxw)

        key = " "
        while key != "Ctrl-D":
            # Show everything
            self.moodlist.Draw()
            self.moodgrid.Draw()
            cli.FlushScreen()

            # Handle keys
            key = cli.GetKey()
            tabgroup.HandleKey(key)

        cli.ClearScreen()
        cli.SetCursor(0, 0)
        cli.ShowCursor(True)
        return
예제 #6
0
    def ShowUI(self):
        cli  = Text()
        cli.ShowCursor(False)
        cli.ClearScreen()
        cli.SetCursor(1, 1)
        cli.SetColor("1;30", "40")
        cli.PrintText("New sub genre belong to selected main genre.  Ctrl-D to exit.")

        maxw, maxh = cli.GetScreenSize()

        # The GUI must have two lists: main genre, sub genre
        # main and sub genre shall be encapsulated by a frame
        listwidth   = maxw // 2 - 1           # - 1 for some space around
        listystart  = 3
        listheight  = maxh - (listystart + 3)   # +3 for a ButtonView
        list1xstart = 1
        list2xstart = 2 + listwidth

        # List Views
        self.genreview    = GenreView   (self.cfg, self.db, 
                "Main Genre", list1xstart, listystart, listwidth, listheight)
        self.subgenreview = SubGenreView(self.cfg, self.db, self.genreview, 
                "Sub Genre",  list2xstart, listystart, listwidth, listheight)

        # Buttons
        self.buttons = ButtonView(align="middle")
        self.buttons.AddButton("a", "Add new tag")
        self.buttons.AddButton("e", "Edit tag")
        self.buttons.AddButton("r", "Remove tag")
        self.buttons.AddButton("↹", "Select list")

        # Composition
        tabgroup = TabGroup()
        tabgroup.AddPane(self.genreview)
        tabgroup.AddPane(self.subgenreview)

        # Draw once
        self.buttons.Draw(0, maxh-2, maxw)


        key = " "
        selectedmaingenre = 0   # trace selected main genre to update subgenre view
        while key != "Ctrl-D":
            # Show everything
            self.genreview.Draw()
            self.subgenreview.Draw()
            cli.FlushScreen()

            # Handle keys
            key = cli.GetKey()
            tabgroup.HandleKey(key)

            genre = self.genreview.GetSelectedData()
            if genre["id"] != selectedmaingenre:
                selectedmaingenre = genre["id"]
                self.subgenreview.UpdateView()


        cli.ClearScreen()
        cli.SetCursor(0,0)
        cli.ShowCursor(True)
        return
예제 #7
0
파일: frame.py 프로젝트: whiteblue3/musicdb
 def __init__(self, linestyle=LINESTYLE_NORMAL):
     Text.__init__(self)
     self.linestyle = linestyle
예제 #8
0
    def ShowUI(self):
        cli  = Text()
        cli.ShowCursor(False)
        cli.ClearScreen()
        maxw, maxh = cli.GetScreenSize()

        # List Views
        self.orphanpathview  = OrphanPathView("Orphan Paths", x=1, y=3, w=maxw//2-1, h=maxh-6)
        self.orphanpathview.SetData(self.newartists, self.newalbums, self.newsongs)

        self.orphanentryview = OrphanEntryView("Orphan DB Entries", x=maxw//2+1, y=3, w=maxw//2-1, h=maxh-6)
        self.orphanentryview.SetData(self.lostartists, self.lostalbums, self.lostsongs)

        # Buttons
        lbuttons = ButtonView(align="left")
        lbuttons.AddButton("a", "Add path to database")
        lbuttons.AddButton("↑", "Go up")
        lbuttons.AddButton("↓", "Go down")
        
        mbuttons = ButtonView(align="middle")
        mbuttons.AddButton("u", "Update database entry path")

        rbuttons = ButtonView(align="right")
        rbuttons.AddButton("↑", "Go up")
        rbuttons.AddButton("↓", "Go down")
        rbuttons.AddButton("r", "Remove song from database")
        
        bbuttons = ButtonView() # bottom-buttons
        bbuttons.AddButton("c", "Check again")
        bbuttons.AddButton("↹", "Select list")
        bbuttons.AddButton("q", "Quit")
        
        # Draw ButtonViews
        w = (maxw // 3) - 2
        lbuttons.Draw(2,         1,      w)
        mbuttons.Draw(maxw//3,   1,      w)
        rbuttons.Draw(2*maxw//3, 1,      w)
        bbuttons.Draw(2,         maxh-2, maxw)

        # Draw Lists
        self.orphanpathview.Draw()
        self.orphanentryview.Draw()

        # Create Tab group
        tabgroup = TabGroup()
        tabgroup.AddPane(self.orphanpathview)
        tabgroup.AddPane(self.orphanentryview)

        key = " "
        while key != "q" and key != "Ctrl-D":
            cli.FlushScreen()
            key = cli.GetKey()
            tabgroup.HandleKey(key)

            # Update Views
            if key == "c":
                self.UpdateUI()

            # Update Database
            if key == "u":
                newdata = self.orphanpathview.GetSelectedData()
                olddata = self.orphanentryview.GetSelectedData()

                # check if both are songs, albums or artists
                if newdata[0] != olddata[0]:
                    continue
                target  = newdata[0]
                newpath = newdata[1]
                entryid = olddata[1]["id"]
                self.UpdateDatabase(target, entryid, newpath)
                self.UpdateUI()

            # Add To Database
            if key == "a":
                newdata = self.orphanpathview.GetSelectedData()

                target  = newdata[0]
                newpath = newdata[1]
                self.AddToDatabase(target, newpath)

            # Remove From Database
            if key == "r":
                data = self.orphanentryview.GetSelectedData()

                target   = data[0]
                targetid = data[1]["id"]
                self.RemoveFromDatabase(target, targetid)
                self.UpdateUI()


        cli.ClearScreen()
        cli.SetCursor(0,0)
        cli.ShowCursor(True)
        return