def choose_theme(self): # [bug fixed]: disable `set theme` button while animation is still in progress if self.mouse_disabled: return # [bug fixed]: disable all main UI events until the dialog is closed self.mouse_disabled = True if not self.popup1: button_style = dict(font_name='Lato', font_size="16sp", text_color=(0, 153 / 255, 1, 1)) button1 = MDFlatButton(text="RESTART", **button_style) button2 = MDFlatButton(text="CANCEL", **button_style) button1.bind(on_release=self.change_theme) button2.bind(on_release=self.close_dialog) self.popup1 = MDDialog( title="Themes", type="confirmation", items=[ThemeItem(text="guns"), ThemeItem(text="knives")], size_hint=(0.3, None), auto_dismiss=False, buttons=[button1, button2]) self.popup1.open()
def __init__(self, **kwargs): super().__init__(**kwargs) if self.button_text != "": button = MDFlatButton(text=self.button_text) self.ids.box.add_widget(button) if self.button_callback: button.bind(on_release=self.button_callback)
def settingButton(self, configObj, section, key, default=''): "Return a button representing a setting in a configparser obj which you can press to edit." try: if hasattr(configObj, 'add_section'): configObj.add_section(section) else: configObj[section] = configObj.get(section, {}) except: pass configObj[section][key] = configObj[section].get(key, default) or default x = MDFlatButton(text=key + ":" + configObj[section].get(key, "")[:25]) def f(*a): def g(r): if not r is None: configObj[section][key] = r x.text = key + ":" + configObj[section].get(key, "")[:25] self.askQuestion(section + ":" + key, configObj[section].get(key, ""), g) x.bind(on_press=f) return x
def show_fail_dialog(self): btn = MDFlatButton(text="Try Again") btn.bind(on_release=self.close_fail_dialog) self.dialog2 = MDDialog( text="Incorrect username or password!", size_hint=[.7, .7], buttons=[btn], ) self.dialog2.open()
def __init__(self, **kwargs): super(OneUIHeaders, self).__init__(**kwargs) self.rows = 2 self.spacing = 5 self.__headers.orientation = "vertical" self.md_bg_color = [0.3, 0.3, 0.1, 1] __add_new = MDFlatButton() __add_new.text = "Add New" __add_new.bind(on_release=lambda x: self.add()) super().add_widget(self.__headers) super().add_widget(__add_new)
def select_dialog(self, *args): button1 = MDFlatButton(text="Cancel") button2 = MDFlatButton(text="Save") button1.bind(on_press=self.forget) button2.bind(on_press=self.save_changes) self.dialog = MDDialog(title="Choose your time:", type="custom", size_hint=[.5, .5], content_cls=my_layout(), buttons=[button1, button2]) ###fix later self.dialog.open()
def delete(self, _, mock: data.Mock): confirm_button = MDFlatButton(text="Accept", text_color=OneUIColors.SaveButton.value) confirm_button.bind(on_release=lambda x: self.remove(mock)) cancel_button = MDFlatButton(text="Cancel", text_color=OneUIColors.AccentColor.value) cancel_button.bind(on_release=lambda x: self.dialog.dismiss()) self.dialog = MDDialog( title=f"Remove mock server ( {mock.name} : {mock.port} )?", text="This will remove all endpoint and associated data", buttons=[confirm_button, cancel_button], ) self.dialog.open()
def show_dialog(self): bt1 = MDFlatButton(text="CANCEL") bt2 = MDRaisedButton(text="OK") bt1.bind(on_release=self.close) bt2.bind(on_release=self.test) self.dialog = MDDialog( text="Are you sure?", size_hint=[.7, .7], buttons=[ bt1, bt2, ], ) self.dialog.open()
def build(self): initialize_google( self.after_login, self.error_listener, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, ) initialize_fb( self.after_login, self.error_listener, FACEBOOK_CLIENT_ID, FACEBOOK_CLIENT_SECRET, ) initialize_github( self.after_login, self.error_listener, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, ) if platform == "android": NewRelic.withApplicationToken( "eu01xx3a293465cda73cd2f5b1154ed969b9af4b27-NRMA" ).start(context.getApplication()) # set_statusbar_color() tmp = Builder.load_string(kv) if platform != "android": from kivymd.uix.dialog import MDDialog from kivymd.uix.button import MDFlatButton btn = MDFlatButton(text="CANCEL", text_color=self.theme_cls.primary_color) btn.bind(on_release=lambda *args: (stop_login(), self.dialog.dismiss())) self.dialog = MDDialog( title="", size_hint_x=None, size_hint_y=None, width="250dp", type="custom", auto_dismiss=False, content_cls=Content(), buttons=[btn], ) return tmp
def congratulate(self): if self.time_elapsed < self.best_record: self.best_record = self.time_elapsed text = f'Total time used: {self.format_time()}, ' \ f'total clicks: {self.flips}, ' \ f'best record: {self.best_record}.' button_style = dict(font_name='Lato', font_size="16sp", text_color=(0, 153 / 255, 1, 1)) button = MDFlatButton(text="OK", **button_style) button.bind(on_release=self.close_dialog) # create a new dialog with new statistics each time self.popup2 = MDDialog(title="Congratulations, You Won!", text=text, radius=[20, 20, 20, 20], size_hint=(0.7, None), auto_dismiss=False, buttons=[button]) self.popup2.open()
def action(self, button): item = [] if type(button.parent.parent.parent).__name__ == 'History': for data in self.left_check_list: if data.state == 'down': item.append(data.parent.parent) else: item.append(button.parent.parent.parent) item_data = str(item[0].text + ' ' + item[0].secondary_text) if button.icon == 'content-copy': Clipboard.copy(item_data) elif button.icon == 'history': self.main.pages.pages_list[ current_page[0]].entry.text = item_data.split()[0] self.parent.dismiss() elif button.icon == 'qrcode': image = Image(source="") imgIO = io.BytesIO() qrcode.make(item_data).save(imgIO, ext='png') imgIO.seek(0) imgData = io.BytesIO(imgIO.read()) image.texture = CoreImage(imgData, ext='png').texture image.reload() dialog = ModalView(size_hint=(None, None), size=image.texture.size) dialog.add_widget(image) dialog.open() elif button.icon in ['delete', 'delete-sweep']: dialog_yes = MDFlatButton(text="yes") dialog_no = MDRaisedButton(text="no") dialog = MDDialog(text="Delete {} item{}?".format( len(item), '' if len(item) == 1 else 's'), buttons=[dialog_no, dialog_yes]) with open('history.json', 'r') as file: data = json.load(file) for item_ in item: data.pop(item_.time) dialog_no.bind(on_release=dialog.dismiss) dialog_yes.bind(on_release=dialog.dismiss) dialog_yes.bind(on_release=lambda button: json.dump( data, open('history.json', 'w'), indent=4)) dialog_yes.bind(on_release=self.item_check) dialog.bind(on_dismiss=self.refresh) dialog.open()
class Library(Screen): def __init__(self, **kwargs): super(Library, self).__init__(**kwargs) self.deckname = None self.skeleton_frame() def skeleton_frame(self): #Displays all decks on the app self.box = MDBoxLayout(orientation="vertical") self.scrollview = ScrollView() self.list = MDList() self.scrollview.add_widget(self.list) #calls the activate_for_loop method self.display_deck() # Buttons on the bottom of the screen # Buttons are places on bottom of screen self.box.add_widget( MDLabel(size_hint=(0.2, 0.15))) # Push down the list of buttons self.box.add_widget(self.scrollview) self.bottom_bar = MDToolbar() self.delete_deck_button = MDIconButton(icon="trash-can-outline", pos_hint={ 'center_x': .5, 'center_y': .5 }) self.delete_deck_button.bind(on_press=self.delete_deck) self.build_deck_button = MDIconButton(icon="plus-thick", pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.build_deck_button.bind(on_press=self.build_new_deck) #add method to make a new deck self.bottom_bar.add_widget(self.delete_deck_button) self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(self.build_deck_button) self.bottom_bar.add_widget(MDLabel()) self.box.add_widget(self.bottom_bar) self.add_widget(self.box) def skeleton_frame2(self, instance): # method must be used to make the on_press method work self.scrollview.remove_widget(self.list) self.box.remove_widget(self.bottom_bar) self.list = MDList() self.scrollview.add_widget(self.list) #Displays all decks on the app self.box = MDBoxLayout(orientation="vertical") self.scrollview = ScrollView() self.list = MDList() self.scrollview.add_widget(self.list) #calls the activate_for_loop method self.display_deck() # Buttons on the bottom of the screen # Buttons are places on bottom of screen self.box.add_widget( MDLabel(size_hint=(0.2, 0.15))) # Push down the list of buttons self.box.add_widget(self.scrollview) self.bottom_bar = MDToolbar() self.delete_deck_button = MDIconButton(icon="trash-can-outline", pos_hint={ 'center_x': .5, 'center_y': .5 }) self.delete_deck_button.bind(on_press=self.delete_deck) self.build_deck_button = MDIconButton(icon="plus-thick", pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.build_deck_button.bind(on_press=self.build_new_deck) #add method to make a new deck self.bottom_bar.add_widget(self.delete_deck_button) self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(self.build_deck_button) self.bottom_bar.add_widget(MDLabel()) self.box.add_widget(self.bottom_bar) self.add_widget(self.box) # Creates a section that will list out the decks def display_deck(self): conn = sqlite3.connect("flashcard_app.db") cur = conn.cursor() cur.execute(""" SELECT DeckName FROM Decks """) names = cur.fetchall() for name in names: # the nested for loop will remove (),' from the string name = str(name) for char in name: if char == "(" or char == ")" or char == "," or char == "'": name = name.replace(char, "") self.items = OneLineListItem(text=name) self.items.bind(on_press=self.display_cards) self.list.add_widget(self.items) conn.commit() conn.close() # working code to switch screens with python code def display_cards(self, instance): self.scrollview.remove_widget(self.list) self.box.remove_widget(self.bottom_bar) self.list = MDList() self.scrollview.add_widget(self.list) self.deckname = instance.text print(self.deckname) conn = sqlite3.connect("flashcard_app.db") cur = conn.cursor() cur.execute( """ SELECT CardName FROM Cards WHERE DeckName = ? """, (instance.text, )) names = cur.fetchall() for name in names: # the nested for loop will remove (),' from the string name = str(name) for char in name: if char == "(" or char == ")" or char == "," or char == "'": name = name.replace(char, "") self.items = OneLineListItem(text=name) self.items.bind(on_press=self.display_name_def) self.list.add_widget(self.items) conn.commit() conn.close() self.get_bottom_bar() def display_cards2(self): self.scrollview.remove_widget(self.list) self.box.remove_widget(self.bottom_bar) self.list = MDList() self.scrollview.add_widget(self.list) conn = sqlite3.connect("flashcard_app.db") cur = conn.cursor() cur.execute( """ SELECT CardName FROM Cards WHERE DeckName = ? """, (self.deckname, )) names = cur.fetchall() for name in names: # the nested for loop will remove (),' from the string name = str(name) for char in name: if char == "(" or char == ")" or char == "," or char == "'": name = name.replace(char, "") self.items = OneLineListItem(text=name) self.items.bind(on_press=self.display_name_def) self.list.add_widget(self.items) conn.commit() conn.close() self.get_bottom_bar() #displays the bottom nav bar when display_cards is called def get_bottom_bar(self): self.bottom_bar = MDToolbar() self.add_card_button = MDIconButton(icon="plus-thick", pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.trash_button = MDIconButton(icon="trash-can-outline", pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.back_button = MDIconButton(icon="arrow-left-bold", pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.trash_button.bind(on_press=self.delete_card) self.back_button.bind(on_press=self.skeleton_frame2) self.add_card_button.bind(on_press=self.add_cards) #self.build_deck_button.bind(on_press=self.to_build_card) # jargon of code to space out the buttons on bottom nav bar self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(self.back_button) self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(self.add_card_button) self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(self.trash_button) self.bottom_bar.add_widget(MDLabel()) self.bottom_bar.add_widget(MDLabel()) self.box.add_widget(self.bottom_bar) def add_cards(self, instance): close_button = MDFlatButton(text="Close", on_release=self.close_dialog) enter_button = MDFlatButton(text="Enter", on_release=self.add_cardname_to_db) self.grid = MDGridLayout(rows=4, size_hint_y=None, height=int(Window.height) / 8.9) self.front_input = MDTextField(size_hint=(.9, 1)) self.back_input = MDTextField(size_hint=(.9, 1)) self.dialog = MDDialog(title="Card Creation", pos_hint={ 'center_x': .5, 'center_y': .5 }, type="custom", content_cls=Content(), size_hint=(.9, 1), buttons=[close_button, enter_button]) self.grid.add_widget(MDLabel(text=" Front")) self.grid.add_widget(self.front_input) self.grid.add_widget(MDLabel(text=" Back")) self.grid.add_widget(self.back_input) self.dialog.add_widget(self.grid) self.dialog.open() def add_cardname_to_db(self, instance): front_input = self.front_input.text back_input = self.back_input.text print(self.deckname) print(front_input) print(back_input) con = sqlite3.connect("flashcard_app.db") cur = con.cursor() cur.execute( """ INSERT INTO Cards (CardName, Definition, DeckName) VALUES(?, ?, ?) """, (front_input, back_input, self.deckname)) names = cur.fetchall() for name in names: # the nested for loop will remove (),' from the string name = str(name) for char in name: if char == "(" or char == ")" or char == "," or char == "'": name = name.replace(char, "") self.items = OneLineListItem(text=name) #self.items.bind(on_press=self.display_name_def) self.list.add_widget(self.items) con.commit() con.close() self.display_cards2() # displays the front and back of a single card def display_name_def(self, instance): self.predicate = True self.scrollview.remove_widget(self.list) self.box.remove_widget(self.bottom_bar) print(instance.text) con = sqlite3.connect("flashcard_app.db") cur = con.cursor() cur.execute( """ SELECT CardName, Definition FROM Cards WHERE CardName = ? """, (instance.text, )) row = cur.fetchall() for cardname, definition in row: self.front = cardname self.back = definition print(self.front, self.back) con.commit() con.close() # will display the front-side of selected card self.click_action() # the screen will act as a button to display the front or back after clicking the screen def click_action(self): if self.predicate == True: self.button = Button(text=self.front, color=(1, 0, 1, 1), background_color=(0, 0, 0, 0), font_size='20sp', on_release=self.click_action2) self.predicate = False else: self.button = Button(text=self.back, color=(1, 0, 1, 1), background_color=(0, 0, 0, 0), font_size='20sp', on_release=self.click_action2) self.predicate = True self.scrollview.add_widget(self.button) self.bottom_bar_name_def() def click_action2(self, instance): self.box.remove_widget(self.scrollview) self.remove_widget(self.bottom_bar) self.scrollview = ScrollView() if self.predicate == True: self.button = Button(text=self.front, color=(1, 0, 1, 1), background_color=(0, 0, 0, 0), font_size='20sp', on_release=self.click_action2) self.predicate = False else: self.button = Button(text=self.back, color=(1, 0, 1, 1), background_color=(0, 0, 0, 0), font_size='20sp', on_release=self.click_action2) self.predicate = True self.scrollview.add_widget(self.button) self.box.add_widget(self.scrollview) self.bottom_bar_name_def() # displays bottom bar that will return user to displaying the list of decks def bottom_bar_name_def(self): self.bottom_bar = MDToolbar() #self.box = MDBoxLayout(orientation="horizontal") self.back_button = MDFlatButton(text="Return to Decks", pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) self.back_button.bind(on_press=self.back_display_cards) #self.box.add_widget(self.back_button) #self.box.add_widget(MDLabel()) self.bottom_bar.add_widget(self.back_button) self.add_widget(self.bottom_bar) def back_display_cards(self, instance): self.box.remove_widget(self.scrollview) self.remove_widget(self.bottom_bar) self.skeleton_frame() # method to build a new deck using a dialog box def build_new_deck(self, instance): close_button = MDFlatButton(text="Close", on_release=self.close_dialog) # *** This button will put name into db, then refresh the page enter_button = MDFlatButton(text="Enter", on_release=self.add_name_to_db) self.input = MDTextField(pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }, size_hint=(.9, 1)) self.dialog = MDDialog(title="Enter Deck Name", size_hint=(0.7, 1), buttons=[close_button, enter_button]) self.dialog.add_widget(self.input) self.dialog.open() # method to close the dialog box def close_dialog(self, instance): self.dialog.dismiss() #method that inserts the deck name into db def add_name_to_db(self, instance): input = self.input.text # this will have an if else statement if an error was typed in #self.error = MDDialog() #self.error.open() conn = sqlite3.connect("flashcard_app.db") cur = conn.cursor() cur.execute( """ INSERT INTO Decks (deckname) VALUES(?)""", (input, )) conn.commit() conn.close() self.remove_widget(self.box) self.skeleton_frame() print("boo") def delete_deck(self, instance): close_button = MDFlatButton(text="Close", on_release=self.close_dialog) delete_dialog_button = MDFlatButton(text="Delete", on_release=self.delete_deck_input) self.dialog = MDDialog(title="Delete Deck", size_hint=(0.7, 1), buttons=[close_button, delete_dialog_button]) self.input = MDTextField() self.dialog.add_widget(self.input) self.dialog.open() def delete_deck_input(self, instance): input = self.input.text con = sqlite3.connect("flashcard_app.db") cur = con.cursor() cur.execute( """ DELETE FROM Decks WHERE DeckName = ?; """, (input, )) cur.execute( """ DELETE FROM Cards WHERE DeckName = ?; """, (input, )) con.commit() con.close() self.remove_widget(self.box) self.skeleton_frame() def delete_card(self, instance): close_button = MDFlatButton(text="Close", on_release=self.close_dialog) delete_dialog_button = MDFlatButton(text="Delete", on_release=self.delete_card_input) self.dialog = MDDialog(title="Delete Card", size_hint=(0.7, 1), buttons=[close_button, delete_dialog_button]) self.input = MDTextField() self.dialog.add_widget(self.input) self.dialog.open() def delete_card_input(self, instance): input = self.input.text con = sqlite3.connect("flashcard_app.db") cur = con.cursor() cur.execute( """ DELETE FROM Cards WHERE CardName = ? """, (input, )) con.commit() con.close() self.display_cards2()
def show_alert_dialog(self, title, text): btn = MDFlatButton(text="ok", text_color=app.theme_cls.primary_color,) btn.bind(on_press=lambda x: self.remove_widget(dialog)) dialog = MDDialog(size_hint=(.8, None), title=title, text=text, buttons=[btn]) dialog.open()
class CamApp(App): def build(self): model_dir = Path("RFB-320") Logger.info(f"Model: Model directory path: {model_dir.__str__()}") self.model = cv2.dnn.readNetFromCaffe( Path(model_dir, "RFB-320.prototxt").__str__(), Path(model_dir, "RFB-320.caffemodel").__str__()) Logger.info(f"Model: Model has loaded successfully ({self.model})") overlap_path = Path("Thug-Life-Glasses-PNG.png") self.overlap_image = cv2.imread(overlap_path.__str__(), cv2.IMREAD_UNCHANGED) self.overlap_image = cv2.resize(self.overlap_image, (320, 240)) self.thug_life = False self.image_mean = np.array([127, 127, 127]) self.image_std = 128.0 self.iou_threshold = 0.3 self.center_variance = 0.1 self.size_variance = 0.2 self.min_boxes = [[10.0, 16.0, 24.0], [32.0, 48.0], [64.0, 96.0], [128.0, 192.0, 256.0]] self.strides = [8.0, 16.0, 32.0, 64.0] self.threshold = 0.7 self.size_ratio = None self.input_size = (320, 240) self.width = self.input_size[0] self.height = self.input_size[1] self.priors = define_img_size(self.input_size) self.check_window_size() self.img1 = Image(pos_hint={'center_x': 0.5, 'center_y': 0.5}) self.speed_button = Button(text="Change display size", size_hint=(0.2, 0.4), pos_hint={ 'center_x': 0.25, 'center_y': 0.125 }) self.thug_button = Button(text="switch thug life", size_hint=(0.2, 0.4), pos_hint={ 'center_x': 0.75, 'center_y': 0.125 }) self.thug_button.bind(on_press=self.switch_thug_life) self.speed_button.bind(on_press=self.set_display_speed) layout = FloatLayout(size=Window.size) layout.add_widget(self.img1) layout.add_widget(self.speed_button) layout.add_widget(self.thug_button) self.display_speed = 2 # 0 for best resolution, 1 for medium, 2 for fastest display desired_resolution = (720, 480) self.camCV = CameraCV(play=True, resolution=desired_resolution) self.camCV.image_bytes = False Clock.schedule_interval(self.update_texture, 1.0 / 60.0) return layout def set_display_speed(self, instance): if self.display_speed == 2: self.display_speed = 0 else: self.display_speed += 1 def check_window_size(self): self.window_shape = Window.size self.window_width = self.window_shape[0] self.window_height = self.window_shape[1] Logger.info(f"Screen: Window size is {self.window_shape}") def switch_thug_life(self, instance): self.thug_life = not self.thug_life def update_texture(self, instance): self.check_window_size() if type(self.camCV.image_bytes) == bool: Logger.info("Camera: No valid frame") return Logger.info(f"Camera: image bytes {len(self.camCV.image_bytes)}") Logger.info(f"Camera: image size {self.camCV.image_size}") if not self.size_ratio: self.camera_width = self.camCV.image_size[0] self.camera_height = self.camCV.image_size[1] self.size_ratio = self.camera_height / self.camera_width Logger.info(f"Camera: update texture") self.extract_frame() self.process_frame() self.display_frame() Logger.info(f"Camera: converted to gray and back to rgba") def extract_frame(self): self.frame = np.frombuffer(self.camCV.image_bytes, np.uint8) Logger.info(f"Camera: frame exist") self.frame = self.frame.reshape( (self.camCV.image_size[1], self.camCV.image_size[0], 4)) Logger.info(f"Camera: frame size {self.frame.shape}") def process_frame(self): boxes = find_faces(self, platform) self.frame = draw_on_faces(self, boxes, platform) def display_frame(self): self.img1.texture = make_new_texture_frame(self)
class EditScreen(Screen): def on_enter(self, *args): global CLASS global StaffName self.flag = 1 self.ids.staff_name.text = StaffName sql = "SELECT roll_no FROM student_class WHERE cs_code=%s" val = (CLASS, ) tmp_cursor.execute(sql, val) result = tmp_cursor.fetchall() self.buttons_dict = {} for item in result: bl = BoxLayout(orientation='horizontal', size_hint=(1, None), height=Window.height * 0.1) label = MDLabel(text=item[0], halign='center') button = MDIconButton(icon='minus', pos_hint={'center_x': 0.1}) button.bind(on_press=self.delete) self.buttons_dict[button] = item[0] bl.add_widget(label) bl.add_widget(button) self.ids.student_list.add_widget(bl) def delete(self, instance): global CLASS roll = self.buttons_dict[instance] sql = "DELETE FROM student_class WHERE cs_code=%s and roll_no=%s" val = ( CLASS, roll, ) tmp_cursor.execute(sql, val) db.commit() sql = "DELETE FROM attendance where cs_code=%s and roll_no=%s" val = ( CLASS, roll, ) tmp_cursor.execute(sql, val) db.commit() self.on_leave() self.on_enter() self.manager.current = 'editscreen' def add_student(self): if self.flag == 1: self.flag = 0 else: return self.textbox = MDTextField(pos_hint={'center_y': 0.055}) self.button = MDFlatButton(text='ADD', pos_hint={'center_y': 0.055}) self.button.bind(on_press=self.add) self.ids.bottom_box.add_widget(self.textbox) self.ids.bottom_box.add_widget(self.button) def add(self, instance): if len(self.textbox.text) == 0: return global CLASS roll = self.textbox.text sql = "INSERT INTO student_class VALUES(%s,%s)" val = ( CLASS, roll, ) tmp_cursor.execute(sql, val) db.commit() self.ids.bottom_box.remove_widget(self.textbox) self.ids.bottom_box.remove_widget(self.button) self.on_leave() self.on_enter() self.manager.current = 'editscreen' def on_leave(self, *args): self.ids.student_list.clear_widgets() self.ids.bottom_box.remove_widget(self.textbox) self.ids.bottom_box.remove_widget(self.button)