示例#1
0
def adicionarMusica():
    global listaNomes, opcoes, lista, musica_e, z, fundo, cor_fundo_escolhida, botao_play, valor_play_pause
    jatem = False
    root = Tk()
    root.geometry('0x0')
    root.overrideredirect(False)
    root.iconbitmap('icones\icon_player.ico')
    opcoes['defaultextension'] = '.mp3'
    opcoes['filetypes'] = [('arquivos .mp3', '.mp3')]
    opcoes['initialdir'] = ''  # será o diretório atual
    opcoes['initialfile'] = ''  #apresenta todos os arquivos no diretorio
    opcoes['title'] = 'Selecione a música'
    nome_musica = askopenfile(mode='r', **opcoes)
    root.destroy()
    root.mainloop()
    try:
        fundo.fill(cor_fundo_escolhida)
        d = nome_musica.name
        f = d.split('/')
        w = f[len(f) - 1]
        w = w.split('.')
        if d in listaNomes:
            pyautogui.alert(text='A música \"' + w[0] +
                            '\" já encontra-se na lista!',
                            title='',
                            button='OK')
            listaNomes = listaNomes
            lista = lista
            jatem = True
        else:
            try:
                pygame.mixer.music.load(d)
                pygame.mixer.music.play()
                listaNomes.append(nome_musica.name)
                lista.append(w[0])
                musica_e = w[0]
                z = len(lista) - 1
            except:
                pyautogui.alert(text='Não foi possível reproduzir a música!',
                                title='Erro',
                                button='OK')
        if valor_play_pause == 1 and jatem == False:
            botao_play = pygame.image.load("icones\icon_play_pause.png")
            valor_play_pause = 0
    except AttributeError as error:
        listaNomes = listaNomes
        lista = lista
    salvarLista()
示例#2
0
class WCUI:
    window = ""

    Sc_height = 0
    Sc_width = 0

    def __init__(self):
        self.window = Tk()
        self.window.title("Web Customizer")
        self.window.geometry('800x800')
        self.window.config(bg="white")
        self.window.overrideredirect(False)

        self.Sc_height = self.window.winfo_screenheight() // 2
        self.Sc_width = self.window.winfo_screenwidth() // 2

        self.window.geometry(f"{self.Sc_width}x{self.Sc_height}")
        print(self.Sc_height)
        self.nlpObject = Nlp()
        self.htmlObject = html_writer()

    def makeChanges(self, changes):
        if (len(changes) >= 3 and not (changes == None)
                and not (changes == "")):
            print(changes)
            self.nlpObject.proccessInput(changes)

    def resetpage(self):
        self.htmlObject.file_writer()

    def clearEntry(self, inputText):
        self.inputText.delete(0.0, 23.0)

    def mainmenu(self):
        myFont = font.Font(size=15)

        self.inputText = Text(self.window,
                              height=self.Sc_height,
                              width=self.Sc_width,
                              bg="black",
                              fg="white",
                              insertbackground='white')
        self.inputText['font'] = myFont
        self.inputText.insert(0.0, 'Type changes need here ...')
        self.inputText.bind("<Button-1>", self.clearEntry)
        self.inputText.place(relx=0, rely=0)

        resetbutton = Button(self.window,
                             text="Reset Webpage",
                             width=400,
                             bg="yellow",
                             fg="black",
                             command=lambda: self.resetpage())
        resetbutton['font'] = myFont
        resetbutton.pack(side=BOTTOM)

        button = Button(self.window,
                        text="Apply Changes",
                        width=500,
                        bg="blue",
                        fg="white",
                        command=lambda: self.makeChanges(
                            self.inputText.get("1.0", "end-1c")))
        button['font'] = myFont
        button.pack(side=BOTTOM)
        self.window.mainloop()