def get_color(self): boolean = True while boolean: try: red = int( prompt(text='Введите значение Red (от 0 до 255)', title='Ввод')) green = int( prompt(text='Введите значение Green (от 0 до 255)', title='Ввод')) blue = int( prompt(text='Введите значение Blue (от 0 до 255)', title='Ввод')) if (0 <= red <= 255 and 0 <= green <= 255 and 0 <= blue <= 255): boolean = False color = (red, green, blue) return color else: alert(text='Введите численное значение от 0 до 255', title='Ошибка ввода') except ValueError: alert(text='Введите численное значение от 0 до 255', title='Ошибка ввода') except TypeError: boolean = False
def matchFile(self, filename, userInput=True): try: title, artist, score = self._topresult(filename) print("") print("AcoustID Name: %s" % title) print("AcoustID Artist: %s" % artist) print("") self.spotifysearch.search( "%s - %s" % (title, artist) ) # Plug back in our acoustID results into spotify search return self.spotifysearch.selectResult( 0) # Return the resulting spotify track except TypeError: # Again, If we could not identify a match # TODO: Work on the userInput exception handling... e.g. skip None Songs if userInput == True: pymsgbox.alert(text='Could not identify song automatically', title='Song ID Error', button='OK') userSongName = pymsgbox.prompt(text='Song Name', title='Enter Song Name') userSongArtist = pymsgbox.prompt(text='Artist', title='Enter Artist Name') self.spotifysearch.search( "%s - %s" % (userSongName, userSongArtist) ) # Search spotify with user entered values return self.spotifysearch.selectResult( 0) # Return the resulting spotify track else: return None
def CSV2VCF(): Tk().withdraw() somefile=askopenfilename(filetypes=[ ("CSV Files", ("*.csv")), ("CSV", '*.csv'), ('All', '*') ],) Add2Name=pymsgbox.prompt('Anything add to Name :') VCF_File= pymsgbox.prompt('VCF Name:') + '.vcf' with open( somefile, 'r' ) as source: reader = csv.reader( source ) allvcf = open(VCF_File, 'w') i = 0 for row in reader: allvcf.write('BEGIN:VCARD' + "\n") allvcf.write('VERSION:3.0' + "\n") allvcf.write('N:' + Add2Name +';'+ row[0] + ';' + row[1] + "\n") allvcf.write('FN:' + row[1] + ' ' + row[0] + "\n") allvcf.write('ORG:' + row[2] + "\n") allvcf.write('TEL;CELL:' + row[4] + "\n") allvcf.write('NOTE:' + row[3] + "\n") allvcf.write('END:VCARD' + "\n") allvcf.write("\n") i += 1#counts allvcf.close()
def test(Prix): #génération d'un prix aléatoire boisson = generation_nom_boisson(Prix) #Msg Box popup pour poser la question sur cettte boisson proposition_de_demarage_du_jeu = pymsgbox.alert( 'Quel est le prix de:' + " " + boisson, 'La devinette', "Allez je me le tente!") response = pymsgbox.prompt('Vas-y propose ton prix !!?') #si la réponse est la bonne if response == str(Prix[boisson]): resultat = pymsgbox.confirm( 'Bien ouej! Tu veux rejouer tout de suite ou reprendre plus tard?', 'Fin du game?', ["Je rejoue!", 'La flemme!']) #si le user veut rejouer --> boucle sur la génération aléatoire d'un nom de boisson if resultat == "Je rejoue!": test(Prix) elif resultat == "La flemme!": pymsgbox.alert('A plus tard !', 'Fin du Game !!!', "A + !") #sinon, si la réponse est fausse elif response == None: pymsgbox.alert('A plus tard !', 'Fin du Game !!!', "A + !") else: resultat = pymsgbox.confirm( 'Et non t es pas encore au point sur ta carte, Tu veux une deuxième chance ou tu veux la réponse desuite?', 'Fin du game?', ["Deuxième chance!", 'La flemme balance la réponse!']) #si il y a 2e essaie alors le résultat de pymsgbox.confirm nous permet de boucler sur response if resultat == "Deuxième chance!": #boucle sur response response = pymsgbox.prompt( 'Attention, deuxième chance pour le prix de/du ' + " " + boisson, 'La devinette') if response == str(Prix[boisson]): resultat = pymsgbox.confirm('Top! 2e round concluant!', 'Fin du game?', ["Je rejoue!", 'La flemme!']) #si le user veut rejouer --> boucle sur la génération aléatoire d'un nom de boisson if resultat == "Je rejoue!": test(Prix) elif resultat == "La flemme!": pymsgbox.alert('A plus tard !', 'Fin du Game !!!', "A + !") elif response == None: pymsgbox.alert('A plus tard !', 'Fin du Game !!!', "A + !") else: pymsgbox.alert( "La réponse est .... :" + "\n" + str(Prix[boisson]) + " ma gueule :) ! ", 'Fin du Game !!!', "OK maintenant c dans ma ptite tête !!") else: pymsgbox.alert( "La réponse est .... :" + "\n" + str(Prix[boisson]) + " ma gueule :) ! ", 'Fin du Game !!!', "OK maintenant c dans ma ptite tête !!")
def gesture_details_data(self): """ Capturing the details of the gesture, gesture ID and Gesture details and inserting it into the database :return: None """ # self.gesture_id = input('Gesture Number') conn = sqlite3.connect(self.gesture_db) query = "SELECT max(gesture_id) FROM isl_gesture " cursor = conn.execute(query) for row in cursor: gesture_id = row[0] conn.close() try: id_value = pymsgbox.prompt('Gesture Number', default=int(gesture_id) + 1, title='Gesture Information') self.gesture_id = int(-1 if id_value is None else id_value) except (ValueError, TypeError) as e: pymsgbox.alert('Please enter a valid integer ID', 'Alert!') self.gesture_details_data() return if self.gesture_id is -1: exit(0) else: self.gesture_id = str(self.gesture_id) # self.gesture_detail = input('Gesture Details') self.gesture_detail = pymsgbox.prompt('Gesture Details', default='', title='Gesture Information') if self.gesture_detail is None: exit(0) conn = sqlite3.connect(self.gesture_db) query = "INSERT INTO isl_gesture (gesture_id, gesture_detail) VALUES (%s, \'%s\')" % \ (self.gesture_id, self.gesture_detail) try: conn.execute(query) except sqlite3.IntegrityError: # choice = input("Gesture with this ID already exists. Want to change the record? (y/n): ") choice = pymsgbox.confirm( 'Gesture with this ID already exists. Want to change the record?', 'Confirm', ["Yes", 'No']) if choice.lower() == 'yes': cmd = "UPDATE isl_gesture SET gesture_detail" \ " = \'%s\' WHERE gesture_id = %s" % (self.gesture_detail, self.gesture_id) conn.execute(cmd) else: conn.close() self.gesture_details_data() return conn.commit()
def convert_pdf(): pdf = FPDF() pdf.add_page() pdf.set_font("Arial", size=15) pdf.cell(200, 10, txt="Histórico do Adicional Noturno", ln=1, align='C') pdf.cell(200, 20, txt="", align='L') f = open("Banco/banco.txt", "r") for x in f: pdf.cell(200, 10, txt=x, ln=1, align='L') f.close() filePath = QtWidgets.QFileDialog.getExistingDirectory() if filePath: try: print(filePath) diretorio = filePath nomedoarquivo = str( prompt(text='Insira o nome do PDF', title='Nome do PDF')) pdf.output(f'{diretorio}/{nomedoarquivo}.pdf') f = open("Banco/banco.txt", "a") f.write(f'\n') f.close() except Exception: pass
def msg_box(msg, title): """ send a message to the user @param msg: message to display @param title: the message title """ return pymsgbox.prompt(msg, title)
def chrome_open(url, class_name='', prompt=True): r = '' if prompt: r = msg.prompt("Enter anything to not go to class: " + class_name) if r == '': webbrowser.open_new(url) return
def completalaserie(): #inserisci il numero successivo """ numerodipassi=randint(1,3) listpasso2=list() listaa=list() a=randint(0,5) print(a) listaa.append(a) stringa='Completa la serie: ' for i in range(0,numerodipassi): stringa=stringa+str(a)+"; " passo2=randint(-5,5) a=a+passo2 listpasso2.append(passo2) listaa.append(a) print(stringa) print(listpasso2) print(listaa) c=listaa[numerodipassi] print(c) """ passo = randint(0, 5) a = randint(-5, 5) b = a + passo d = b + passo c = d + passo continua = True while continua: response = pymsgbox.prompt('Completa la serie: ' + str(a) + '; ' + str(b) + '; ' + str(d) + '; ...') continua = risultato(c, response)
def on_press(key): global check if check == True: a = 0 key = str(key).lower() for x in keys: if x == key: write(msg[a]) a = a + 1 if str(key).lower() == "key.delete": response = pymsgbox.prompt('enter equation', "epic calculator") if response and numberCheck(response): if "," in list(response): responseList = response.split(",") results = [[], []] for response in responseList: if numberCheck(response): results[0].append(str(calculate(response))) results[1].append( str(calculate(response, False))) ctypes.windll.user32.MessageBoxW( 0, "calculated equations:\n" + "\n".join(results[1]) + "\nresults:\n" + "\n".join(results[0]), "epic calculator", 0x0) else: ctypes.windll.user32.MessageBoxW( 0, "calculated equation:\n" + str(calculate(response, False)) + "\nresult:\n" + str(calculate(response)), "epic calculator", 0x0)
def stalemate(): global wins, losses msg = pymsgbox.prompt( 'Stalemate. Type P to play again or S to submit score'.format( ('BLACK', 'WHITE')[turn < 0]), 'Game Over') while msg not in ['P', 'S']: msg = pymsgbox.prompt( 'Invalid Option. Type P to play again or S to submit score', 'Error') if msg == 'S': name = pymsgbox.prompt('Enter your name', 'Name') leader_board.append([name, wins / (losses + 1)]) leader_board.sort(key=lambda x: x[1]) wins = losses = 0 reset_board() update_graphics()
def calculate(): # asks the user to input the amount of the purchase price = float(pymsgbox.prompt('Please input the amount of the purchase to calculate the total cost for the item after taxes:', 'Price of Item')) total = float(price * s * c + price) #calculates full price with taxes and outputs it pymsgbox.alert("Your new price is: $" + str(total)) "OK" return again()
def get_user_input(): user_input = pymsgbox.prompt('Enter name', default=add_txt_ext(''), title='FBPI .pdf Text Extractor') # closes program if user clicks cancel if user_input == None: exit(0) return user_input
def getTag(): tagReq = ms.prompt( "Please Enter the same tag that you entered in your phone", "Enter The tag", "4 character tag ", None, None) if (len(tagReq.strip()) != 4): getTag() else: return tagReq
def sottrazione(): #esegue la sottrazione, con il secondo termine minore del primo termine (i risultato è sempre un numero positivo) a = randint(0, 10) b = randint(a, 10) continua = True c = b - a while continua: response = pymsgbox.prompt('Quanto fa ' + str(b) + '-' + str(a) + '?') continua = risultato(c, response)
def divisioneconvirgola(): #esegue la divisione, il risultato è un numero decimale. Se intero, scrive il numero seguito da ".0" a = randint(0, 10) b = randint(a, 10) c = b / a continua = True while continua: response = pymsgbox.prompt('Quanto fa ' + str(b) + '/' + str(a) + '?') continua = risultato(c, response)
def test_timeout(self): # Note: If these test's fail, the unit tests will hang. self.assertEqual(pymsgbox._alertTkinter('timeout test', timeout=300), pymsgbox.TIMEOUT_RETURN_VALUE) self.assertEqual(pymsgbox._confirmTkinter('timeout test', timeout=300), pymsgbox.TIMEOUT_RETURN_VALUE) self.assertEqual(pymsgbox.prompt('timeout test', timeout=300), pymsgbox.TIMEOUT_RETURN_VALUE) self.assertEqual(pymsgbox.password('timeout test', timeout=300), pymsgbox.TIMEOUT_RETURN_VALUE)
def divisioneintero(): #esegue la divisione avendo come risultato sempre un numero intero. #un termine della moltiplicazione può essere maggiore di 10. c = randint(0, 10) b = randint(0, 10) a = c * b continua = True while continua: response = pymsgbox.prompt('Quanto fa ' + str(a) + '/' + str(b) + '?') continua = risultato(c, response)
def numsuccessivo(): a = randint(0, 40) c = "Vero" if a <= b: c = "Falso" continua = True while continua: response = pymsgbox.prompt(str(a) + ' > ' + str(b) + '?') continua = risultato(c, response)
def test_timeout(self): # Note: If these test's fail, the unit tests will hang. self.assertEqual(pymsgbox.alert('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT) self.assertEqual(pymsgbox.confirm('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT) self.assertEqual(pymsgbox.prompt('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT) self.assertEqual(pymsgbox.password('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT)
def setup(fail: tuple) -> tuple or None: site = prompt("Enter URL to crawl", "WebCrawler", "http://example.com/") archive = False selector = None if not site: return fail try: parsed_site = urlparse(site) if 'http' not in parsed_site.scheme: alert("Missing http") return fail except URLError: alert("Not a valid URL") return fail sitemap = prompt("Enter path to sitemap if available", "WebCrawler", "sitemap.xml") if type(sitemap) is not str or sitemap == "": sitemap = None if WebCrawler.ALLOW_ARCHIVING and confirm("Archive pages?", "WebCrawler", ["Yes", "No"]) == "Yes": archive = True raw_input = prompt( "Enter the element attribute and value that identifies the content wrapper separated " + "by '=' or Cancel to import entire page.\nExample: class=entry-content", "WebCrawler", "class=entry-content") if raw_input and raw_input.count("=") == 1: selector = raw_input.split("=") else: selector = None alert("Invalid identifier, page parsing is disabled.") return site, sitemap, archive, selector
def getInputs(): global VELOCITY, ACCELARATION, RETARDATION, MAX_SPEED, TIME_OF_UPDATE temp = str( pmb.prompt( "Please Enter in sequence mentioned\nAccelaration (m/s) -> Time of Update(s) -> Decleration(m/s) -> Max Speed(km/hr)" )).split(" ") ACCELARATION, TIME_OF_UPDATE, RETARDATION, MAX_SPEED = temp ACCELARATION = float(ACCELARATION) RETARDATION = float(RETARDATION) MAX_SPEED = float(MAX_SPEED) TIME_OF_UPDATE = float(TIME_OF_UPDATE) MAX_SPEED = MAX_SPEED * 5 / 18 # to convert into m/s
def create_file(): """ Function to create and initialize file i.e. csv file initilise = writing fields """ global CSV_FILE_NAME CSV_FILE_NAME = pmb.prompt("Enter CSV File Name: ") CSV_FILE_NAME += ".csv" fields = ['Time ', 'Veclocity (km/s)'] with open(CSV_FILE_NAME, 'w') as csvfile: csvwr = csv.writer(csvfile) csvwr.writerow(fields)
def clickChooseUser(self, event): if self.returnButton.isClicked(event.x, event.y): config.collectingData = True config.new = False config.completed = False self.page = "load" if self.newButton.isClicked(event.x, event.y): response = pymsgbox.prompt('What is your name?') config.collectingData = True config.new = True config.PersonName = " " + response config.completed = False self.page = "load"
def numprecosuccess(): #numero precedente o successivo? a = randint(0, 40) test = randint(0, 1) #0 sucessivo, 1 precedente c = a + 1 stringa = " dopo di " if test == 1: c = a - 1 stringa = " prima di " continua = True while continua: response = pymsgbox.prompt('Quale numero viene' + stringa + str(a) + ' ?') continua = risultato(c, response)
def clickChooseUser(self, event): if self.returnButton.isClicked(event.x, event.y): config.collectingData = True config.new = False config.completed = False self.page = "load" if self.newButton.isClicked(event.x, event.y): response = pymsgbox.prompt('What is your name?') config.collectingData = True config.new = True config.PersonName = " " + response config.completed = False self.page = "load"
def on_click(event): if event.inaxes is None: return if event.button == 3: ydata.append("%.1fx" % event.ydata) return if event.button != 1: return import pymsgbox text = pymsgbox.prompt(default="-".join(ydata), title='Label for Text') print('("%s", %f, %f, "%s"),' % (name, event.xdata, event.ydata, text), file=sys.stderr)
def add_api_key(message, title): api_key_path = open(API_PATH, "w") alert(message, title) key = prompt('Public API key:') # re-prompt user until the key is valid (by checking length) try: if len(key) != 64: add_api_key("Invalid key entered. Please re-enter public key", "Invalid key entered") except TypeError: exit(0) api_key_path.write(key) api_key_path.close()
def moltiplicazione(): naddendi = randint(2, 2) lista = [] c = randint(0, 10) stringa = 'Quanto fa ' + str(c) for i in range(0, naddendi): a = randint(0, 10) stringa = stringa + 'x' + str(a) c = c * a stringa = stringa + ' ?' continua = True while continua: response = pymsgbox.prompt(stringa) continua = risultato(c, response)
def ask_ticker_to_user(): # Aak ticker to user ticker = pymsgbox.prompt('Please enter a valid ticker: ') if ticker is None: exit() try: assert ticker.isalpha() except AssertionError: pymsgbox.alert("Ticker entered is invalid. Please try again.", "Assertion Error") exit() return ticker.upper()
def somma(): #esegue la somma naddendi = randint(2, 5) lista = [] a = randint(0, 10) lista.append(a) stringa = 'Quanto fa ' + str(a) for i in range(0, naddendi): a = randint(0, 10) stringa = stringa + '+' + str(a) lista.append(a) stringa = stringa + ' ?' c = sum(lista) continua = True while continua: response = pymsgbox.prompt(stringa) continua = risultato(c, response)
def test_timeout(self): # Note: If these test's fail, the unit tests will hang. self.assertEqual(pymsgbox.alert('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT) self.assertEqual(pymsgbox.confirm('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT) self.assertEqual(pymsgbox.prompt('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT) self.assertEqual(pymsgbox.password('timeout test', timeout=1000), pymsgbox.TIMEOUT_TEXT)