def applyIn(self, type, a, b): if a.text == '' and b.text == 0: toast('please fill the form Completely') else: self.p(type) toast('Done') self.render()
def due_diag(self, temp): if self.flag == 1: self.reset_screen() self.ids.container.clear_widgets() self.ids.container.size_hint_y = 1 self.ids.container.add_widget(self.obj) self.flag = 0 if not bool(self.obj.ids.namee_d.text): toast('Enter Name') return elif not bool(self.obj.ids.amt_d.text): toast('Enter Due Amount') return elif not bool(self.obj.ids.datee_d.text): toast('Enter Date') return elif bool(self.obj.ids.phone_d.text): if len(self.obj.ids.phone_d.text) != 10: toast('Phone Number Digits must be 10') return elif not bool(self.obj.ids.reason_d.text): toast('Enter Reason for Due') return self.dialog = MDDialog(title='Do you want to confirm?', text="Add New Entry", size_hint=[.8, .4], events_callback=self.mycallback, text_button_cancel='CANCEL', text_button_ok='CONFIRM') self.dialog.open()
def show_example_download_file(self, interval): from kivymd.uix.progressloader import MDProgressLoader def get_connect(host="8.8.8.8", port=53, timeout=3): import socket try: socket.setdefaulttimeout(timeout) socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect( (host, port)) return True except (TimeoutError, ConnectionError, OSError): return False if get_connect(): link = ("https://www.python.org/ftp/python/3.5.1/" "python-3.5.1-embed-win32.zip") progress = MDProgressLoader( url_on_image=link, path_to_file=os.path.join(self.directory, "python-3.5.1.zip"), download_complete=self.download_complete, download_hide=self.download_progress_hide, ) progress.start(self.data["Download File"]["object"].ids.box_flt) else: toast("Connect error!")
def check(self): if self.sg_nm.text and self.sg_id.text and self.sg_uid.text and self.sg_pas.text: self.manager.current = "myNav" self.wrt() else: toast("Fill Everything...")
def on_enter(self): """ Put parsed damper info into the EditDamperScreen fields. """ damper = Damper() try: self.d_types = damper.get_types() except sqlite3.DatabaseError: toast("GetTypesError") else: # Read DB and output data into dampers_container. if not self.d_types: toast(MDApp.get_running_app().tr._("No Types in the DB")) else: menu_items = [{"text": d_type} for d_type in self.d_types] self.menu = MDDropdownMenu(caller=self.ids["dditm_type"], items=menu_items, position="center", width_mult=4, callback=self.set_item) self.tf_number.text = self.old_number # To show correct current_item in the MDDropDownItem (dditm_type). self.dditm_type.current_item = self.old_d_type self.dditm_type.ids["label_item"].text = self.old_d_type self.lbl_choose_date.text = "[u]{}[/u]".format( self.old_check_date) self.tf_location.text = self.old_location self.chbx_isreleased.active = self.old_is_released self.tf_notes.text = self.old_notes
def on_enter(self): """Read DB and output data into types_container.""" # Creating DeleteEditTypeToolbar dots menus. self.menu_dots = MDDropdownMenu( caller=self.ids["tb_deleteedittype"].ids["ibtn_dots"], items=self.menu_items_dots, callback=self.callback_menu_dots, # position="bottom", hor_growth="left", ver_growth="down", width_mult=7) damper = Damper() try: self.d_types = damper.get_types() except sqlite3.DatabaseError: toast("GetTypesError") else: # Read DB and output data into dampers_container. if not self.d_types: toast(MDApp.get_running_app().tr._("No Types in the DB")) else: for d_type in self.d_types: a_type_list_item = TypeListItem(text=d_type) self.ids["types_container"].add_widget(a_type_list_item) # Add all adding TypeListItem to the list for # getting access to right_checkbox_types in the future. self.all_types_in_container.append(a_type_list_item)
def guardarProduct(self, instance): if self.pathProduct == None: toast('Path Image Required') else: name = App.get_running_app().main_widget.ids.scr_mngr.get_screen( "shop window").ids["adminproduct_screen"].ids["nameProd"].text #actualizar si trae idprod idProdEdit = App.get_running_app( ).main_widget.ids.scr_mngr.get_screen( "shop window").ids["adminproduct_screen"].idProd val = App.get_running_app().main_widget.ids.scr_mngr.get_screen( "shop window").ids["adminproduct_screen"].ids category = App.get_running_app( ).main_widget.ids.scr_mngr.get_screen( "shop window").ids["adminproduct_screen"].ids["catProd"].text description = App.get_running_app( ).main_widget.ids.scr_mngr.get_screen("shop window").ids[ "adminproduct_screen"].ids["descripProd"].text price = App.get_running_app().main_widget.ids.scr_mngr.get_screen( "shop window").ids["adminproduct_screen"].ids["priceProd"].text newproduct = Product(name=name, description=description, img=self.pathProduct, category=category, price=price) self.db.saveProduct(newproduct, idProdEdit) self.clearEdit(self) self.set_list_product() self.SearchProduct('', self.filterByPage, self.contadorPag)
def compraProducto(self, *args): idProd = self.idProdQv idusuario = self.idUsuarioSesion #usuario en sesion #no regitrado solo agregar pero no comprar #validacion segun el color del corazon quitar o no if idusuario != None and idusuario != 0 and idusuario != "": self.db.AgregarCarrito(idusuario, idProd) self.carritoComprasActual() else: # print('agregado virtual') product = self.db.getProductbyId(idProd) App.get_running_app().main_widget.ids.scr_mngr.get_screen( "shop window").ids.cart_screen.ids.rv_cart.data.append({ "viewclass": "CardItemForCart", "height": dp(150), "product_image": product.img, "txtCabecera": product.name, "description": product.description, "idProd": str(product.id), 'price': str(product.price) # "id": val.id }) toast('Added to cart')
def signin(self): # print ( self.data ) if (len(self.ids.username.text) == 0): toast("Username need to be entered") self.logged = False else: if (len(self.ids.password.text) == 0): toast("Password need to be entered") self.logged = False else: for user in self.data['users']: if (user['username'] == self.ids.username.text): if (user['password'] == self.ids.password.text): self.logged = True break else: self.logged = False else: self.logged = False if (self.logged): self.ids.result.text = "Successfuly logged in" self.ids.result.theme_text_color = 'Custom' self.ids.result.text_color = rgba(0, 255, 0, 255) self.sound_success.play() if Hardware_data: self.act5.LoggedIn() else: self.ids.result.text = "Wrog password or username" self.ids.result.theme_text_color = 'Error' self.sound_wrong.play() if Hardware_data: self.act5.WrogLogIn()
def settle_due(self): try: settle_due(name_pass, name_id, str(date.today()), str(self.tot_amt)) toast('entry settled') self.on_pre_enter() except: toast('Data Error')
def on_pre_enter(self, *args): name_val = '%' + name_pass + '%' try: entrys = search_due(name_val, name_id) except: toast('No Entry Found') self.namee_d.text = entrys[0][1] self.phone_d.text = entrys[0][3] self.add_d.text = entrys[0][2] self.reason_d.text = entrys[0][7] self.namee_temp = entrys[0][1] self.phone_temp = entrys[0][3] self.balamt_temp = entrys[0][6] self.sdate_temp = entrys[0][4] self.settle_flag = entrys[0][-1] self.value_lbl.text = 'Value: ' + str(entrys[0][6].split(':')[0]) dur_date = entrys[0][4].split(':')[0] dur_date = datetime.strptime(dur_date, '%Y-%m-%d') dur_date = dur_date.date() dur_date = date.today() - dur_date mnths = int(dur_date.days / 30) dys = int(dur_date.days % 30) self.duration_lbl.text = 'Duration: ' + str(mnths) + 'm ' + str( dys) + 'd' arr_bal = entrys[0][6].split(':') bal_txt = 'Amounts: \n' for i in range(len(arr_bal)): bal_txt = bal_txt + ' ' + arr_bal[i] + '\n' self.amt_lbl.text = bal_txt arr_date = entrys[0][4].split(':') date_txt = 'Date: \n' for i in range(len(arr_date)): date_txt = date_txt + arr_date[i] + '\n' self.date_lbl.text = date_txt if self.settle_flag == '1': self.close_btn_lbl.text = 'Open' self.close_lbl.text = 'Entry Closed on: ' + entrys[0][5] self.tick_lbl.source = "vector61.jpg" else: self.close_btn_lbl.text = 'Close' self.close_lbl.text = ' ' self.tick_lbl.source = "" self.tot_amt = 0 for i in range(len(arr_bal)): self.tot_amt = self.tot_amt + int(arr_bal[i]) self.amount_lbl.text = "Rs: " + str(self.tot_amt)
def update_btn(self): fin_amt = self.balamt_temp + ':' + self.pop_amt_add fin_date = self.sdate_temp + ':' + str(date.today()) try: due_update_add(fin_amt, fin_date, self.namee_temp, name_id) except: toast('Data Error') self.balamt_temp = fin_amt self.sdate_temp = fin_date
def select_path(self, path): """It will be called when you click on the file name or the catalog selection button. :type path: str; :param path: path to the selected directory or file; """ self.exit_manager() toast(path)
def settlebtn(self): try: settle(str(name_pass), name_id, str(date.today()), str(self.final_amt)) toast('Entry Settled') sm.current = 'main' except: toast('Data Error')
def select_path(self, path): '''It will be called when you click on the file name or the catalog selection button. :type path: str; :param path: path to the selected directory or file; ''' self.pathProduct = path.replace('/', '') self.exit_manager() toast(self.pathProduct)
def edit_selected_type(self, *args): """Edit selected type.""" if self.selected_types: # if self.selected_types is not empty. if len(self.selected_types) > 1: toast(MDApp.get_running_app().tr._("Select one for editing")) else: MDApp.get_running_app().root.ids["edit_type_screen"].ids[ "tf_type"].text = self.selected_types[0].text MDApp.get_running_app( ).screen_manager.current = "edit_type_screen"
def make_purchase(self): idUsuario = self.idUsuarioSesion if (idUsuario != 0 and idUsuario != "" and idUsuario != None): self.db.emptyCard(idUsuario) self.carritoComprasActual() toast('Successful purchase') else: toast('Please request access') pass
def _is_money_lock_valid(self) -> bool: money_lock = self.ids.money_lock_amount.text if len(money_lock) == 0: return False if '-' in money_lock: toast("Money lock amount must not be negative.") return False return True
def mycallback(self, text_s, pop): if text_s == 'CONFIRM': try: int(pop.text_field.text) self.pop_amt_add = '-' + pop.text_field.text self.update_btn() self.on_pre_enter() toast('Amount Added Successfully') except: self.minus_diag() toast('ENTER NUMERIC INPUT')
def mycallback_BB(self, text_s, pop): if text_s == 'CONFIRM': try: int(pop.text_field.text) self.pop_amt_add = '-' + pop.text_field.text + '^' self.update_btn() self.on_pre_enter() toast('Amount Added Successfully') except: toast('Wrong Input') self.minus_diagBB()
def clear_db(self, text_of_selection, *args): """Delete ALL date from the DB.""" if text_of_selection == self.tr._("Clear"): damper = Damper() try: damper.clear_db() except sqlite3.DatabaseError: toast("ClearDBError") else: toast(self.tr._("Cleared")) # Delay for showing toast("Cleared") Clock.schedule_once(self.get_dampers, 1)
def dialog_exit(self): def check_interval_press(interval): self.exit_interval += interval if self.exit_interval > 5: self.exit_interval = False Clock.unschedule(check_interval_press) if self.exit_interval: sys.exit(0) Clock.schedule_interval(check_interval_press, 1) toast("Press Back to Exit")
def restore_db(self, selection): """Restore Database.""" # dst_db_path = os.path.dirname(__file__) # doesn't work on Android. dst_db_path = os.getcwd() try: shutil.copyfile(selection[0], "{}{}{}".format(dst_db_path, os.sep, "dampers.db")) except OSError as err: toast(str(err)) # toast("RestoreBackupError") else: toast(self.tr._("Backup file restored")) # Get and show dampers after restoring. self.get_dampers()
def chip_c(self, instance, value): try: if scrn == 'Non_Due': amt = 'amt_' + str(value) amt_list = list(self.ids[amt].text) if amt_list[-1] == '^': self.ids[amt].text = ''.join( str(elem) for elem in amt_list[:-1]) else: self.ids[amt].text = self.ids[amt].text + '^' elif scrn == 'Due': toast('Interest Cannot be added for Due') except: toast('Edit existing amounts only')
def Check_Login(self): self.Red() if self.data: if self.lg_i.text == self.data[2].strip( ) and self.lg_pas.text == self.data[3].strip(): self.manager.current = "myNav" else: toast("Password or User ID is wrong") if self.lg_cb.active: f2 = open("pas.text", "a+") f2.write('1') f2.close() else: pass
def due_entry(self): namee = self.obj.ids.namee_d.text phone = self.obj.ids.phone_d.text address = self.obj.ids.add_d.text sdate = self.obj.ids.datee_d.text amt = self.obj.ids.amt_d.text reason = self.obj.ids.reason_d.text try: insert_due(namee, address, phone, sdate, amt, reason) sm.current = 'main' toast(' Successfully Entry Added ') except: toast('Cannot add')
def switch_lang(self, lang): # get the right locales directory, and instanciate a gettext try: locale_dir = os.path.join(os.path.dirname(__file__), 'data', 'locales') locales = gettext.translation('dampersapp', locale_dir, languages=[lang]) self.ugettext = locales.gettext # update all the kv rules attached to this text for func, largs, kwargs in self.observers: func(largs, None, None) except: toast(MDApp.get_running_app().tr._("Can't translate the App"))
def msg_send(self): if self.re_box.text: f = open("pas.text") self.data = f.readlines() toast("Requested..") self.h = self.title_name() f = open("History.text", "a+") f.write("\n\n" + str(self.h) + "\n" + str(self.re_box.text)) f.close() self.re_box.text = " " f = open("State.text", "w") f.write("1") f.close() else: toast("Write Your Explaination Please")
def handle_failure(self, message, exception=None): toast('SX camera problem: {:}'.format(message)) if exception is not None: logger.exception('Camera: handle_failure {:} ({:})'.format( message, exception)) self.connected = False # to ensure reconnect if that was the issue self.last_capture = None self.stop_capture() try: self.clean_up() except Exception as e: logger.exception('Camera: problem disposing {:}'.format(e)) finally: if self.params['on_failure'] is not None: self.params['on_failure']()
def callback(instance, value): if value is None: toast('Delete post %s' % str(instance)) elif isinstance(value, int): toast('Set like in %d stars' % value) elif isinstance(value, str): toast('Repost with %s ' % value) elif isinstance(value, list): toast(value[1])