Esempio n. 1
0
    def createWidgets(self):

        frame_main = ttk.LabelFrame(self.widget, text="AudioBot Test")
        frame_main.grid(column=0, row=0, padx=8, pady=4)

        # ========== input frame ================

        frame_input = ttk.Frame(frame_main)
        frame_input.grid(column=0, row=0, padx=8, pady=4, sticky=tk.W)

        # Creating check box for commands
        ttk.Label(frame_input, text=_("enter room id:")) \
            .grid(column=0, row=0, sticky=tk.W, padx=8, pady=4)

        room_id_input = ttk.Entry(frame_input,
                                  width=16,
                                  textvariable=self.room_id)
        room_id_input.grid(column=1, row=0, padx=8, pady=4)

        play_button = ttk.Button(frame_input,
                                 width=8,
                                 text=_("connect"),
                                 command=self.__confirmroom)
        play_button.grid(column=2, row=0)

        # ========== output frame ================

        frame_output = ttk.Frame(frame_main)
        frame_output.grid(column=0, row=1, padx=8, pady=4, sticky=tk.W)

        # Creating check box for commands
        output_label = ttk.Label(frame_output,
                                 width=64,
                                 textvariable=self.output_label)
        output_label.grid(column=0, row=0, sticky=tk.W, padx=8, pady=4)
Esempio n. 2
0
    def initialize(self):
        self.main_window.getTabController().add(self.widget, text=_("Playlist"))

        self.audio_bot.user_playlist.handlers._register("playlist_update",
                                                     "playlist.update",
                                                     self.__updateTree)

        self.audio_bot.handlers._register("audiobot_play",
                                            "playinginfo.update",
                                            self.__updatePlayingInfo)

        self.audio_bot.mpv_player.registerPropertyHandler("playinginfo.syncprogress",
                                                MPVProperty.PERCENT_POS,
                                                self.__syncProgress)

        self.audio_bot.mpv_player.registerPropertyHandler("playinginfo.watchtime",
                                                          MPVProperty.TIME_POS,
                                                          self.__syncTime)

        self.audio_bot.mpv_player.registerPropertyHandler("playinginfo.watchduration",
                                                          MPVProperty.DURATION,
                                                          self.__syncTime)

        self.audio_bot.mpv_player.registerPropertyHandler("playinginfo.watchvolume",
                                                          MPVProperty.VOLUME,
                                                          self.__syncVolume)

        if Config.player_volume > 1 :
            Config.player_volume = 1
        self.volume.set(Config.player_volume*100)
        self.audio_bot.mpv_player.setVolumePercent(Config.player_volume)
Esempio n. 3
0
 def initialize(self):
     self.main_window.getTabController().add(self.widget,
                                             text=_("Blacklist"))
     self.audio_bot.blacklist.handlers._register(BlacklistUpdateEvent,
                                                 "blacklistgui.update",
                                                 self.__updateTree)
     self.audio_bot.blacklist.handlers.call(
         BlacklistUpdateEvent(self.audio_bot.blacklist))
Esempio n. 4
0
 def __updatePlayingInfo(self, event: AudioBotPlayEvent):
     item = event.item
     self.playing_source.set(_("Source: {}").format(item.source.getSourceName()))
     self.playing_title.set(("{title:.24} - - - " +
                             "{artist:.16} - - - " +
                             "({user:.16})").format(title=filterTclSpecialCharacter(item.source.getTitle()),
                                                             artist=item.source.getArtist(),
                                                             user=item.username))
     self.main_window.threading_update(self.__loadCover,item.source.getCover())
Esempio n. 5
0
    def createWidgets(self):
        frame_main = ttk.LabelFrame(self.widget,
                                    text=_("Netease Login"))
        frame_main.grid_columnconfigure(0, weight=1)
        frame_main.grid_columnconfigure(2, weight=1)
        frame_main.pack(fill="both", expand="yes", padx=8, pady=4)
        # ==== Row 1 ====

        frame_row_1 = ttk.Frame(frame_main)
        frame_row_1.grid(column=1, row=0, padx=8, pady=4)

        self.login_qr = ttk.Label(frame_row_1, width=250)
        self.login_qr.grid(column=0, row=0, sticky="news")
        self.__setQrImg(self.empty_image)

        # ==== Row 2 ====

        frame_row_2 = ttk.Frame(frame_main)
        frame_row_2.grid(column=1, row=1, padx=8, pady=4)

        getqr_button = ttk.Button(frame_row_2, width=16, text=_("Get QR"), command=self.__tryLogin)
        getqr_button.grid(column=0, row=0)
        finishqr_button = ttk.Button(frame_row_2, width=16, text=_("Finish QR Scan"), command=self.__checkLogin)
        finishqr_button.grid(column=1, row=0)
        logout_button = ttk.Button(frame_row_2, width=16, text=_("Logout"), command=self.__tryLogout)
        logout_button.grid(column=2, row=0)

        # ==== Row 3 ====

        frame_row_3 = ttk.Frame(frame_main)
        frame_row_3.grid(column=1, row=2, padx=8, pady=4)

        playing_title_label = ttk.Label(frame_row_3, textvariable=self.current_status)
        playing_title_label.grid(column=0, row=0, pady=2, padx=2)
        self.current_status.set("Waiting")


        self.__setLoginInfo()
Esempio n. 6
0
 def initialize(self):
     self.main_window.getTabController().add(self.widget, text=_("Netease Login"))
Esempio n. 7
0
 def __setLoginInfo(self):
     if self.__isLogin():
         self.current_status.set(_("Login As ")+GetCurrentSession().login_info['content']['profile']['nickname'])
     else:
         self.current_status.set(_("Not Login"))
Esempio n. 8
0
    def createWidgets(self):
        frame_main = ttk.LabelFrame(self.widget, text="Blacklist Manager")
        frame_main.pack(fill="both", expand="yes", padx=8, pady=4)

        frame_blacklist = ttk.Frame(frame_main)
        frame_blacklist.pack(fill=tk.X, expand="yes", side=tk.TOP)

        frame_blacklistadd = ttk.Frame(frame_main)
        frame_blacklistadd.pack(fill=tk.X, expand="yes", side=tk.TOP)

        # ========== blacklist frame ================
        frame_display = ttk.Frame(frame_blacklist)
        frame_display.grid(column=0, row=0, padx=4, pady=4)
        frame_move = ttk.Frame(frame_blacklist)
        frame_move.grid(column=1, row=0, padx=4, pady=4)

        self.blacklist_tree = ttk.Treeview(frame_display,
                                           height="13",
                                           selectmode="browse")
        self.blacklist_tree["columns"] = ("bantype", "content", "whole")
        self.blacklist_tree.column("#0", width=64, minwidth=32)
        self.blacklist_tree.column("bantype", width=256, minwidth=256)
        self.blacklist_tree.column("content", width=256, minwidth=128)
        self.blacklist_tree.column("whole", width=64, minwidth=128)

        self.blacklist_tree.heading("#0", text="#", anchor=tk.W)
        self.blacklist_tree.heading("bantype", text=_("ban type"), anchor=tk.W)
        self.blacklist_tree.heading("content",
                                    text=_("ban content"),
                                    anchor=tk.W)
        self.blacklist_tree.heading("whole",
                                    text=_("use whole word"),
                                    anchor=tk.W)

        self.blacklist_tree.grid(column=0, row=0)
        self.blacklist_tree.bind('<Button-1>', self.__disableTreeSeperator)

        self.blacklist_tree.bind('<ButtonRelease-1>', self.__clearFocusIfEmpty)

        blacklist_del_button = ttk.Button(
            frame_move,
            width=3,
            text="X",
            command=lambda: self.audio_bot.blacklist.remove(
                self.__getTreeviewFocusIndex()))
        blacklist_del_button.grid(column=0, row=0, pady=2)

        ToolTip(blacklist_del_button, _("delete this blacklist item"))

        # ========== blackadd frame ================
        frame_blacklistadd_0 = ttk.Frame(frame_blacklistadd)
        frame_blacklistadd_0.grid(column=0, row=0, padx=8)

        bantype_var = tk.StringVar()
        bantype_selection = ttk.Combobox(frame_blacklistadd_0,
                                         width=16,
                                         textvariable=bantype_var,
                                         state='readonly')
        bantype_vals = [m.identifier for m in BlacklistItemType.values()]
        bantype_selection['values'] = tuple(bantype_vals)
        bantype_selection.grid(column=0, row=1, padx=8)
        bantype_selection.set(bantype_vals[0])
        bantype_var.set(bantype_vals[0])

        ban_content_var = tk.StringVar()
        ban_content = ttk.Entry(frame_blacklistadd_0,
                                width=32,
                                textvariable=ban_content_var)
        ban_content.grid(column=1, row=1, padx=8, pady=4)

        ban_add_button = ttk.Button(
            frame_blacklistadd_0,
            width=16,
            text=_("add to blacklist"),
            command=lambda: self.audio_bot.blacklist.append(
                bantype_var.get(), ban_content_var.get()))
        ban_add_button.grid(column=2, row=1, padx=8, pady=4)

        ttk.Label(frame_blacklistadd_0,
                  text=_("Choose ban type")).grid(column=0,
                                                  row=0,
                                                  padx=8,
                                                  pady=4,
                                                  sticky=tk.W)
        ttk.Label(frame_blacklistadd_0,
                  text=_("Specify ban content")).grid(column=1,
                                                      row=0,
                                                      padx=8,
                                                      pady=4,
                                                      sticky=tk.W)
Esempio n. 9
0
    def createWidgets(self):

        frame_main = ttk.LabelFrame(self.widget, text="Search test")
        frame_main.pack(fill="both", expand="yes", padx=8, pady=4)

        frame_search_input  = ttk.Frame(frame_main)
        frame_search_input.pack(fill=tk.X, expand="yes", side=tk.TOP)

        frame_search_result = ttk.Frame(frame_main)
        frame_search_result.pack(fill=tk.X, expand="yes", side=tk.TOP)

        # ========== search input frame ================
        frame_search_input.columnconfigure(0, weight=1)
        frame_search_input.columnconfigure(2, weight=1)

        frame_basic = ttk.Frame(frame_search_input)
        frame_basic.grid(column=1, row=0, padx=8, pady=4)
        # Creating check box for commands
        ttk.Label(frame_basic, text="Keyword or url:") \
            .grid(column=0, row=0, sticky=tk.W, padx=8, pady=4)
        parameter_entry = ttk.Entry(frame_basic, width=64, textvariable=self.keyword)
        parameter_entry.grid(column=0, row=1,
                             padx=8, pady=4)

        # Adding a Button
        action = ttk.Button(frame_basic, width=8, text=_("Search"),command = self.__search)
        action.grid(column=1, row=1)

        # Adding a Button
        action = ttk.Button(frame_basic, width=8, text=_("Add"), command=self.__add)
        action.grid(column=2, row=1)

        # ========== search result frame ================
        frame_search_result.columnconfigure(0, weight=1)
        frame_search_result.columnconfigure(3, weight=1)
        frame_display = ttk.Frame(frame_search_result)
        frame_display.grid(column=1, row=0, padx=4, pady=4)
        frame_tool = ttk.Frame(frame_search_result)
        frame_tool.grid(column=2, row=0, padx=4, pady=4)

        self.search_result_tree = ttk.Treeview(frame_display, height="13", selectmode="browse")
        self.search_result_tree["columns"] = ("title", "artist", "source")
        self.search_result_tree.column("#0", width=64, minwidth=64)
        self.search_result_tree.column("title", width=256, minwidth=256)
        self.search_result_tree.column("artist", width=128+64, minwidth=128)
        self.search_result_tree.column("source", width=128, minwidth=128)

        self.search_result_tree.heading("#0", text="index", anchor=tk.W)
        self.search_result_tree.heading("title", text=_("title"), anchor=tk.W)
        self.search_result_tree.heading("artist", text=_("artist"), anchor=tk.W)
        self.search_result_tree.heading("source", text=_("source"), anchor=tk.W)
        self.search_result_tree.grid(column=0, row=0)

        self.search_result_tree.bind('<Button-1>', self.__disableTreeSeperator)
        self.search_result_tree.bind('<ButtonRelease-1>', self.__clearFocusIfEmpty)

        search_result_add_button = ttk.Button(frame_tool, width=3, text="+",
                                              command = self.__addCurrent)
        search_result_add_button.grid(column=0, row=0, pady=2)

        ToolTip(search_result_add_button, _("add to the playlist"))

        search_result_play_button = ttk.Button(frame_tool, width=3, text="▶",
                                               command  =self.__playCurrent)
        search_result_play_button.grid(column=0, row=1, pady=2)

        ToolTip(search_result_play_button, _("play selected"))

        search_bl_button = ttk.Button(frame_tool, width=3, text="⛒",
                                        command=self.__addCurrentToBlacklist)
        search_bl_button.grid(column=0, row=2, pady=2)

        ToolTip(search_bl_button, _("add to blacklist"))
Esempio n. 10
0
 def initialize(self):
     self.main_window.getTabController().add(self.widget, text=_("Search"))
Esempio n. 11
0
    def createWidgets(self):
        frame_obsinfo = ttk.LabelFrame(self.widget, text=_("OBS output"))
        frame_obsinfo.pack(fill=tk.BOTH, expand="yes", padx=4)
        frame_appinfo = ttk.LabelFrame(self.widget, text=_("Application Information"))
        frame_appinfo.pack(fill=tk.BOTH, expand="yes", padx=4)

        # ============== obs info =========================

        frame_obsinfo_1 = ttk.Frame(frame_obsinfo)
        frame_obsinfo_1.grid(column=0,row=0,sticky=tk.W,padx=8,pady=8)

        frame_obsinfo_2 = ttk.Frame(frame_obsinfo)
        frame_obsinfo_2.grid(column=0, row=1,sticky=tk.W,padx=8,pady=8)

        frame_obsinfo_3 = ttk.Frame(frame_obsinfo)
        frame_obsinfo_3.grid(column=0, row=2,sticky=tk.W,padx=8,pady=8)

        frame_obsinfo_4 = ttk.Frame(frame_obsinfo)
        frame_obsinfo_4.grid(column=0, row=3,sticky=tk.W,padx=8,pady=8)

        frame_obsinfo_5 = ttk.Frame(frame_obsinfo)
        frame_obsinfo_5.grid(column=0, row=4, sticky=tk.W, padx=8, pady=8)

        ttk.Label(frame_obsinfo_1,text = _("Current Song Info:")).pack(side=tk.LEFT,padx=4)
        TextEntry.getTextEntry(frame_obsinfo_1,
                               "http://127.0.0.1:{}/currentplaying"
                               .format(Config.output_channel["web"]["port"]),
                               width = 32).pack(side=tk.LEFT,padx=4)
        ttk.Label(frame_obsinfo_1, text=_("CSS:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_1,
                               ".playing-info {}",
                               width=16).pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_obsinfo_2, text=_("Current Song Lyric:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_2,
                               "http://127.0.0.1:{}/currentlyric"
                               .format(Config.output_channel["web"]["port"]),
                               width=32).pack(side=tk.LEFT, padx=4)
        ttk.Label(frame_obsinfo_2, text=_("CSS:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_2,
                               ".playing-lyric {}",
                               width=16).pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_obsinfo_3, text=_("Current Song Cover:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_3,
                               "http://127.0.0.1:{}/currentcover"
                               .format(Config.output_channel["web"]["port"]),
                               width=32).pack(side=tk.LEFT, padx=4)
        ttk.Label(frame_obsinfo_3, text=_("CSS:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_3,
                               ".playing-cover {}",
                               width=16).pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_obsinfo_4, text=_("Playlist:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_4,
                               "http://127.0.0.1:{}/playlist"
                               .format(Config.output_channel["web"]["port"]),
                               width=32).pack(side=tk.LEFT, padx=4)
        ttk.Label(frame_obsinfo_4, text=_("CSS:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_4,
                               ".playlist-info {}",
                               width=16).pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_obsinfo_5, text=_("TextInfo:")).pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_obsinfo_5,
                               "http://127.0.0.1:{}/textinfo"
                               .format(Config.output_channel["web"]["port"]),
                               width=32).pack(side=tk.LEFT, padx=4)

        # ============== application info =========================

        frame_appinfo_1 = ttk.Frame(frame_appinfo)
        frame_appinfo_1.grid(column=0, row=0, sticky=tk.W, padx=8, pady=8)

        frame_appinfo_2 = ttk.Frame(frame_appinfo)
        frame_appinfo_2.grid(column=0, row=1, sticky=tk.W, padx=8, pady=8)

        frame_appinfo_3 = ttk.Frame(frame_appinfo)
        frame_appinfo_3.grid(column=0, row=2, sticky=tk.W, padx=8, pady=8)

        frame_appinfo_4 = ttk.Frame(frame_appinfo)
        frame_appinfo_4.grid(column=0, row=3, sticky=tk.W, padx=8, pady=8)

        frame_appinfo_5 = ttk.Frame(frame_appinfo)
        frame_appinfo_5.grid(column=0, row=4, sticky=tk.W, padx=8, pady=8)

        frame_appinfo_6 = ttk.Frame(frame_appinfo)
        frame_appinfo_6.grid(column=0, row=5, sticky=tk.W, padx=8, pady=8)

        ttk.Label(frame_appinfo_1, text=_("Author:")).pack(side=tk.LEFT, padx=4)
        ttk.Label(frame_appinfo_1, text="Aynakeya && Nearl_Official").pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_appinfo_2, text="Github:").pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_appinfo_2,
                               "https://github.com/LXG-Shadow/BiliAudioBot",
                               width=64).pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_appinfo_3, text="Aynakeya Bilibili:").pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_appinfo_3,
                               "https://space.bilibili.com/10003632",
                               width=64).pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_appinfo_4, text="Nearl_Official Bilibili:").pack(side=tk.LEFT, padx=4)
        TextEntry.getTextEntry(frame_appinfo_4,
                               "https://space.bilibili.com/5953957",
                               width=64).pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_appinfo_5, text=_("Thanks to:")).pack(side=tk.LEFT, padx=4)
        ttk.Label(frame_appinfo_5, text="greats3an/pyncm, xfgryujk/blivedm, jaseg/python-mpv").pack(side=tk.LEFT, padx=4)

        ttk.Label(frame_appinfo_6, text=_("Version:")).pack(side=tk.LEFT, padx=4)
        ttk.Label(frame_appinfo_6, text=Config.version).pack(side=tk.LEFT, padx=4)
Esempio n. 12
0
    def createWidgets(self):
        frame_diange = ttk.LabelFrame(self.widget, text=_("DG Config"))
        frame_diange.pack(fill=tk.X, expand="yes", padx=4)

        frame_qiege = ttk.LabelFrame(self.widget, text=_("QG Config"))
        frame_qiege.pack(fill=tk.X, expand="yes", padx=4)

        frame_playlist = ttk.LabelFrame(self.widget, text=_("Playlist Config"))
        frame_playlist.pack(fill=tk.X, expand="yes", padx=4)

        frame_audio_device = ttk.LabelFrame(self.widget,
                                            text=_("Audio Device"))
        frame_audio_device.pack(fill=tk.X, expand="yes", padx=4)

        frame_etc = ttk.LabelFrame(self.widget, text=_("Experimental Feature"))
        frame_etc.pack(fill=tk.X, expand="yes", padx=4)

        # ========== frame_diange ================
        frame_diange_1 = ttk.Frame(frame_diange)
        frame_diange_1.pack(fill=tk.X,
                            side=tk.TOP,
                            expand="yes",
                            padx=2,
                            pady=2)
        frame_diange_2 = ttk.Frame(frame_diange)
        frame_diange_2.pack(fill=tk.X,
                            side=tk.TOP,
                            expand="yes",
                            padx=2,
                            pady=2)

        ttk.Label(frame_diange_1, text=_("DG Permission: ")).grid(column=0,
                                                                  row=0)

        # visitor perm
        ConfigGUIFactory.getCheckButton(frame_diange_1, _("Visitor"),
                                        Config.commands["diange"], "visitor",
                                        bool, int).grid(column=1,
                                                        row=0,
                                                        padx=8)

        # guard perm
        ConfigGUIFactory.getCheckButton(frame_diange_1, _("Guard"),
                                        Config.commands["diange"], "guard",
                                        bool, int).grid(column=2,
                                                        row=0,
                                                        padx=8)

        # admin perm
        ConfigGUIFactory.getCheckButton(frame_diange_1, _("Admin"),
                                        Config.commands["diange"], "admin",
                                        bool, int).grid(column=3,
                                                        row=0,
                                                        padx=8)

        ttk.Label(frame_diange_2, text=_("DG Cooldown (s): ")).grid(column=0,
                                                                    row=0)
        ConfigGUIFactory.getInput(frame_diange_2, Config.commands["diange"],
                                  "cooldown",
                                  ConfigGUIFactory.ConvertWithDefault(int, 0),
                                  str).grid(column=1, row=0, padx=8)
        ttk.Label(frame_diange_2, text=_("DG Max number: ")).grid(column=2,
                                                                  row=0)
        ConfigGUIFactory.getInput(
            frame_diange_2, Config.commands["diange"], "limit",
            ConfigGUIFactory.ConvertWithDefault(int, 128), str).grid(column=3,
                                                                     row=0,
                                                                     padx=8)

        # ========== frame_qiege ================
        frame_qiege_1 = ttk.Frame(frame_qiege)
        frame_qiege_1.pack(fill=tk.X,
                           side=tk.TOP,
                           expand="yes",
                           padx=2,
                           pady=2)

        # self perm
        ConfigGUIFactory.getCheckButton(frame_qiege_1, _("Self"),
                                        Config.commands["qiege"], "self", bool,
                                        int).grid(column=1, row=0, padx=8)

        # guard perm
        ConfigGUIFactory.getCheckButton(frame_qiege_1, _("Guard"),
                                        Config.commands["qiege"], "guard",
                                        bool, int).grid(column=2,
                                                        row=0,
                                                        padx=8)

        # admin perm
        ConfigGUIFactory.getCheckButton(frame_qiege_1, _("Admin"),
                                        Config.commands["qiege"], "admin",
                                        bool, int).grid(column=3,
                                                        row=0,
                                                        padx=8)

        # ========== frame_playlist ================
        frame_playlist_1 = ttk.Frame(frame_playlist)
        frame_playlist_1.pack(fill=tk.X,
                              side=tk.TOP,
                              expand="yes",
                              padx=2,
                              pady=2)
        frame_playlist_2 = ttk.Frame(frame_playlist)
        frame_playlist_2.pack(fill=tk.X,
                              side=tk.TOP,
                              expand="yes",
                              padx=2,
                              pady=2)
        frame_playlist_3 = ttk.Frame(frame_playlist)
        frame_playlist_3.pack(fill=tk.X,
                              side=tk.TOP,
                              expand="yes",
                              padx=2,
                              pady=2)

        ttk.Label(
            frame_playlist_1,
            text=
            _("Enter netease playlist id (separate by ,) (restart after modified )"
              )).grid(column=0, row=0)
        ttk.Label(frame_playlist_1, text="      ").grid(column=1, row=0)
        ttk.Label(frame_playlist_1,
                  text=_("Example: 1234565,1234564")).grid(column=2, row=0)
        input1, button1 = ConfigGUIFactory.getInputWithButton(
            frame_playlist_2,
            Config.system_playlist["playlist"],
            "netease",
            ConfigGUIFactory.ConvertWithDefault(
                lambda x: list(map(lambda x: str(int(x)), x.split(","))), []),
            lambda x: ",".join(x),
            input_kwargs={"width": 64},
            button_kwargs={"text": _("Update Playlist")})
        input1.grid(column=0, row=0, padx=8)
        button1.grid(column=1, row=0, padx=8)

        ConfigGUIFactory.getCheckButton(frame_playlist_3,
                                        _("Random System Playlist"),
                                        Config.system_playlist, "random", bool,
                                        int).grid(column=0, row=0, padx=8)
        ConfigGUIFactory.getCheckButton(frame_playlist_3,
                                        _("Skip when user add a song"),
                                        Config.system_playlist, "autoskip",
                                        bool, int).grid(column=1,
                                                        row=0,
                                                        padx=8)

        # ========== frame audio_device ================

        frame_audio_device_1 = ttk.Frame(frame_audio_device)
        frame_audio_device_1.pack(fill=tk.X,
                                  side=tk.TOP,
                                  expand="yes",
                                  padx=2,
                                  pady=2)

        player: MPVPlayer = Global_Audio_Bot.mpv_player
        ad_info = player.getProperty(MPVProperty.AUDIO_DEVICE_LIST)
        ad_vals = [d["description"] for d in ad_info]
        ad_dn_map = dict((d["description"], d["name"]) for d in ad_info)
        ad_nd_map = dict((d["name"], d["description"]) for d in ad_info)

        def get_set_audio_device(audio_bot, ad_map, name):
            ad_desc = ad_map[name]
            p: MPVPlayer = audio_bot.mpv_player
            p.setProperty(MPVProperty.AUDIO_DEVICE, name)
            return ad_desc

        audio_device_selection = ConfigGUIFactory.getBoxSelector(
            frame_audio_device_1,
            Config.audio_device,
            "id",
            ad_vals,
            ConfigGUIFactory.ConvertWithDefault(lambda x: ad_dn_map[x],
                                                "auto"),
            ConfigGUIFactory.ConvertWithDefault(
                lambda x: get_set_audio_device(Global_Audio_Bot, ad_nd_map, x),
                "Autoselect device"),
            state='readonly',
            width=32)
        ttk.Label(frame_audio_device_1,
                  text=_("Select audio device: ")).grid(column=0, row=0)
        audio_device_selection.grid(column=1, row=0, padx=8)

        # ========== frame exp ================
        variable = tk.IntVar()

        def tst():
            if variable.get() == 0:
                MatchEngine.HANDLERS.unregister(FindSearchResultEvent,
                                                "filtercover")
            else:
                MatchEngine.HANDLERS._register(FindSearchResultEvent,
                                               "filtercover",
                                               SkipCover.skip_cover)

        check_button = tk.Checkbutton(frame_etc,
                                      text=_("filter cover"),
                                      variable=variable,
                                      command=tst)
        check_button.grid(column=0, row=0)
    def createWidgets(self):
        frame_main = ttk.LabelFrame(self.widget, text="Play History")
        frame_main.pack(fill="both", expand="yes", padx=8, pady=4)

        frame_playlist = ttk.Frame(frame_main)
        frame_playlist.pack(fill=tk.X, expand="yes", side=tk.TOP)

        frame_playing = ttk.Frame(frame_main)
        frame_playing.pack(fill=tk.X, expand="yes", side=tk.BOTTOM)

        # ========== playlist frame ================
        frame_display = ttk.Frame(frame_playlist)
        frame_display.grid(column=0, row=0, padx=4, pady=4)
        frame_move = ttk.Frame(frame_playlist)
        frame_move.grid(column=1, row=0, padx=4, pady=4)

        self.playlist_tree = ttk.Treeview(frame_display,
                                          height=16,
                                          selectmode="browse")
        self.playlist_tree["columns"] = ("title", "artist", "source", "user")
        self.playlist_tree.column("#0", width=32, minwidth=32)
        self.playlist_tree.column("title", width=256, minwidth=256)
        self.playlist_tree.column("artist", width=128, minwidth=128)
        self.playlist_tree.column("source", width=128, minwidth=128)
        self.playlist_tree.column("user", width=64 + 32, minwidth=64 + 32)

        self.playlist_tree.heading("#0", text="#", anchor=tk.W)
        self.playlist_tree.heading("title", text=_("title"), anchor=tk.W)
        self.playlist_tree.heading("artist", text=_("artist"), anchor=tk.W)
        self.playlist_tree.heading("source", text=_("source"), anchor=tk.W)
        self.playlist_tree.heading("user", text=_("user"), anchor=tk.W)

        self.playlist_tree.grid(column=0, row=0)
        self.playlist_tree.bind('<Button-1>', self.__disableTreeSeperator)

        self.playlist_tree.bind('<ButtonRelease-1>', self.__clearFocusIfEmpty)

        playlist_add_button = ttk.Button(frame_move,
                                         width=3,
                                         text="+",
                                         command=self.__addCurrent)
        playlist_add_button.grid(column=0, row=0, pady=2)

        ToolTip(playlist_add_button, _("add to the playlist"))

        playlist_play_button = ttk.Button(frame_move,
                                          width=3,
                                          text="▶",
                                          command=self.__playCurrent)
        playlist_play_button.grid(column=0, row=1, pady=2)

        ToolTip(playlist_play_button, _("play selected"))

        playlist_clear_button = ttk.Button(
            frame_move,
            width=3,
            text="∅",
            command=self.audio_bot.history_playlist.clear)
        playlist_clear_button.grid(column=0, row=2, pady=2)

        ToolTip(playlist_clear_button, _("clear the list"))

        playlist_bl_button = ttk.Button(frame_move,
                                        width=3,
                                        text="⛒",
                                        command=self.__addCurrentToBlacklist)
        playlist_bl_button.grid(column=0, row=3, pady=2)

        ToolTip(playlist_bl_button, _("add to blacklist"))
    def initialize(self):
        self.main_window.getTabController().add(self.widget,
                                                text=_("Play History"))

        self.audio_bot.history_playlist.handlers._register(
            "playlist_update", "playhistory.update", self.__updateTree)
Esempio n. 15
0
    def createWidgets(self):

        frame_main = ttk.LabelFrame(self.widget, text="Playlist demo")
        frame_main.pack(fill="both", expand="yes", padx=8, pady=4)

        frame_playlist = ttk.Frame(frame_main)
        frame_playlist.pack(fill=tk.X, expand="yes", side=tk.TOP)

        frame_playing = ttk.Frame(frame_main)
        frame_playing.pack(fill=tk.X, expand="yes", side=tk.BOTTOM)

        # ========== playlist frame ================
        frame_display = ttk.Frame(frame_playlist)
        frame_display.grid(column=0, row=0, padx=4, pady=4)
        frame_move = ttk.Frame(frame_playlist)
        frame_move.grid(column=1, row=0, padx=4, pady=4)

        self.playlist_tree = ttk.Treeview(frame_display, height="13", selectmode="browse")
        self.playlist_tree["columns"] = ("title", "artist", "source", "user")
        self.playlist_tree.column("#0", width=32, minwidth=32)
        self.playlist_tree.column("title", width=256, minwidth=256)
        self.playlist_tree.column("artist", width=128, minwidth=128)
        self.playlist_tree.column("source", width=128, minwidth=128)
        self.playlist_tree.column("user", width=64+32, minwidth=64+32)

        self.playlist_tree.heading("#0", text="#", anchor=tk.W)
        self.playlist_tree.heading("title", text=_("title"), anchor=tk.W)
        self.playlist_tree.heading("artist", text=_("artist"), anchor=tk.W)
        self.playlist_tree.heading("source", text=_("source"), anchor=tk.W)
        self.playlist_tree.heading("user", text=_("user"), anchor=tk.W)

        self.playlist_tree.grid(column=0, row=0)
        self.playlist_tree.bind('<Button-1>', self.__disableTreeSeperator)

        self.playlist_tree.bind('<ButtonRelease-1>', self.__clearFocusIfEmpty)

        playlist_superup_button = ttk.Button(frame_move, width=3, text="⭡",
                                             command = lambda :self.__move(self.__getTreeviewFocusIndex(),0))
        playlist_superup_button.grid(column=0, row=0, pady=2)

        ToolTip(playlist_superup_button, _("move to top"))

        playlist_up_button = ttk.Button(frame_move, width=3, text="⏶",
                                        command = lambda :self.__move(self.__getTreeviewFocusIndex(),self.__getTreeviewFocusIndex()-1))
        playlist_up_button.grid(column=0, row=1, pady=2)

        ToolTip(playlist_up_button, _("move up"))

        playlist_down_button = ttk.Button(frame_move, width=3, text="⏷",
                                  command = lambda :self.__move(self.__getTreeviewFocusIndex(),self.__getTreeviewFocusIndex()+1))
        playlist_down_button.grid(column=0, row=2, pady=2)

        ToolTip(playlist_down_button, _("move down"))

        playlist_superdown_button = ttk.Button(frame_move, width=3, text="⭣",
                                       command = lambda :self.__move(self.__getTreeviewFocusIndex(),99999))
        playlist_superdown_button.grid(column=0, row=3, pady=2)

        ToolTip(playlist_superdown_button, _("move to bottom"))

        playlist_delete_button = ttk.Button(frame_move, width=3, text="X",
                                    command = lambda :self.audio_bot.user_playlist.remove(self.__getTreeviewFocusIndex()))
        playlist_delete_button.grid(column=0, row=4, pady=2)

        ToolTip(playlist_delete_button, _("delete song from list"))

        playlist_clear_button = ttk.Button(frame_move, width=3, text="∅",
                                           command=self.audio_bot.user_playlist.clear)
        playlist_clear_button.grid(column=0, row=5, pady=2)

        ToolTip(playlist_clear_button, _("clear the list"))

        playlist_play_button = ttk.Button(frame_move, width=3, text="▶",
                                          command = lambda :self.audio_bot.playByIndex(self.__getTreeviewFocusIndex()))
        playlist_play_button.grid(column=0, row=6, pady=2)

        ToolTip(playlist_play_button, _("play selected"))

        playlist_bl_button = ttk.Button(frame_move, width=3, text="⛒",
                                          command=lambda: self.audio_bot.addBlacklistByIndex(self.__getTreeviewFocusIndex()))
        playlist_bl_button.grid(column=0, row=7, pady=2)

        ToolTip(playlist_bl_button, _("add to blacklist"))

        # ========== Playing frame ================
        frame_cover = ttk.Frame(frame_playing)
        frame_cover.grid(column=0, row=0, padx=4)
        frame_playinfo = ttk.Frame(frame_playing)
        frame_playinfo.grid(column=1, row=0, padx=4)
        frame_playinfo_0 = ttk.Frame(frame_playinfo)
        frame_playinfo_0.grid(column=0, row=0, padx=4, sticky=tk.W)
        frame_playinfo_1 = ttk.Frame(frame_playinfo)
        frame_playinfo_1.grid(column=0, row=1, padx=4, sticky=tk.W)
        frame_playinfo_2 = ttk.Frame(frame_playinfo)
        frame_playinfo_2.grid(column=0, row=2, padx=4, sticky=tk.W)
        frame_playinfo_3 = ttk.Frame(frame_playinfo)
        frame_playinfo_3.grid(column=0, row=3, padx=4, sticky=tk.W)

        self.playing_cover = ttk.Label(frame_cover, width=100)
        self.playing_cover.grid(column=0, row=0)

        self.playing_cover.configure(image=self.empty_image)
        self.playing_cover.image = self.empty_image

        playing_source = ttk.Label(frame_playinfo_0, textvariable=self.playing_source)
        playing_source.grid(column=0, row=0, pady=2, padx=2)
        self.playing_source.set("Waiting")

        playing_title_label = ttk.Label(frame_playinfo_1, textvariable=self.playing_title)
        playing_title_label.grid(column=0, row=0, pady=2, padx=2)
        self.playing_title.set("Waiting")

        playing_previous_button = ttk.Button(frame_playinfo_2, width=3, text="⏮",
                                             command=lambda: self.audio_bot.mpv_player.goto(0))
        playing_previous_button.grid(column=0, row=0, pady=2, padx=2)

        ToolTip(playing_previous_button,_("replay"))

        playing_pause_button = ttk.Button(frame_playinfo_2, width=3, text="⏯",
                                          command=lambda: self.audio_bot.mpv_player.toggle())
        playing_pause_button.grid(column=1, row=0, pady=2, padx=2)

        ToolTip(playing_pause_button, _("play/pause"))

        playing_next_button = ttk.Button(frame_playinfo_2, width=3, text="⏭", command=self.audio_bot.playNext)
        playing_next_button.grid(column=2, row=0, pady=2, padx=2)

        ToolTip(playing_next_button, _("play next"))

        ttk.Label(frame_playinfo_2,text= "       ").grid(column=3, row=0)

        # add volume scale
        ttk.Label(frame_playinfo_2, text=_("Volume: ")) \
            .grid(column=4, row=0)
        volume_scale = PlayerProgressBar(frame_playinfo_2,
                                         orient=tk.HORIZONTAL,
                                         variable=self.volume,
                                         from_=0,
                                         to=100,
                                         length = 64+32,
                                         command = self.__setVolume)
        volume_scale.grid(column=5, row=0)

        # add progress scale
        progress_scale = PlayerProgressBar(frame_playinfo_3,
                                           orient=tk.HORIZONTAL,
                                           variable=self.progress,
                                           from_=0,
                                           to=100,
                                           length=512-32,
                                           command = self.__setProgress)
        progress_scale.grid(column=0, row=0)

        time_label = ttk.Label(frame_playinfo_3,textvariable=self.playing_time)
        time_label.grid(column=1, row=0,padx=4)
Esempio n. 16
0
    def initialize(self):
        self.main_window.getTabController().add(self.widget,
                                                text=_("AudioBot"))

        self.room_id.set(Config.default_room)