def agree_and_continue(self): if self.ids.year_of_birth.text > "2010" or self.ids.year_of_birth.text < "1940": Snackbar( text= 'Looks Like You Are Not Eligible To Use This App Because Of Your Given DOB' ).show() if len(self.ids.mobile_number.text) != 10: Snackbar(text='Invalid Mobile Number. Please Check Again').show() try: self.checkerCPS = 'NoError' data = { 'first_name': f'{self.ids.first_name.text}', 'complete_name': f'{self.ids.first_name.text} {self.ids.middle_name.text} {self.ids.last_name.text}', 'address': f'{self.ids.address.text}', 'year_of_birth': f'{self.ids.year_of_birth.text}', 'mobile_number': f'{self.ids.mobile_number.text}' } db.child("Users").child(f"{EmailID}").set(data) except: self.checkerCPS = 'Error' Snackbar( text= 'We Are Having Trouble Connecting To The Internet..Please Try Again Later' ).show()
def placeOrder(self): if datetime.combine(date.today(), self.time_takeAway) > datetime.now(): orderNum = str(randint(10000, 99999)) + str(date.today().year) + str(date.today().month) + str(date.today().day) self.cursor = db.cursor() placeOrderStatement = "insert into orderDetailsTimeTable(ordernum, studentUsername, hotelName, timeTakeAway, totalPay, orderStatus) values (%s, %s, %s, %s, %s, %s)" placeOrderDetails = (orderNum, username_current, self.hotel_obj.hotel_ordering_currently,datetime.combine(date.today(), self.time_takeAway), self.hotel_obj.totalAmount_Order,True) self.cursor.execute(placeOrderStatement, placeOrderDetails) placeOrderDishTableDetails = [] for i in self.orders_frequency_table: placeOrderDishTableDetails.extend([orderNum, i, self.orders_frequency_table[i]]) placeOrderDishTableStatement = "insert into orderDishTable(ordernum, dish, quantity) values " + ",".join( "(%s, %s, %s)" for dummy in self.orders_frequency_table) self.ids.bill_timeLbl.text = "00:00" self.ids.billConfirmBtn.disabled = True self.cursor.execute(placeOrderDishTableStatement, placeOrderDishTableDetails) db.commit() self.cursor.close() self.hotel_obj.resetValues() MDApp.get_running_app().root.ids.master.current = 'hotel' Snackbar(text='Order placed').show() else: Snackbar(text = 'Selecting past time is not valid').show()
def MuestraNotificacionComparador(self): """Se muestra las notificaciones que se anexaron al modulo del comparador de precios""" self.a = randint(1, 6) print(self.a) if self.a == 1: notification.notify( title='Como Actualizar los precios', message= 'Puedes actualizar los precios de los productos pulsando el boton de Actualizar que se encuentra en' 'la parte superior', timeout=20) snackbar = Snackbar( text= "Puedes actualizar los precios de los productos pulsando el boton de Actualizar que se encuentra en la parte superior" ) snackbar.show() if self.a == 2: notification.notify( title='Visualización de los Precios', message= 'Los precios pueden ser consultados deslizando la tabla que se muestra al consultar alguna categoría', timeout=20) snackbar = Snackbar( text= "Los precios pueden ser consultados deslizando la tabla que se muestra al consultar alguna categoría" ) snackbar.show() pass
def callback_context_menu(icon): context_menu.dismiss() if not self.file_source_code: from kivymd.uix.snackbar import Snackbar Snackbar(text="No source code for this example").show() return elif icon == "source-repository": if platform in ("win", "linux", "macosx"): webbrowser.open( f"https://github.com/HeaTTheatR/KivyMD/wiki/" f"{os.path.splitext(self.file_source_code)[0]}" ) elif icon == "language-python": self.root.ids.scr_mngr.current = "code viewer" try: self.data["Source code"][ "object" ].ids.code_input.text = open( f"{os.environ['KITCHEN_SINK_ASSETS']}md/{self.file_source_code}", "rt", encoding="utf-8", ).read() except FileNotFoundError: from kivymd.uix.snackbar import Snackbar Snackbar(text="Cannot load source code").show()
def send_email(self): if self.email_dialog_input.text: oil_list = [] visit_list = [] session = Session(bind=engine) visit = session.query(Visit).all() oil = session.query(Oil).all() for i in oil: oil_list.append([i.id, i.month, i.date, i.pay, i.comment]) for i in visit: visit_list.append([ i.id, i.month, i.date, i.type, i.name, i.address, i.distance, i.money ]) smtpObj = smtplib.SMTP('smtp.gmail.com', 587) smtpObj.starttls() smtpObj.login('*****@*****.**', 'Sasha.1794') smtpObj.sendmail( "*****@*****.**", self.email_dialog_input.text, f'{oil_list}\n{visit_list}'.replace(':', '/..').encode('utf-8')) Snackbar( text=f'Данные были отправленны на {self.email_dialog_input.text}' ).show() self.email_dialog_input.text = '' smtpObj.quit() else: Snackbar(text='Данные не были отправленны, введите gmail').show()
def forgot(self, *args): if self.ids.email.text != '': import pyrebase import requests, json from screens import fbconfig firebaseConfig = fbconfig.users_firebaseConfig firebase = pyrebase.initialize_app(firebaseConfig) auth = firebase.auth() try: user = auth.send_password_reset_email(self.ids.email.text) Snackbar(text="Password reset code has been sent to email!").open() except requests.HTTPError as e: #print('args start') error_json = e.args[1] #print(error_json) error = json.loads(error_json)['error']['message'] #print(error) msg = '' if error == "INVALID_EMAIL": msg = "Invalid email!" elif error == "EMAIL_NOT_FOUND": msg = "Email not found!" else: msg = "Something's wrong. Check your internet connection." Snackbar(text=msg).open() if os.path.isfile('helper.tn') == True: os.remove('helper.tn') else: Snackbar(text="Please enter only email to reset password!").open()
def call_imu_data(self): #used in the button that begins imu connection ip_input = self.root.ids.ipAddr.text port_input = int(self.root.ids.portAddr.text) Snackbar( text= f'Attempting connection with {ip_input} : {port_input}... this may take some time' ).show() try: self.imu_instance = client_fx(2, ip_input, port_input) Snackbar( text=f'Connection with {ip_input} : {port_input} successful!', button_text="Visualizer Screen", button_callback=self.switchToVisualizer).show() except: Snackbar( text= f'Cannot connect with {ip_input} : {port_input}... try again later' ).show() #save previous user details for next session qq = f'{ip_input}' to_write = f"{self.root.ids.ipAddr.text},{self.root.ids.portAddr.text},{self.root.ids.usr_weight.text},{self.root.ids.usr_height.text},{self.root.ids.usr_sex.text},{self.root.ids.contact01.text},{self.root.ids.refr_rate_field.text},{self.root.ids.g_thresh.text},{self.root.ids.f_det_freq.text}" with open('DefinitiveSweRC1_3\\storedDetails\\stored_details.txt', 'w') as new_detail: new_detail.write(to_write)
def check_new_password(self): self.new_password = str(self.screen.get_screen('sifredeyismeyeri').ids.newpassword.text) self.new_password2 = str(self.screen.get_screen('sifredeyismeyeri').ids.newpasswordagain.text) self.pass_text_list = [] for i in str(self.new_password): self.pass_text_list.append(i) if len(self.pass_text_list) < 8: self.sn = Snackbar( text="Şifrə uzunluğu 8 deyil." ) self.sn.show() if not self.new_password: self.sn = Snackbar( text="Şifrəni daxil edin." ).show() if not self.new_password2: self.sn = Snackbar( text="Şifrəni təkrarlayın." ).show() if self.new_password != self.new_password2: self.sn = Snackbar( text="Şifrələr eyni deyil." ).show() self.connect = s3.connect('user.db') self.cursor = self.connect.cursor() self.cursor.execute( f"""UPDATE users SET sifre='{self.new_password}' WHERE istifadeci_adi='{self.forget_username}'""") self.dialog2 = MDDialog( text='Şifrəniz dəyişdirildi.', size_hint_x='.7', buttons=[MDRaisedButton(text='OK', on_release=self.kecmenyuya2)] ).open() self.connect.commit() self.connect.close()
def copy_to_clipboard2(self): text_to_copy = self.screen.get_screen('home').ids.text_to_speech.text if text_to_copy != '': pc.copy(text_to_copy) Snackbar(text='Text coppied to clipboard').open() else: Snackbar(text='There is nothing to copy').open()
def Lines(self, obj): global line if line == False: line = True Snackbar(text="Index lenght increased").show() else: line = False Snackbar(text="Index length decreased").show()
def Bold(self, obj): global bold if bold == False: bold = True Snackbar(text="Bold Format Added").show() else: bold = False Snackbar(text="Bold Format Removed").show()
def refreshDelete(self): try: os.remove(normalizedPath) self._update_files() Snackbar(text="File Deleted!").show() except: Snackbar( text="That didn't work. Maybe the file is protected?").show()
def decrypt(self): try: pyAesCrypt.decryptFile(self.path, self.path[:-4], self.password, 64 * 1024) Snackbar(text="Completed !").show() except: Snackbar(text="error try again correctly !").show( ) # error for incorrect password or any other things
def hitung(self): toast("Counting..........") try: from rajaOngkirApi import rajaongkirApi api = rajaongkirApi(key='23930140f7b47aaebf5318262ee5d0f1', accountType='starter') self.id_origin = self.data_tables[ self.ids.ongkirscreen.ids.province.text][ self.ids.ongkirscreen.ids.kota.text] self.id_destinasi = self.data_tables[ self.ids.ongkirscreen.ids.province_tujuan.text][ self.ids.ongkirscreen.ids.kota_tujuan.text] print(self.id_origin, self.id_destinasi) if bool(self.ids.ongkirscreen.ids.weight.text) == False: from kivymd.uix.snackbar import Snackbar snackbar = Snackbar(text="Harap Isi Semuanya", duration=0.5) snackbar.show() else: harga = api.requestApi( origin=self.id_origin, destination=self.id_destinasi, weight=str(self.ids.ongkirscreen.ids.weight.text), courier=self.ids.ongkirscreen.ids.kurir.text.lower()) harga = harga.decode('utf-8') harga = json.loads(harga) deskripsi = '' for i in ((harga['rajaongkir']['results'][0]['costs'])): if 'HARI' in i["cost"][0]["etd"]: deskripsi += f' {i["service"]} : Rp {i["cost"][0]["value"]} \n Perkiraan {i["cost"][0]["etd"]}\n' else: print(f'{i["cost"][0]["etd"]}') deskripsi += f' {i["service"]} : Rp {i["cost"][0]["value"]} \n Perkiraan {i["cost"][0]["etd"]} hari\n' if self.ids.ongkirscreen.ids.kurir.text.lower() == 'jne': self.ids.ongkirscreen.ids.image.ii = self.images[0] if self.ids.ongkirscreen.ids.kurir.text.lower() == 'tiki': self.ids.ongkirscreen.ids.image.ii = self.images[1] if self.ids.ongkirscreen.ids.kurir.text.lower() == 'pos': self.ids.ongkirscreen.ids.image.ii = self.images[2] if deskripsi == '': self.ids.ongkirscreen.ids.label.text = 'tidak ada kurir yang tersedia' if deskripsi != '': self.ids.ongkirscreen.ids.label.text = deskripsi except: from kivymd.uix.snackbar import Snackbar snackbar = Snackbar(text="Harap Isi Semuanya", duration=0.5) snackbar.show()
def forget_check_username(self): self.forget_username = str(self.screen.get_screen('forgetpassword').ids.forgetusername.text) if not self.forget_username: self.sn = Snackbar(text='İstifadəçi adınzı yazın').show() self.connect = s3.connect('user.db') self.cursor = self.connect.cursor() self.username_for_check = self.screen.get_screen('forgetpassword').ids.forgetusername.text self.cursor.execute(f"""SELECT istifadeci_adi FROM users WHERE istifadeci_adi='{self.username_for_check}'""") self.connect.commit() if not self.cursor.fetchone(): self.sn = Snackbar(text="Profil mövcud deyil").show() self.connect.close() else: self.authentication_code = random.randint(111111, 999999) self.mail_content000 = str(self.authentication_code) self.connect = s3.connect('user.db') self.cursor = self.connect.cursor() self.cursor.execute(f"""SELECT mail FROM users WHERE istifadeci_adi='{self.username_for_check}' """) self.server = slib.SMTP('64.233.184.108', 587) self.server.ehlo() self.server.starttls() self.server.login("*****@*****.**", "harley572275") try: for i in self.cursor.fetchone(): self.server.sendmail("*****@*****.**", str(i), self.mail_content000) break self.dialog = MDDialog( text=("Mail adresinizə identifikasiya kodu göndərildi."), size_hint_x='.7', buttons=[ MDFlatButton( text="OK", text_color=self.theme_cls.primary_color, on_release=self.forget_authentication_code_sehifesine_kecid, ) ] ) self.dialog.open() self.connect.commit() self.connect.close() except: self.dialog = MDDialog( text=("Mail adresinizə identifikasiya kodu göndərildi."), size_hint_x='.7', buttons=[ MDFlatButton( text="OK", text_color=self.theme_cls.primary_color, on_release=self.forget_authentication_code_sehifesine_kecid, ) ] ) self.dialog.open() self.connect.commit() self.connect.close()
def call_imu_data(self): ip_input = self.root.ids.ipAddr.text port_input = int(self.root.ids.portAddr.text) try: self.imu_instance = client_fx(2, ip_input, port_input) Snackbar(text=f'Attempting connection with {ip_input} : {port_input}').show() except: Snackbar(text=f'Cannot connect with {ip_input} : {port_input}... try again later').show()
def submit_data(self): name = self._name.ids.category.text.replace('Name', '') gender = self._gender.ids.category.text.replace('Gender', '') age = self._age.ids.category.text.replace('Age', '') breed = self._breed.ids.category.text.replace('Breed', '') color = self._color.ids.category.text.replace('Color', '') size = self._size.ids.category.text.replace('Size', '') status = self._status.ids.category.text.replace('Status', '') date = self._date.ids.category.text.replace('Date', '') state = self._state.ids.category.text.replace('State', '') summary = self._summary.ids.category.text.replace('Summary', '') zip = self._zip.ids.category.text.replace('Zip', '') city = self._city.ids.category.text.replace('City', '') images = self._images id = uuid.uuid4() dict = { 'name': name.strip(), 'gender': gender.strip(), 'age': age.strip(), 'breed': breed.strip(), 'color': color.strip(), 'size': size.strip(), 'status': status.strip(), 'date': date.strip(), 'state': state.strip(), 'zip': zip.strip(), 'city': city.strip(), 'summary': summary, 'petid': id } for key, value in dict.items(): if value == '': Snackbar(text=key.title() + ' is missing.').show() return if not images: Snackbar(text='Image is missing.').show() return Snackbar(text='Attempting to send requested pet...').show() print('All fields satisfied.') self._button_submit.disabled = True self._button_submit.text = 'SENDING' for image in images: tuple = (image, open(image, 'rb')) self.raw_images.append(tuple) #pool = Pool(1) #pool.apply_async(requests.post, args=['https://fur-finder.herokuapp.com/api/pets//'], kwds={'data': dict, 'files': self.raw_images}, callback=self.on_success, error_callback=self.on_error) th = Thread(target=self.post, args=(dict, )) th.setDaemon(True) th.start()
def tryNLTKDownload(self): try: nltk.download() Snackbar(text="nltk.download() window opened...", duration=2).show() except: Snackbar( text= "That didn't work. Do you have the nltk library downloaded?", duration=5).show()
def refresh(self): try: self.textInput.text = textFile Snackbar(text="The textbox has been refreshed.", duration=5).show() except: Snackbar( text= "That didn't work. You probably have not opened a file yet, nor entered anything into the " "textbox. There is nothing to refresh!", duration=5).show()
def qeydiyyatdan_kec(self): self.number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, '+'] self.mail = self.screen.get_screen('qnmp').ids.email.text self.number = self.screen.get_screen('qnmp').ids.number.text self.password_new = self.screen.get_screen('qnmp').ids.password_new.text self.password_new2 = self.screen.get_screen('qnmp').ids.password_new2.text self.username = self.screen.get_screen('qnmp').ids.username.text self.a = True if not self.mail: self.sn = Snackbar(text='Email boş ola bilməz.') self.sn.show() self.a = False elif not self.number: self.sn = Snackbar(text='Nömrə boş ola bilməz.') self.sn.show() self.a = False elif not self.password_new: self.sn = Snackbar(text='Şifrə boş ola bilməz.') self.sn.show() self.a = False elif not self.password_new2: self.sn = Snackbar(text='Şifrəni təkrarlayın.') self.sn.show() self.a = False elif not self.username: self.sn = Snackbar(text='İstifadəçi adı boşdur') self.sn.show() self.a = False elif '@' not in self.mail: self.sn = Snackbar(text='Email düzgün yazılmayıb.') self.sn.show() self.a = False elif '.' not in self.mail: self.sn = Snackbar(text='Email düzgün yazılmayıb.') self.sn.show() self.a = False elif len(self.password_new) < 8: self.sn = Snackbar(text='Şifrə uzunluğu 8 deyil.') self.sn.show() self.a = False elif self.password_new != self.password_new2: self.sn = Snackbar(text='Şifrələr eyni deyil.') self.sn.show() self.a = False else: if self.a == True: self.root.current = 'qa' self.authentication_code = random.randint(111111, 999999) self.mail_content = str(self.authentication_code) self.server = slib.SMTP('64.233.184.108', 587) self.server.ehlo() self.server.starttls() self.server.login("*****@*****.**", "10bk572275") try: self.server.sendmail("*****@*****.**", str(self.mail), self.mail_content) except: pass
def show_example_snackbar(self, snack_type): """Create and show instance Snackbar.""" def callback(instance): from kivymd.toast import toast toast(instance.text) def wait_interval(interval): self._interval += interval if self._interval > self.snackbar.duration: anim = Animation(y=dp(10), d=0.2) anim.start(self.ids.button) Clock.unschedule(wait_interval) self._interval = 0 self.snackbar = None from kivymd.uix.snackbar import Snackbar if snack_type == "simple": Snackbar(text="This is a snackbar!").show() elif snack_type == "button": Snackbar( text="This is a snackbar", button_text="WITH A BUTTON", button_callback=callback, ).show() elif snack_type == "verylong": Snackbar( text="This is a very very very very very very very " "long snackbar!" ).show() elif snack_type == "padding": Snackbar( text="This is a snackbar!", padding="20dp", button_text="ACTION", button_color=(1, 0, 1, 1), ).show() elif snack_type == "float": if not self.snackbar: self.snackbar = Snackbar( text="This is a snackbar!", button_text="BUTTON", duration=3, button_callback=callback, ) self.snackbar.show() anim = Animation(y=dp(72), d=0.2) anim.bind( on_complete=lambda *args: Clock.schedule_interval( wait_interval, 0 ) ) anim.start(self.ids.button)
def postUser(self): data = { 'email': self.email_text.text, 'username': self.username_text.text, 'password': self.password_text.text, 'password2': self.password2_text.text } if self.password2_text.text != self.password_text.text: Snackbar(text="Passwords must match").show() else: res = requests.post( url='https://fur-finder.herokuapp.com/api/register//', data=data) print(res.status_code) print(res.text) if res.status_code == 201: data = { 'username': self.username_text.text, 'password': self.password_text.text } login_res = requests.post( url='https://fur-finder.herokuapp.com/api/login/', data=data) print(login_res.text) pet_list = [] username = self.email_text.text.split('@', 1)[0] regex = re.compile('[^a-zA-Z]') self.m.token = regex.sub('', username) LoginView.usr = self.m.token print(self.m.token) print(LoginView.usr) LoginView.pets_list = pets_list LoginView.author = self.email_text.text self.screens.add_widget(Profile().create( pet_list, LoginView.author)) LoginView.token = login_res.json()['token'] print(LoginView.token) self.sm.current = 'App' else: dictionary = res.json() if 'email' in dictionary: if dictionary['email'][ 0] == 'account with this email already exists.': Snackbar(text='Account with this email already exists.' ).show() else: Snackbar(text='Enter a valid email address.').show() elif 'username' in dictionary: Snackbar(text='Account with this username already exists.' ).show() else: Snackbar(text='Account creation error, try again.').show()
def findLocation(self, location): self.url = "https://isaifirst-434b9-default-rtdb.firebaseio.com/.json" if len(location) == 2: err = Snackbar(text="NO Blank Space Allowed") err.open() else: if len(location) >= 3: err = Snackbar(text="Sucess") JSON = {"userLocation": f"{location}"} re = requests.patch(url=self.url, json=JSON)
def Check_de(self): try: if self.password != "" and self.path != '': self.decrypt() elif self.password == "": Snackbar(text="Enter password to continue !").show() else: pass except: Snackbar(text="Choose file to decrypt !").show()
def bookmark(self, obj): if Containor.current_screen.name not in Star: Star.append(Containor.current_screen.name) star() Snackbar(text=str(Containor.current_screen.name) + ' is starred').show() else: Star.remove(Containor.current_screen.name) star() Snackbar(text=str(Containor.current_screen.name) + ' is unstarred').show()
def generate_qr_code(self, root): if self.ids.link_text.text != "" and self.ids.image_name.text != "": code = qrcode.QRCode(version=1.0, box_size=15, border=4) code.add_data(self.ids.link_text.text) code.make(fit=True) img = code.make_image(fill="Black", back_color="White") img.save(f"{self.ids.image_name.text}.png") Snackbar(text="QR code generated", font_size=40).show() else: Snackbar(text="Enter something in text sections", font_size=40).show()
def verify(self, email, password): if email != "admin": err = Snackbar(text="Enter correct Detail", md_bg_color=[0, 0.3, 0, 1]) err.open() else: if password != "1234": err = Snackbar(text="Enter correct Detail", md_bg_color=[0, 0.3, 0, 1]) err.open() else: err = Snackbar(text="Success") err.open()
def saveFileConfirm(self): userSavePath = (self.fileSaver.path + "\\" + self.textISave.text) print(userSavePath) try: with open(userSavePath, "w", encoding="utf8") as txt: txt.write(textFile) Snackbar(text="Text saved in: " + userSavePath).show() self.fileSaver._update_files() except: Snackbar( text= "That didn't work. Did you select a valid folder? Note: You can't save files in your root directory (protected)", duration=6).show()
def setTextEnd(self): global endTextMarker global endSelection endTextMarker = self.textInput.cursor_row endSelection = self.textInput.selection_text if endSelection != "": Snackbar(text="You selected: '" + endSelection + "'", duration=5).show() print("You selected: " + endSelection) else: Snackbar(text="You didn't select/highlight anything...", duration=5).show() print("You selected: " + endSelection)
def forget_check_authentication_code(self): self.forget_authentication_code_textfield_text = self.screen.get_screen( 'forgetauthenticationcode').ids.forgetauthenticationcode.text if not self.forget_authentication_code_textfield_text: self.sn = Snackbar( text='Kodu daxil edin.' ).show() elif str(self.forget_authentication_code_textfield_text) != self.mail_content000: self.sn = Snackbar( text='Kod düzgün deyil.' ).show() elif str(self.forget_authentication_code_textfield_text) == self.mail_content000: self.root.current = 'sifredeyismeyeri'