Apr-24-2019, 11:54 AM
from random import choice import webbrowser from tkinter import ttk from tkinter import * import tkinter import time from tkinter import messagebox import pygame import os import sys #########################Organização da janela tkinter################################# root = Tk() filename = PhotoImage(file = "C:/Bot/background.png") background_label = Label(root, image=filename) background_label.place(x=0, y=0, relwidth=1, relheight=1) root_height = 350 root_width = 520 screen_width = root.winfo_screenwidth() screen_height = root.winfo_screenheight() x_cordinate = int((screen_width/2) - (root_width/2)) y_cordinate = int((screen_height/2) - (root_height/2)) root.geometry("{}x{}+{}+{}".format(root_width, root_height, x_cordinate, y_cordinate)) ################################################################################################# ############################################################################################################### user_1 = ["google", "GOOGLE", "Google"] ############################ user_2 = ["facebook", "FACEBOOK", "Facebook"] ############################ user_3 = ["badoo", "BADOO", "Badoo"] ############################ user_4 = ["buzznet", "BUZZNET", "Buzznet"] ########################### user_5 = ["care2", "CARE2", "Care2"] ############################ user_6 = ["cafemom", "CAFEMOM", "Cafemom"] ############################ user_7 = ["cellufun", "CELLUFUN", "Cellufun"] ############################ user_8 = ["classmates", "CLASSMATES", "Classmates"] ############################ user_9 = ["deviantart", "DEVIANTART", "Deviantart"] ########################### user_10 = ["flixster", "FLIXSTER", "Flixster"] ########################### user_11 = ["flickr", "FLICKR", "Flickr"] ########################### user_12 = ["foursquare", "FOURSQUARE", "Foursquare"] ########################### user_13 = ["funnyordie", "FUNNYORDIE", "Funnyordie"] ########################### user_14 = ["gaiaonline", "GAIAONLINE", "Gaiaonline"] ########################### user_15 = ["google+", "GOOGLE+", "Google+", "googleplus", "GOOGLEPLUS", "Googleplus"] ########################### user_16 = ["instagram", "INSTAGRAM", "Instagram"] ########################### user_17 = ["kiwibox", "KIWIBOX", "Kiwibox"] ########################### user_18 = ["line", "LINE", "Line"] ########################### user_19 = ["linkedin", "LINKEDIN", "Linkedin"] ########################### user_20 = ["livejournal", "LIVEJOURNAL", "Livejournal"] ########################### error = ["NÃO RECONHEÇO ESSA OPCAO - DON'T RECOGNIZE THAT OPTION"] ########################### user_bad = [] ########################### user_piadas = ["piadas", "PIADAS", "Piadas", "rir", "RIR", "Rir", "comédia", "COMÉDIA", "Comédia", "comedia", "COMEDIA", "Comedia", "anedotas", "ANEDOTAS", "Anedotas"] bot_info = ["AGUARDE ENQUANTO AS PIADAS TERMINAM", "O PROGRAMA FICARÁ BLOQUEADO ATÉ AS PIADAS TERMINAREM"] ########################### user_jokes = ["laugh", "LAUGH", "Laugh", "jokes", "JOKES", "Jokes", "comedy", "COMEDY", "Comedy"] #################################################################################################### Utilizador = StringVar() bot = StringVar() #################################################################################################### ################################################################################################### root.title(" NeneBot v1.0 (alfa)") Label(root, text=" Utilizador\nUSER ").place(x=20, y=10, width=60) Entry(root, textvariable=Utilizador).place(x=100, y=15, width=400) Label(root, text=" Bot ").place(x=20, y=60, width=70) Entry(root, textvariable=bot, state=DISABLED).place(x=100, y=60, width=400) ################################################################################################### ################################################################################################## def main(): question = Utilizador.get()# - google website if question in user_1: Utilizador.set('') pygame.init() pygame.mixer.init() pygame.mixer.music.load("google_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("google_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("www.google.com") elif question in user_2: Utilizador.set('')# - facebook website pygame.init() pygame.mixer.init() pygame.mixer.music.load("facebook_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("facebook_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("www.facebook.com") elif question in user_3: Utilizador.set('')# - badoo website pygame.init() pygame.mixer.init() pygame.mixer.music.load("badoo_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("badoo_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("https://badoo.com/") elif question in user_4: Utilizador.set('')# - buzznet website pygame.init() pygame.mixer.init() pygame.mixer.music.load("buzznet_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("buzznet_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("www.buzznet.com/") elif question in user_5: Utilizador.set('')# - care2 website pygame.init() pygame.mixer.init() pygame.mixer.music.load("care2_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("care2_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("https://www.care2.com/") elif question in user_6: Utilizador.set('')# - cafemom website pygame.init() pygame.mixer.init() pygame.mixer.music.load("cafemom_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("cafemom_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("https://www.cafemom.com/") elif question in user_7: Utilizador.set('')# - cellufun website pygame.init() pygame.mixer.init() pygame.mixer.music.load("cellufun_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("cellufun_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("https://www.cellufun.com/games.asp?v=5gbwc9KMt00") elif question in user_8: Utilizador.set('')# - classmates website pygame.init() pygame.mixer.init() pygame.mixer.music.load("classmates_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("classmates_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("https://www.classmates.com/") elif question in user_9: Utilizador.set('')# - deviantart website pygame.init() pygame.mixer.init() pygame.mixer.music.load("deviantart_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("deviantart_en.mp3") pygame.mixer.music.play(0) time.sleep(0) for x in range(1, 110): progress_var.set(x) time.sleep(0.05) root.update() progress_var.set(0) webbrowser.open("https://www.deviantart.com/")
I'm stuck here, when the user write in the input "Jokes", after that, press the button, the same one stays stuck(like locked) and the pygame will start playing all the jokes. But, want i need is the pygame will still work, but the button will be released and the user be able to do anything else on the program
elif question in user_piadas: bot.set(choice(bot_info))# - piadas(comedia) pygame.init() pygame.mixer.init() pygame.mixer.music.load("piada1_pt.mp3") pygame.mixer.music.play(0) time.sleep(14) pygame.mixer.music.load("piada2_pt.mp3") pygame.mixer.music.play(0) time.sleep(12) pygame.mixer.music.load("piada3_pt.mp3") pygame.mixer.music.play(0) time.sleep(13) pygame.mixer.music.load("piada4_pt.mp3") pygame.mixer.music.play(0) time.sleep(12) else: Utilizador.set(choice(error)) Utilizador.set('') pygame.init() pygame.mixer.init() pygame.mixer.music.load("erro_pt.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.music.load("error_en.mp3") pygame.mixer.music.play(0) time.sleep(3) pygame.mixer.quit() progress_var = tkinter.IntVar() pb = ttk.Progressbar(root, orient="horizontal", length=400, maximum=100, mode="determinate", var=progress_var) pb.place(x=100, y=100) Button(root, text="Pressionar Botão\nPress Button", bg='green yellow', command=main).place(x=250, y=150) class Clock: def __init__(self): self.time1 = '' self.time2 = time.strftime('%H:%M:%S') self.mFrame = Frame() self.mFrame.place(x=20, y=100) self.watch = Label(self.mFrame, text=self.time2, font=('times',12,'bold')) self.watch.pack() self.changeLabel() def changeLabel(self): self.time2 = time.strftime('%H:%M:%S') self.watch.configure(text=self.time2) self.mFrame.after(200, self.changeLabel) ############################## obj1 = Clock() root.resizable(False,False) root.mainloop() if __name__=="__main__": main()