def log_click(self, i): """ logs the button that was clicked on, the time it took the user to click it, if the user clicked the wrong button logs the error; presents the next button to click on :param i: the index of the button that was clicked on :return: nothing """ self.trials += 1 if self.button_labels[ i] != self.button_text: # log error if user clicked the wrong button self.errors += 1 self.counts[i] += 1 # increment click count for button millis = int(round(time.time() * 1000)) # get current time self.times.append( millis - self.prev_time) # log the time it took the user to click self.prev_time = millis self.resize_buttons( ) # modify button size to reflect change in click counts if self.trials < self.num_trials: # choose and present next button the user should click on self.button_text = self.button_labels[self.choose_next_button()] self.T.delete(1.0) self.T.insert("1.0", self.button_text) self.T.tag_add("center", "1.0", "end") else: # experiment ended, outputes the average time between clicks and error rate print 'end of trial!' print 'mean click time = ' + str(np.mean(self.times) / 1000.0) print 'percent errors =' + str(self.errors / self.num_trials) tkMessageBox._show( 'end of trial!', 'mean click time = ' + str(np.mean(self.times) / 1000.0) + '; percent errors =' + str(self.errors / self.num_trials))
def CheckUsersGroupsAndAll(self): self.command1 = (['id', self.UsersAndGroupsEntryUserCheck.get()]) self.get = subprocess.Popen(self.command1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.text = self.get.stdout.read() tkMessageBox._show(title='hello', message=self.text)
def checker(buttons): global click if buttons['text'] == ' ' and click == True: buttons['text'] = 'X' click = False elif buttons['text'] == ' ' and click == False: buttons['text'] = 'O' click = True elif (button1['text'] == 'X' and button2['text'] == 'X' and button3['text'] == 'X' or button4['text'] == 'X' and button5['text'] == 'X' and button6['text'] == 'X' or button7['text'] == 'X' and button8['text'] == 'X' and button9['text'] == 'X' or button1['text'] == 'X' and button4['text'] == 'X' and button7['text'] == 'X' or button2['text'] == 'X' and button5['text'] == 'X' and button8['text'] == 'X' or button3['text'] == 'X' and button6['text'] == 'X' and button9['text'] == 'X' or button1['text'] == 'X' and button5['text'] == 'X' and button9['text'] == 'X' or button3['text'] == 'X' and button5['text'] == 'X' and button7['text'] == 'X'): tkMessageBox._show('Results', 'Player X wins') elif (button1['text'] == 'O' and button2['text'] == 'O' and button3['text'] == 'O' or button4['text'] == 'O' and button5['text'] == 'O' and button6['text'] == 'O' or button7['text'] == 'O' and button8['text'] == 'O' and button9['text'] == 'O' or button1['text'] == 'O' and button4['text'] == 'O' and button7['text'] == 'O' or button2['text'] == 'O' and button5['text'] == 'O' and button8['text'] == 'O' or button3['text'] == 'O' and button6['text'] == 'O' and button9['text'] == 'O' or button1['text'] == 'O' and button5['text'] == 'O' and button9['text'] == 'O' or button3['text'] == 'O' and button5['text'] == 'O' and button7['text'] == 'O'): tkMessageBox._show('Results', 'Player O wins')
def CheckLogin(self): username = self.userName.get() #get the value of username entry field upas = self.userPassword.get() #get the value of password entry field whtRole = 0 if self.std.get( ): # checking which check button is checked if student button is check then store the enitiy as srudent and vice versa whtRole = 2 elif self.tchr.get(): whtRole = 1 with sqlite3.connect("database") as conn: #sqlite3 connection cursor = conn.cursor() resut = cursor.execute( "select *from entity where uName=? and upassword=? and role=?", (username, upas, whtRole)) found = cursor.fetchone() #print found[2] conn.commit() if found: #if user found in database self.top.destroy() if whtRole == 1: #if user is teacher q.title() #calling title function from quiz.py elif whtRole == 2: #if user is student print "student" q.showAns() else: #if credentials are wrong it will prompt the error message tkMessageBox._show("Wrong Credentials", "User Name or Password is Incorrect")
def ToAddUsersToAnotherGroups(self): infoAbutUser = tkSimpleDialog.askstring( 'hello', 'insert the user you want to add to the group') infoAbutGroup = tkSimpleDialog.askstring( 'hello', 'now insert the name of the group') os.system("usermod -aG " + infoAbutGroup + '\t' + infoAbutUser) tkMessageBox._show(title='finish the add', message='we finish the add user ' + infoAbutUser + " to the " + infoAbutGroup + ' group')
def purchaseCommand(): product = findProduct(prodName.get()) if product.buyFromStock(prodQuantity.get()): tkMessageBox._show('Successfull Purchase', "You have successfully purchased %d of %s" % (prodQuantity.get(), product.name)) updateProducts() updateProfit() topLevel.destroy() else: tkMessageBox._show('Unsuccessfull Purchase', "Not enough in stock")
def ChangeAPasswordUser(self): ChangePasswordUser = tkSimpleDialog.askstring( 'insert a password', 'insert the new password for the user', show='*') os.system('echo ' + self.UsersAndGroupsEntry2.get() + ":" + ChangePasswordUser + "|" + "chpasswd") tkMessageBox._show(title='the password is cheaged', message='this user password is changed\n user: ' + self.UsersAndGroupsEntry2.get())
def Mezclar2(): if e1.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso nombre del audio.') else: d.set(True) e1.configure(state='disabled') GenerarMix2() nombre= e1.get() GenerarAudio2(nombre) ReproMainButton1.pack(side=LEFT)
def reproducir(): #Verificar si selecciono un tipo de reproduccion if sel.get()==0: tkMessageBox._show('Error','No seleciono un tipo de reproduccion.\n Ingrese de nuevo todos los datos') else: #Llamar a la clase play que reproduce el audio sonido=play(1024) Datos=sonido.open(Nombre.get()) sonido.start(Datos[0],Datos[1],Datos[2]) sonido.play(Datos[3]) sonido.closed()
def get_p(self, event): ''' Method to get the p entry in order to dedicate colors for the path element of the matrix :param event: Binding event for the key press :return: No return ''' pindex = self.lbox_pathcolor.curselection()[0] self.lbox_pathcolor.activate(pindex) self.pseltext = self.lbox_pathcolor.get(pindex) tkMessageBox._show("Input Info.", "Path color: " + str(self.pseltext))
def addAnswer(self): #if quest is of type mcq if typeofquest == 1: if self.is_checked1.get(): self.answer = "a" if self.is_checked2.get(): self.answer = "b" if self.is_checked3.get(): self.answer = "c" if self.is_checked4.get(): self.answer = "d" query = "INSERT INTO answer(Qid,c1,c2,c3,c4,correctAnswer,answer) values(?,?,?,?,?,?,?) " parameters = self.Id, self.choice1.get(), self.choice2.get( ), self.choice3.get(), self.choice4.get(), self.answer, self.answer self.run_querry(query, parameters) #if quest is of type true false elif typeofquest == 2: if self.is_checked5.get(): self.answer = "true" elif self.is_checked6.get(): self.answer = "false" query = "INSERT INTO answer(Qid,tfAnswer,answer,c1,c2) values(?,?,?,?,?) " parameters = self.Id, self.answer, self.answer, "true", "false" #have to put comma there because to create a single element tuple self.run_querry(query, parameters) #if quest is of numeric else: self.answer = self.numericAnswer.get() query = "INSERT INTO answer(Qid,singleAnswer,answer) values(?,?,?) " parameters = self.Id, self.answer, self.answer #have to put comma there because to create a single element tuple self.run_querry(query, parameters) #is ko daikhna hai masla hai print "inside addAns", self.count self.root.withdraw() if self.count < self.Qamount: self.add() self.count = self.count + 1 else: tkMessageBox._show("Submitted", "Quiz Submitted") self.root.destroy()
def Mezclar1(): if e1.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso nombre del audio.') else: d.set(True) Niveles = Nivel.get() e1.configure(state='disabled') GenerarMix1() NivelModificado(Niveles) nombre= e1.get() GenerarAudio1(nombre) ReproMainButton1.pack(side=LEFT)
def get_tr(self, event): ''' Method to get the tr entry in order to dedicate colors for the traverse element of the matrix :param event: Binding event for the key press :return: No return ''' trindex = self.lbox_traversecolor.curselection()[0] self.lbox_traversecolor.activate(trindex) self.trseltext = self.lbox_traversecolor.get(trindex) tkMessageBox._show("Input Info.", "Traverse color: " + str(self.trseltext))
def get_w(self, event): """ Method to get the w entry in order to dedicate colors for the specific wall element of the matrix Note: W = Wall :return No return """ windex = self.lbox_wallcolor.curselection()[0] self.lbox_wallcolor.activate(windex) self.wseltext = self.lbox_wallcolor.get(windex) tkMessageBox._show("Input Info.", "Wall color: " + str(self.wseltext))
def activasms1(): if e1.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso nombre del audio.') else: d.set(True) e1.configure(state='disabled') audio1.inicio() mensaje1.pack(side=LEFT) while d.get(): audio1.grabacion() ventana.update() if d.get() is False: break
def Delay(): if e1.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso frecuencia a generar.') if e2.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso duracion del audio.') if e3.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso el numero de cuadros.') if e4.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso nombre del audio.') else: d.set(True) Frecuencia = int( e1.get()) Time = int( e2.get()) Frames = int( e3.get()) Nombre = e4.get() Niveles = Nivel.get() Delay1 = GenerarRetraso(Time,Frecuencia,Frames) Delay1.generar() Delay1.NivelModificado(Niveles) Delay1.GenerarAudio1(Nombre) Delay1.graficar()
def setcolors(self): ''' Sets the colors of the entries and places them in a dictionary. :return: No return ''' self.colors = { "W": self.wseltext, "T": self.tseltext, "M": "blue", ".": self.pseltext, "TR": self.trseltext } tkMessageBox._show("Redirect", "Processed! Please select OK.") self.root.destroy()
def newFile(): ############## # TODO: can user import vertices file? global image global canv global fileUnsaved if fileUnsaved: result = tkMessageBox._show("File Unsaved", "Save before closing?", tkMessageBox.QUESTION, tkMessageBox.YESNOCANCEL) else: result = None if str(result) == tkMessageBox.CANCEL: pass else: if str(result) == tkMessageBox.YES: saveButtonClicked() imageSize = SizeWindow(root) root.wait_window(imageSize.frame) if imageSize.ok: fileUnsaved = True size = (imageSize.x, imageSize.y) image = WorkingImage() image.newImage(size) splashPanel.destroy() canv.delete('all') canv.configure(width=image.width, height=image.height) image.buildCanvas() canv.pack(pady=50)
def filePicker(): ################# global canv global image global fileUnsaved if fileUnsaved: result = tkMessageBox._show("File Unsaved", "Save before closing?", tkMessageBox.QUESTION, tkMessageBox.YESNOCANCEL) else: result = None if str(result) == tkMessageBox.CANCEL: pass else: if str(result) == tkMessageBox.YES: saveButtonClicked() imageFile = tkFileDialog.askopenfilename() if(str(imageFile) == "()"): pass else: image = WorkingImage() image.openImage(imageFile) fileUnsaved = True splashPanel.destroy() canv.delete('all') canv.configure(width=image.width, height=image.height) image.buildCanvas() canv.pack(pady=50)
def delete_movie(): if selected_movie is not None: title = title_entry.get() id = id_entry.get() genre = genre_entry.get() movie_deleted = id + " " + title + " " + genre backend.delete_movie(id) view_all_cmd() tkMessageBox._show("Delete", 'The movie Was Deleted : \n ' + movie_deleted, tkMessageBox.INFO) else: tkMessageBox._show( "Error", "No movie was selected.\n To delete select a movie", tkMessageBox.ERROR)
def checkAnswers(self): self.score = 0 for x in range(len(self.result)): if (self.entry[x] == None): break else: pehli = self.entry[x].get() if self.result[x][5] == pehli: self.score = self.score + 1 strMarks = "Your Score Is : " marks = str(self.score) c = strMarks + " " + marks tkMessageBox._show("Marks", c)
def activasms1(): if (e1.get()) & (e2.get()) & (e3.get()) & (e4.get()) == '': print 'error' tkMessageBox._show('Error', 'Asegurese de ingresar bien los datos.') else: d.set(True) e1.configure(state='disabled') e2.configure(state='disabled') e3.configure(state='disabled') e4.configure(state='disabled') audio1.inicio() mensaje1.pack(side=LEFT) while d.get(): audio1.grabacion() ventana.update() if d.get() is False: break
def activasms1(): if e1.get() == '' or e4.get() == '' or selec.get()==0: tkMessageBox._show('Error', 'No ingreso todos los datos.') else: global d d.set(True) e1.configure(state='disabled') audio1.inicio() mensaje1.pack(side=LEFT) while d.get(): audio1.grabacion() ventana.update() if d.get() is False: break
def checkregisterion(self): firstname = self.br1.get() lesttname = self.br2.get() email = self.br3.get() password = self.br4.get() password2 = self.br5.get() self.conn = sqlite3.connect("myweb.db") self.c = self.conn.cursor() self.c.execute( '''create table if not exists michael5(id integer primary key autoincrement, firstname varchar(100),lestname varchar(200), email varchar(200), friends varchar(255),password varchar(200),scuondpasssowrd varchar(200))''') self.c.execute("insert into michael5(firstname,lestname,email,password,scuondpasssowrd) values " + str((firstname, lesttname, email, password, password2))) sql = "select * from michael5" self.c.execute(sql) ssss = self.c.fetchall() for u in ssss: print u self.conn.commit() tkMessageBox._show("chat", "thank for registerion")
def exitOSFA(): ############### if fileUnsaved: # File not saved result = tkMessageBox._show("File Unsaved", "Save before closing?", tkMessageBox.QUESTION, tkMessageBox.YESNOCANCEL) else: result = None if str(result) == tkMessageBox.CANCEL: pass else: if str(result) == tkMessageBox.YES: saveButtonClicked() root.quit()
def checkLogindata(self): self.userlog = self.ley.get() passwordlog = self.ley2.get() self.conn2 = sqlite3.connect("myweb.db") self.cc = self.conn2.cursor() fe = "select * from michael5 WHERE firstname = " fe2 = "and password="******"'"+gg+"'")+fe2+("'"+ gg2 +"'")) da2 = self.cc.fetchone() self.google2 = self.userlog + "_table" if da2 is None: tkMessageBox._show("sorry", "the username or the password are not corrct") else: tkMessageBox._show("login", "you are login user "+ self.userlog) self.chat_root() for v in da: print v
def activasms1(): if e1.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso nombre del audio.') else: Notas = Nota.get() Niveles = Nivel.get() BPM = Tempo.get() onda = Metro(CHUNK, FORMAT, CHANNELS, RATE,Notas,Niveles,BPM) onda.metrono() d.set(True) e1.configure(state='disabled') audio1.inicio() mensaje1.pack(side=LEFT) while d.get(): audio1.grabacion() ventana.update() if d.get() is False: break
def save_changes(self): """If the document has been changed, give the user the chance to save. Raises Cancelled if the user cancels.""" if self.needs_saving: name = self.get_filename() answer = tkMessageBox._show(message="Save changes to '%s'?" % name, icon='warning', type='yesnocancel') if answer == 'cancel': raise Errors.Cancelled if answer == 'yes': self.save()
def runTest(self): print "Executing script: %s" % self.command i = 2 while i == 2: # This works on osx 10.4 proc = subprocess.Popen(self.command,shell=True) # This call breaks on my os 11.0 machine. Not sure why. Had to use popen2.Popen() instead root = Tkinter.Tk() root.withdraw() i = tkMessageBox._show(type='yesno', icon='warning', message=self.message + '\nDid it pass?') proc.wait() if i == 1: self.verificationErrors.append('Did not pass')
def startBlender(): ################### if fileUnsaved: # File not saved result = tkMessageBox._show("File Unsaved", "The file is unsaved. It must be saved before opening Blender. Save now?", tkMessageBox.QUESTION, tkMessageBox.YESNOCANCEL) else: result = None if (str(result) == tkMessageBox.CANCEL) or (str(result) == tkMessageBox.NO): pass else: if str(result) == tkMessageBox.YES: saveButtonClicked() root.quit() os.system(BLENDER_SCRIPT + ' ' + vertices.name)
def metrica(): if e1.get() == '' or e4.get() == '': tkMessageBox._show('Error', 'No ingreso todos los datos.') else: global mtr s=selec.get() mtr=str(s) mtr=mtr+'.wav' Gmetrono = metronomo(e4.get(),cuadro3.get(), mtr) Rmetro = Gmetrono.metrono() volrajustado=Gmetrono.niveldeaudio(cuadro5.get(), Rmetro) doc=file(44100,16,mtr) doc.archive(volrajustado)
def checkSaved(self): if self.currentSaved: return True ret = tkMessageBox._show("Pad", "Save changes to file?", icon=tkMessageBox.QUESTION, type=tkMessageBox.YESNOCANCEL) if ret=='yes': ret = self.save_file() if not ret: return False else: return True elif ret == 'no': return True elif ret == 'cancel': return False
def checkSaved(self): if self.currentSaved: return True ret = tkMessageBox._show("Pad", "Save changes to file?", icon=tkMessageBox.QUESTION, type=tkMessageBox.YESNOCANCEL) if ret == 'yes': ret = self.save_file() if not ret: return False else: return True elif ret == 'no': return True elif ret == 'cancel': return False
def run(self, callback, args): # TODO: Support linux # Arguments should have a 'type' key which can be any of: # 'abortretryignore','ok','okcancel','retrycancel','yesno','yesnocancel' if SystemInfo.get_os() in ["Windows", "Darwin"]: window = Tk() window.wm_withdraw() # center the window on the main screen window.geometry("1x1+" + str(window.winfo_screenwidth() / 2) + "+" + str(window.winfo_screenheight() / 2)) # noinspection PyProtectedMember answer = tkMessageBox._show(type=args['type'], title=args['title'], message=args['message'], icon=None, ) callback(self, StatusCode.status_dict(StatusCode.SUCCESS), {"answer": answer}) else: callback(self, StatusCode.UNSUPPORTED_OS, None) Logger().critical('Unsupported OS')
def gamePlay(self): ''' :param initpos: Takes in the initial position as a position object. :return: Allows flow of the function as long as we are able to move throughout the map. ''' self.currentState.col = self.initialpos.col self.currentState.row = self.initialpos.row while True: move = self.checkPos() if move == 0: # Condition if there is no move. if self.stackObject.size() == 0: break else: item = self.stackObject.pop() # ---------Backtrack Process------------ # 0 represents that we went NORTH, so we need to go down, so row increase # 1 represents that we went EAST, so we need to decrease the column # 2 represent the we went SOUTH, so we need to row decrease # 3 represent that we went WEST, so we need to increase the column if item == 0: self.currentState.row += 1 elif item == 1: self.currentState.col -= 1 elif item == 3: self.currentState.col += 1 else: self.currentState.row -= 1 else: continue tkMessageBox._show("Complete", "Congratulations!")
def closeImage(): ################# global fileUnsaved if fileUnsaved: # File not saved result = tkMessageBox._show("File Unsaved", "Save before closing?", tkMessageBox.QUESTION, tkMessageBox.YESNOCANCEL) else: result = None if str(result) == tkMessageBox.CANCEL: pass else: if str(result) == tkMessageBox.YES: saveButtonClicked() canv.delete('all') canv.configure(width=0,height=0) canv.pack(pady=0) root.geometry("600x600+0+0") splashPanel = Label(root, image=splash) splashPanel.pack(side='top', fill='both', expand='yes') shapes.clear() fileUnsaved = False
def add_movie(): try: title = (title_entry.get(), "title") id = (id_entry.get(), "id") genre = (genre_entry.get(), "genre") if title[0] == "" or id[0] == "" or genre[0] == "": tkMessageBox._show("Error", "Please entry id title and genre", tkMessageBox.ERROR) else: if id[0].isdigit() is False: tkMessageBox._show( "Error", "Please entry id contains from integers only", tkMessageBox.ERROR) else: backend.add_movie(id, title, genre) mesg = id[0] + " " + title[0] + " " + genre[0] tkMessageBox._show("Insert", 'The movie Was Insert : \n ' + mesg, tkMessageBox.INFO) except Exception: tkMessageBox._show("Error", "insert movie was canceled, try again", tkMessageBox.ERROR)
def run(self, callback, args): # TODO: Support linux # Arguments should have a 'type' key which can be any of: # 'abortretryignore','ok','okcancel','retrycancel','yesno','yesnocancel' if SystemInfo.get_os() in ["Windows", "Darwin"]: window = Tk() window.wm_withdraw() # center the window on the main screen window.geometry("1x1+" + str(window.winfo_screenwidth() / 2) + "+" + str(window.winfo_screenheight() / 2)) # noinspection PyProtectedMember answer = tkMessageBox._show( type=args['type'], title=args['title'], message=args['message'], icon=None, ) callback(self, StatusCode.status_dict(StatusCode.SUCCESS), {"answer": answer}) else: callback(self, StatusCode.UNSUPPORTED_OS, None) Logger().critical('Unsupported OS')
def update_movie(): if selected_movie is not None: new_title = title_entry.get() new_id = id_entry.get() new_genre = genre_entry.get() id_was_changed = str(selected_movie[0]) != new_id if id_was_changed: # wait for an answer if need to support it tkMessageBox._show("Update", "you cant change a id") else: backend.update_movie(selected_movie[0], new_id, new_title, new_genre) old_movie = str(selected_movie[0]) + " " + str( selected_movie[1]) + " " + str(selected_movie[2]) new_movie = new_id + " " + new_title + " " + new_genre tkMessageBox._show( "Update", 'The movie Was Update from : \n ' + old_movie + "\n" "to : \n " + new_movie, tkMessageBox.INFO) view_all_cmd() else: tkMessageBox._show( "Error", "No movie was selected.\n To update select a movie", tkMessageBox.ERROR)
def Delay3(): if e2.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso la cantidad de repeticiones.') if e6.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso los milisegundos.') if e4.get() == '': print 'error' tkMessageBox._show('Error', 'No ingreso nombre del audio.') else: d.set(True) Repe= int( e2.get()) Time= float(e6.get()) Niveles = float(Nivel.get()) Nombre = e4.get() DelayA=GenerarDelay(Time,Repe) DelayA.DelayOn() DelayA.NivelModificado(Niveles) DelayA.GenerarAudio1(Nombre)
def simulate(omgevingsmatrix, start, stop, updatesize=1): ''' berkend en visuwaliseert path doormiddel van het A* algorithme :param omgevingsmatrix: matrix van de omgeving :param start: coordinaten van startpunt [x,y] :param stop: coordinaten van eindpunt [x,y] :return: ''' calculation_matrix = set.creat_matrix( len(omgevingsmatrix[0]), len(omgevingsmatrix) ) # maak matrix aan voor het opslaan van de gegevens step_matrix = set.creat_matrix(len(omgevingsmatrix[0]), len( omgevingsmatrix)) # maak matrix aan voor het opslaan van de gegeven pygame.init() # berekenen van de germenigingsvuldigingsfactor voor de breedte en hoogte van het scherm screen_info = pygame.display.Info() ver_widt = int(math.floor(screen_info.current_w / len(omgevingsmatrix[0]))) ver_height = int(math.floor(screen_info.current_h / len(omgevingsmatrix))) if ver_widt < ver_height: ver_factor = ver_widt else: ver_factor = ver_height DISPLAY = pygame.display.set_mode((len(omgevingsmatrix[0]) * ver_factor, len(omgevingsmatrix) * ver_factor), FULLSCREEN | DOUBLEBUF, 32) pygame.event.set_allowed([QUIT, K_ESCAPE, K_TAB]) pygame.display.set_caption("simulate A* algorithm") DISPLAY.fill((255, 255, 255)) frameteller = 0 found = False while True: try: #print frameteller keys = pygame.key.get_pressed() if keys[K_ESCAPE]: pygame.display.set_mode((len(omgevingsmatrix[0]) * ver_factor, len(omgevingsmatrix) * ver_factor)) if keys[K_TAB]: pygame.display.set_mode((len(omgevingsmatrix[0]) * ver_factor, len(omgevingsmatrix) * ver_factor), FULLSCREEN | DOUBLEBUF, 32) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() for x in range(0, updatesize, 1): if found == False: frameteller = frameteller + 1 omgevingsmatrix, calculation_matrix, step_matrix = calculate( omgevingsmatrix, calculation_matrix, step_matrix, start, stop) if calculation_matrix[stop[1]][stop[0]] is not 0: found = True pygame.display.set_mode( (len(omgevingsmatrix[0]) * ver_factor, len(omgevingsmatrix) * ver_factor)) update_screen(DISPLAY, ver_factor, omgevingsmatrix, calculation_matrix, step_matrix, start, stop) printmatrix(calculation_matrix) tkMessageBox._show( "Found", "Endpoint found after " + str(frameteller) + " iteration") except: pygame.display.set_mode((len(omgevingsmatrix[0]) * ver_factor, len(omgevingsmatrix) * ver_factor)) tkMessageBox.showerror("Not possible to simulate") pygame.quit() update_screen(DISPLAY, ver_factor, omgevingsmatrix, calculation_matrix, step_matrix, start, stop) pygame.display.update()
def checkCommand(): prod = findProduct(prodName.get()) tkMessageBox._show('Price is', prod.price) topLevel.destroy()
def SquidStop(self): os.system("service squid stop") tkMessageBox._show(title='squid', message='the squid stoped')
def checkCommand(): prod = findProduct(prodName.get()) tkMessageBox._show('We have:', prod.quantity) topLevel.destroy()
def showDialogBox(mssg, icon="info", type="ok", default="ok"): """Return a pop-up dialog box containing message mssg""" return tkMessageBox._show("Battleship", mssg, icon, type, default=default)
def sumatoria(): #llamar a los arreglos de los tres archivos global file1, file2, file3 #Seleccion de reproduccion monofonica if sel.get() == 1: #Vericar si se subieron los archivos e ingreso nombre if len(file1)==0 or len(file2)==0 or len(file3)==0 or Nombre.get()=='': tkMessageBox._show('Error', 'No ingreso todos los datos.\nCarge de nuevo los audios,\ne ingrese el nombre del archivo nuevo.') sel.set(0) else: #Verificar que cada archivo es de diferente tamano if len(file1)==len(file2) or len(file1)== len(file3) or len(file3)==len(file2): tkMessageBox._show('Error','Los audios no pueden ser de igual duracion.\nCarge de nuevo los audios') else: #Llamar a la clase Iteraciones audio=Iteraciones(file1, file2, file3) #llamar a la funcion Rsimultanea para que suenen los tres audios al tiempo Naudio=audio.Rsimultanea() #ajuste de volumen con la funcion niveldeaudio val=audio.niveldeaudio(Volumen.get(), Naudio) #archivar el nuevo audio Narchivo=file(44100,16,Nombre.get()) Narchivo.archive(val) #Seleccion de reproducir una despues de otro if sel.get() == 2: if len(file1)==0 or len(file2)==0 or len(file3)==0 or Nombre.get()=='': tkMessageBox._show('Error', 'No ingreso todos los datos\nCarge de nuevo los audios,\ne ingrese el nombre del archivo nuevo.') sel.set(0) else: if len(file1)==len(file2) or len(file1)== len(file3) or len(file3)==len(file2): tkMessageBox._show('Error','Los audios no pueden ser de igual duracion.\nCarge de nuevo los audios') else: audio=Iteraciones(file1, file2, file3) #llamar a la funcion Rcontinua para que suenen los tres audios uno despues de otro Naudio=audio.Rcontinua() val=audio.niveldeaudio(Volumen.get(), Naudio) Narchivo=file(44100,16,Nombre.get()) Narchivo.archive(val) #Seleccion de reproduccion estereo if sel.get() == 3: if len(file1)==0 or len(file2)==0 or len(file3)==0 or Nombre.get()=='': tkMessageBox._show('Error', 'No ingreso todos los datos.\nCarge de nuevo los audios,\ne ingrese el nombre del archivo nuevo.') sel.set(0) else: if len(file1)==len(file2) or len(file1)== len(file3) or len(file3)==len(file2): tkMessageBox._show('Error','Los audios no pueden ser de igual duracion.\nCarge de nuevo los audios') else: #arreglo del audio final Audiofinal=[] audio=Iteraciones(file1, file2, file3) #Llamar a la funcion Resterio1 para sumar el audio1 con el audio3 Naudio1=audio.Resterio1() #Llamar a la funcion Resterio2 para sumar el audio2 con el audio3 Naudio2=audio.Resterio2() val1=audio.niveldeaudio(Volumen.get(), Naudio1) val2=audio.niveldeaudio(Volumen.get(), Naudio2) out=wave.open(Nombre.get()+".wav", 'w') out.setparams((2, 2, 44100, 0, 'NONE', 'not compressed')) a=len(val1) b=len(val2) #Comparar el tamano de los dos arreglos nuevos para el orden de las iteraciones if a<b: #Iteracion que reparte los dos nuevos audios entre derecha e izquierda for i in range(0,a): l = struct.pack('<h', val1[i]) r= struct.pack('<h', val2[i]) Audiofinal.append(l) Audiofinal.append(r) #Iteracion que acomoda el resto del audio restante for i in range(a,b): l = struct.pack('<h', 0) r= struct.pack('<h', val2[i]) Audiofinal.append(l) Audiofinal.append(r) if b<a: for i in range(0,b): l = struct.pack('<h', val1[i]) r= struct.pack('<h', val2[i]) Audiofinal.append(l) Audiofinal.append(r) for i in range(b,a): l= struct.pack('<h', val1[i]) r= struct.pack('<h', 0) Audiofinal.append(l) Audiofinal.append(r) value_str=''.join(Audiofinal) out.writeframes(value_str) out.close()
def createMessageBox(windowName, windowMessage): tkMessageBox._show(windowName, windowMessage) updateProducts() updateProfit()
def OpenVpnStart(self): os.system("service openvpn start") tkMessageBox._show(title='openvpn', message='the openvpn start')
import Tkinter from tkMessageBox import _show top = Tkinter.Tk() label = Tkinter.Label(top, text = 'Hello World!') label.pack() enter_show = lambda : _show('button', '1111') def change(test): button = test button = '1111' quit = Tkinter.Button(top, text = 'quit', command = top.quit, bg ='red', fg = 'white') button1 = Tkinter.Button(top, text = '1111', command = enter_show, bg ='red', fg = 'white') button2 = Tkinter.Button(top, text = button, command = change('kobe'), bg ='red', fg = 'white') button3 = Tkinter.Button(top, text = '3333', command = top.quit, bg ='red', fg = 'white') button1.pack(fill = Tkinter.X, expand = 1) button2.pack(fill = Tkinter.X, expand = 1) button3.pack(fill = Tkinter.X, expand = 1) quit.pack(fill = Tkinter.X, expand=1) Tkinter.mainloop()
def askYesNoCancel(self, t,m): return tkMessageBox._show(title=t, message=m, type="yesnocancel", icon="warning")
def showAns(self): top = Tk() _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#d9d9d9' # X11 color: 'gray85' font10 = "-family {DejaVu Sans} -size 11 -weight bold -slant " \ "italic -underline 0 -overstrike 0" font11 = "-family {DejaVu Sans} -size 13 -weight bold -slant " \ "roman -underline 0 -overstrike 0" font9 = "-family {DejaVu Sans} -size 9 -weight normal -slant " \ "roman -underline 0 -overstrike 0" top.geometry("1790x990+103+32") top.title("True False") top.configure(background="#006b31") top.configure(highlightcolor="black") with sqlite3.connect(self.dbNAme) as conn: cursor = conn.cursor() query = "Select question.qtext,answer.c1,answer.c2,answer.c3,answer.c4 ,answer.answer,question.qtype,question.qDesc,question.qName From question,answer where question.id= answer.aid" data = cursor.execute(query) conn.commit() self.result = data.fetchall() print self.result tkMessageBox._show( self.result[0][8], self.result[0][7] ) # this message box shows the description writen by teacher about quiz and quiz title label = [NONE] * 100 # creating a list that can hold 100 elements self.entry = [NONE] * 1000 numberforlabel = 0 numberforentry = 0 for i in xrange(len(self.result)): self.counti = self.counti + 1 for j in xrange( len(self.result[i]) - 4 ): #-1 is done because query returns the column which as correct answer so i did not show that column label[i] = Label(top, text=self.result[i][j], font=("Helvetica", 16), bg="#006b31", fg="white") numberforlabel = numberforlabel + 100 # label[i] = Label(top, text=self.result[i][j], font=("Helvetica", 16), bg="#006b31", fg="white") label[i].grid(row=i, column=j, columnspan=1, ipadx=25, ipady=20, sticky=W) # elif i==15 # label[i].pack() self.countj = self.countj + 1 print self.counti, self.countj for k in range(len(self.result)): numberforentry = numberforentry + 80 self.entry[k] = Entry(top, font=("Helvetica", 16)) self.entry[k].place(x=1250, y=-55 + numberforentry, relheight=0.04, relwidth=0.12) self.quitQuiz = Button(top, command=self.close) self.quitQuiz.place(relx=0.84, rely=0.9, height=46, width=107) self.quitQuiz.configure(activebackground="#d9d9d9") self.quitQuiz.configure(background="#040404") self.quitQuiz.configure(font=font10) self.quitQuiz.configure(foreground="#ffffff") self.quitQuiz.configure(text='''Quit''') self.menubar = Menu(top, font="TkMenuFont", bg=_bgcolor, fg=_fgcolor) top.configure(menu=self.menubar) self.submitQuiz = Button(top, command=self.checkAnswers) self.submitQuiz.place(relx=0.71, rely=0.9, height=46, width=107) self.submitQuiz.configure(activebackground="#d9d9d9") self.submitQuiz.configure(background="#040404") self.submitQuiz.configure(font=font10) self.submitQuiz.configure(foreground="#ffffff") self.submitQuiz.configure(text='''submit''') top.mainloop()
def about(): tkMessageBox._show('About NotePad', 'Just a run of the mill notepad.')
def SquidStart(self): os.system("service squid start") tkMessageBox._show(title='mysql', message='the squid start')
def checkCommand(): products = [] for product in Product.product_list: products.append(product.name) tkMessageBox._show('We have in stock:', products) topLevel.destroy()
def askYesNoCancel(self, t, m): return tkMessageBox._show(title=t, message=m, type="yesnocancel", icon="warning")
def OpenVpnStop(self): os.system("service openvpn stop") tkMessageBox._show(title='openvpn', message='the openvpn stoped')
def __init__(self, master): tkMessageBox._show( "Instructions", "Please select a color for each entry. List boxes" " do not keep their visual selection, but they are" " registered. Press Submit when finished.") self.root = master # Set the file name label text lbl_wallcolor = "Wall Color: " lbl_treasurecolor = "Treasure Color: " lbl_pathcolor = "Path Color: " lbl_traversecolor = "Traverse Color: " self.lbl_wallcolor = LabelFrame(master, text=lbl_wallcolor) self.lbl_wallcolor.pack() self.lbox_wallcolor = Listbox(self.lbl_wallcolor, selectmode=BROWSE, height=7) self.lbox_wallcolor.insert(1, "red") self.lbox_wallcolor.insert(2, "brown") self.lbox_wallcolor.insert(3, "purple") self.lbox_wallcolor.insert(4, "orange") self.lbox_wallcolor.insert(5, "yellow") self.lbox_wallcolor.insert(6, "green") self.lbox_wallcolor.insert(7, "white") self.lbl_treasurecolor = LabelFrame(master, text=lbl_treasurecolor) self.lbl_treasurecolor.pack() self.lbox_treasurecolor = Listbox(self.lbl_treasurecolor, selectmode=BROWSE, height=7) self.lbox_treasurecolor.insert(1, "red") self.lbox_treasurecolor.insert(2, "brown") self.lbox_treasurecolor.insert(3, "purple") self.lbox_treasurecolor.insert(4, "orange") self.lbox_treasurecolor.insert(5, "yellow") self.lbox_treasurecolor.insert(6, "green") self.lbox_treasurecolor.insert(7, "white") self.lbl_pathcolor = LabelFrame(master, text=lbl_pathcolor) self.lbl_pathcolor.pack() self.lbox_pathcolor = Listbox(self.lbl_pathcolor, selectmode=BROWSE, height=7) self.lbox_pathcolor.insert(1, "red") self.lbox_pathcolor.insert(2, "brown") self.lbox_pathcolor.insert(3, "purple") self.lbox_pathcolor.insert(4, "orange") self.lbox_pathcolor.insert(5, "yellow") self.lbox_pathcolor.insert(6, "green") self.lbox_pathcolor.insert(7, "white") self.lbl_traversecolor = LabelFrame(master, text=lbl_traversecolor) self.lbl_traversecolor.pack() self.lbox_traversecolor = Listbox(self.lbl_traversecolor, selectmode=BROWSE, height=7) self.lbox_traversecolor.insert(1, "red") self.lbox_traversecolor.insert(2, "brown") self.lbox_traversecolor.insert(3, "purple") self.lbox_traversecolor.insert(4, "orange") self.lbox_traversecolor.insert(5, "yellow") self.lbox_traversecolor.insert(6, "green") self.lbox_traversecolor.insert(7, "white") self.lbox_wallcolor.pack() self.lbox_treasurecolor.pack() self.lbox_pathcolor.pack() self.lbox_traversecolor.pack() self.btn_return = Button(self.lbl_traversecolor, justify=CENTER, text="Submit", command=self.setcolors) self.btn_return.pack() self.lbox_wallcolor.bind('<ButtonRelease-1>', self.get_w) self.lbox_pathcolor.bind('<ButtonRelease-1>', self.get_p) self.lbox_treasurecolor.bind('<ButtonRelease-1>', self.get_t) self.lbox_traversecolor.bind('<ButtonRelease-1>', self.get_tr)
def activasms1(): if e1.get()== '': print 'error' tkMessageBox._show('Error', 'No ingreso el nombre del audio a grabar.') elif e2.get()== '': print 'error' tkMessageBox._show('Error', 'No ingreso la nota del metronomo.') elif e3.get()== '': print 'error' tkMessageBox._show('Error', 'No ingreso el bpm del metronomo.') elif e4.get()== '': print 'error' tkMessageBox._show('Error', 'No ingreso la metrica del metronomo.') else: d.set(True) g=e2.get() if g=="do": frecFundamental=261.63 print("La nota escogida es: do") if g=="re": frecFundamental=293.66 print("La nota escogida es: re") if g=="mi": frecFundamental=329.63 print("La nota escogida es: mi") if g=="fa": frecFundamental=349.23 print("La nota escogida es: fa") if g=="sol": frecFundamental=392.00 print("La nota escogida es: sol") if g=="la": frecFundamental=440.00 print("La nota escogida es: la") if g=="si": frecFundamental=493.88 print("La nota escogida es: si") t=float(e3.get()) tiempo=(60/t) negra=tiempo/2 corchea=tiempo/4 print("El bpm es:") print(t) m=float(e4.get()) if m == 1: onda = Seno(RATE, MaxBits, frecFundamental, m,negra) print("Metrica de: 4/4") if m == 2: onda = Seno(RATE, MaxBits, frecFundamental, m,negra) print("Metrica de: 3/4") if m == 3: onda = Seno(RATE, MaxBits, frecFundamental, m,negra) print("Metrica de: 2/4") if m == 4: onda = Seno(RATE, MaxBits, frecFundamental, m,corchea) print("Metrica de: 6/8") e1.configure(state='disabled') e2.configure(state='disabled') e3.configure(state='disabled') e4.configure(state='disabled') datos = onda.generar() datosAjustados = onda.leveladjust(datos,MaxBits,level) archivo = Archivo(RATE, MaxBits,Nombre) archivo.archivar(datosAjustados) audio = Audio(buffer) Datos = audio.abrir(Nombre) audio.inicio(Datos[0],Datos[1],Datos[2]) audio.reproducir(Datos[3]) audio1.inicio() mensaje1.pack(side=BOTTOM) print("G R A B A N D O...") while d.get(): audio1.grabacion() ventana.update() if d.get() is False: break audio.cerrar()
def Instruc(): tkMessageBox._show('Instrucciones de Uso', '1. Ingresar nombre del archivo \n'+ '2. Ingresar parametros del Metronomo \n'+ '3. Oprimir "Grabar" \n'+ '4. Oprimir "Metronomo" \n'+ '5. Al terminar de grabar oprima "Parar" \n'+ '5. Oprima "Reproducir" para escuchar \n' )