def __init__(self, **kwargs): self._previously_parsed_text = '' super(Catalog, self).__init__(**kwargs) self.show_kv(None, 'New UI') self.carousel = None try: self.db = Database() all_kvs = self.db.get_kvs() print(len(all_kvs)) for kv in all_kvs: kv = pickle.loads(kv[0]) name = kv.rsplit(os.path.sep, 1)[1].rsplit('.', 1)[0] self.ids.recents.values.append(name) except: print('Failed to initialize the DB')
class Catalog(BoxLayout): '''Catalog of widgets. This is the root widget of the app. It contains a tabbed pain of widgets that can be displayed and a textbox where .kv language files for widgets being demoed can be edited. The entire interface for the Catalog is defined in main.kv, although individual containers are defined in the container_kvs directory. To add a container to the catalog, first create the .kv file in container_kvs The name of the file (sans .kv) will be the name of the widget available inside the kivycatalog.kv Finally modify kivycatalog.kv to add an AccordionItem to hold the new widget. Follow the examples in kivycatalog.kv to ensure the item has an appropriate id and the class has been referenced. You do not need to edit any python code, just .kv language files! ''' language_box = ObjectProperty() screen_manager = ObjectProperty() _change_kv_ev = None def __init__(self, **kwargs): self._previously_parsed_text = '' super(Catalog, self).__init__(**kwargs) self.show_kv(None, 'New UI') self.carousel = None try: self.db = Database() all_kvs = self.db.get_kvs() print(len(all_kvs)) for kv in all_kvs: kv = pickle.loads(kv[0]) name = kv.rsplit(os.path.sep, 1)[1].rsplit('.', 1)[0] self.ids.recents.values.append(name) except: print('Failed to initialize the DB') def replace_kv(self, *args): inst, val = args target = None if val == 'New UI': target = os.path.join(CONTAINER_KVS, 'PlaygroundContainer.kv') else: all_kvs = self.db.get_kvs() for kv in all_kvs: path = pickle.loads(kv[0]) name = path.rsplit(os.path.sep, 1)[1].rsplit('.', 1)[0] if name == val: # TODO - Allow duplicate names target = path break if target: try: with open(target, 'rb') as file: self.language_box.text = file.read().decode('utf8') if self._change_kv_ev is not None: self._change_kv_ev.cancel() if val == 'New UI': self.ids.ui_name.text = 'Untitled*' else: self.ids.ui_name.text = target self.change_kv() # reset undo/redo history self.language_box.reset_undo() except Exception as e: self.show_error(e) def update_name_open_file(self, name: str, modal): """Update the name of the current file Parameters ---------- name : str the name of the file to save modal: :class kivy.uix.modalview.ModalView An instance of the kivy modalview containing the name data Returns ------- None """ modal.dismiss() if not name.endswith('.kv'): name = '.'.join([name, 'kv']) ui_name = self.ids.ui_name ui_name.text = name new_sp_val = name.rsplit(os.path.sep, 1)[1].rsplit('.', 1)[0] self.ids.recents.values.append(new_sp_val) self.ids.recents.text = new_sp_val try: if ui_name == 'New UI': self.ids.ui_name.text = 'Untitled*' else: self.ids.ui_name.text = str(name) save_path = name # Saving the aabsolute filepath to a pickle object dump = pickle.dumps(save_path) print(f"Full path of store is {save_path}") all = self.db.get_kvs() kvs = [x[0] for x in all] if dump not in kvs: if self.db.add_kv(dump): print("Successfully added kivy file path to db") else: print("Failed to save kivy file to db") with open(name, 'rb') as file: self.language_box.text = file.read().decode('utf8') if self._change_kv_ev is not None: self._change_kv_ev.cancel() # self.change_kv() # reset undo/redo history self.language_box.reset_undo() except Exception as e: self.show_error(e) # self.change_kv() def change_kv_open_file(self, *largs): txt = self.language_box.text kv_container = self.screen_manager.current_screen.children[0] try: parser = Parser(content=txt) kv_container.clear_widgets() widget = Factory.get(parser.root.name)() Builder._apply_rule(widget, parser.root, parser.root) kv_container.add_widget(widget) name = self.ids.ui_name.text save_path = name dump = pickle.dumps(save_path) all = self.db.get_kvs() kvs = [x[0] for x in all] if dump not in kvs: self.db.add_kv(dump) with open(save_path, 'w') as f: f.write(txt) except: pass # print(absfilepathname) def load_kv(self): m = ModalView(size_hint=[.6, .7]) box = BoxLayout(orientation='vertical') m.add_widget(box) name_box = BoxLayout(size_hint_y=.1) fc = OpenFChooser() box.add_widget(name_box) box.add_widget(fc) submit = Button(text='open', background_color=[1, 1, 1, 1], background_normal='', color=[0, 0, 0, 1], size_hint_x=.2) submit.bind(on_press=lambda x: self.update_name_open_file( fc.get_selected_file(), m)) # submit.bind(on_press= lambda x: self.show_kv(None,'New UI')) name_box.add_widget(submit) # print(fc.get_selected_file()) m.open() def show_kv(self, instance, value): '''Called when an a item is selected, we need to show the .kv language file associated with the newly revealed container.''' self.screen_manager.current = value child = self.screen_manager.current_screen.children[0] with open(child.kv_file, 'rb') as file: self.language_box.text = file.read().decode('utf8') if self._change_kv_ev is not None: self._change_kv_ev.cancel() self.change_kv() # reset undo/redo history self.language_box.reset_undo() def schedule_reload(self): if self.auto_reload: txt = self.language_box.text child = self.screen_manager.current_screen.children[0] if txt == child.previous_text: return child.previous_text = txt if self._change_kv_ev is not None: self._change_kv_ev.cancel() if self._change_kv_ev is None: self._change_kv_ev = Clock.create_trigger(self.change_kv, .5) self._change_kv_ev() def change_kv(self, *largs): '''Called when the update button is clicked. Needs to update the interface for the currently active kv widget, if there is one based on the kv file the user entered. If there is an error in their kv syntax, show a nice popup.''' txt = self.language_box.text kv_container = self.screen_manager.current_screen.children[0] try: parser = Parser(content=txt) kv_container.clear_widgets() widget = Factory.get(parser.root.name)() Builder._apply_rule(widget, parser.root, parser.root) kv_container.add_widget(widget) name = self.ids.ui_name.text print(f'The whatever name is {name}') if name == 'Untitled*': m = ModalView(size_hint=[.6, .7]) box = BoxLayout(orientation='vertical') m.add_widget(box) # Function to get user's current home directory from os.path import expanduser users_home = expanduser('~') user_home_dir = os.path.join(users_home, 'Desktop') try: os.mkdir(os.path.join(user_home_dir, 'KivyEditor')) user_home_dir = os.path.join(user_home_dir, 'KivyEditor') except FileExistsError: # user_home_dir = os.path.join(user_home_dir, 'KivyEditor') pass name_box = BoxLayout(size_hint_y=.1) fc = FileChooserListView(size_hint_y=.9, filters=['*kv'], rootpath=user_home_dir) box.add_widget(name_box) box.add_widget(fc) tinput = TextInput(multiline=False, size_hint_x=.8) submit = Button(text='Save', background_color=[1, 1, 1, 1], background_normal='', color=[0, 0, 0, 1], size_hint_x=.2) tinput.bind(on_text_validate=lambda x: self.update_name( os.path.join(fc.path, tinput.text), m)) submit.bind(on_release=lambda x: self.update_name( os.path.join(fc.path, tinput.text), m)) name_box.add_widget(tinput) name_box.add_widget(submit) m.open() else: save_path = name dump = pickle.dumps(save_path) all = self.db.get_kvs() kvs = [x[0] for x in all] if dump not in kvs: self.db.add_kv(dump) with open(save_path, 'w') as f: f.write(txt) except (SyntaxError, ParserException) as e: self.show_error(e) except Exception as e: self.show_error(e) def update_name(self, name: str, modal): """Update the name of the current file Parameters ---------- name : str the name of the file to save modal: :class kivy.uix.modalview.ModalView An instance of the kivy modalview containing the name data Returns ------- None """ modal.dismiss() if not name.endswith('.kv'): name = '.'.join([name, 'kv']) ui_name = self.ids.ui_name ui_name.text = name new_sp_val = name.rsplit(os.path.sep, 1)[1].rsplit('.', 1)[0] self.ids.recents.values.append(new_sp_val) self.ids.recents.text = new_sp_val self.change_kv() def show_error(self, e): self.info_label.text = str(e).encode('utf-8') self.anim = Animation(top=190.0, opacity=1, d=2, t='in_back') + \ Animation(top=190.0, d=3) + \ Animation(top=0, opacity=0, d=2) self.anim.start(self.info_label)
def __init__(self, **kw): super().__init__(**kw) self.db = Database() self.init_view()
class MainWindow(BoxLayout): def __init__(self, **kw): super().__init__(**kw) self.db = Database() self.init_view() def init_view(self): all_tasks = self.db.get_tasks() scroll_parent = Window tw = self.ids.today_wrapper uw = self.ids.upcoming for t in all_tasks: date, time = t[2].rsplit(' ', 1) if self.clean_date(date): task = Today() task.og_name = t[1] task.name = t[1].upper() task.time = time task.date = date task.size_hint = (None, 1) task.size = [scroll_parent.width / 2.4, 45] itask = Today() itask.og_name = t[1] itask.name = t[1].upper() itask.time = time itask.date = date itask.size_hint = (None, None) itask.size = [ scroll_parent.width / 2.4, round(scroll_parent.height / 4) ] tw.add_widget(task) self.ids.all_today.add_widget(itask) else: task = Upcoming() task.name = t[1].upper() task.og_name = t[1] task.time = ' '.join([date, time]) task.date = date task.size_hint = (1, None) task.height = dp(100) itask = Upcoming() itask.name = t[1].upper() itask.og_name = t[1] itask.time = ' '.join([date, time]) itask.date = date itask.size_hint = (1, None) itask.height = dp(100) uw.add_widget(task) self.ids.all_upcoming.add_widget(itask) # task.size = [100, 200] if len(tw.children) > 1: for child in tw.children: if type(child) == NewButton: tw.remove_widget(child) def clean_date(self, date: str): today = datetime.today() _date = date.split('/') if len(_date) < 3: _date = date.split('-') date_ = [int(x) for x in reversed(_date)] task_date = datetime(date_[0], date_[1], date_[2]) x = abs((today - task_date).days) if x == 0: return True else: return False def get_update(self, inst): nt = NewTask() nt.ids.task_name.text = inst.name nt.ids.task_time.text = inst.time nt.ids.task_date.text = inst.date nt.ids.submit_wrapper.clear_widgets() submit = Button(text='Update Task', background_normal='', background_color=rgba('#0e5174')) submit.bind(on_release=lambda x: self.update_task(nt, inst)) nt.ids.submit_wrapper.add_widget(submit) nt.open() def update_task(self, task_data, task): error = False xtask = [ task_data.ids.task_name.text, task_data.ids.task_date.text, task_data.ids.task_time.text ] for t in xtask: if len(t) < 3: t.hint_text = 'Field required' t.hint.text_color = [1, 0, 0, 1] error = True if error: pass else: xtask = [xtask[0], ' '.join(xtask[1:]), task.og_name] if self.db.update_task(xtask): task.name = task_data.ids.task_name.text task.date = task_data.ids.task_date.text task.time = task_data.ids.task_time.text task_data.dismiss() def delete_task(self, task: Today): name = task.name if self.db.delete_task(name): task.parent.remove_widget(task) def add_new(self): nt = NewTask() nt.open() def add_task(self, mv, xtask: tuple): error = False scroll_parent = self.ids.scroll_parent tw = self.ids.today_wrapper uw = self.ids.upcoming for t in xtask: if len(t.text) < 3: t.hint_text = 'Field required' t.hint.text_color = [1, 0, 0, 1] error = True if error: pass else: date = ' '.join([xtask[1].text, xtask[2].text]) task_ = (xtask[0].text, date) if self.clean_date(xtask[1].text): task = Today() task.og_name = xtask[0].text task.name = xtask[0].text.upper() task.time = xtask[2].text task.date = xtask[1].text task.size_hint = (None, None) task.size = [ scroll_parent.width / 2.4, scroll_parent.height * .9 ] if self.db.add_task(task_): tw.add_widget(task) else: task = Upcoming() task.og_name = xtask[0].text task.name = xtask[0].text.upper() task.time = xtask[2].text task.date = xtask[1].text task.size_hint = (1, None) task.height = dp(100) if self.db.add_task(task_): uw.add_widget(task) # add task to db mv.dismiss() # check if we have enough tasks to show if len(tw.children) > 1: for child in tw.children: if type(child) == NewButton: tw.remove_widget(child) def add_user(self, username, password): if len(username.text) < 3 or len(password.text) < 6: pass else: user = (username.text, password.text) if self.db.add_user(user): self.ids.scrn_mngr.current = 'scrn_signin' def auth_user(self, username, password): uname = username.text upass = password.text if self.db.auth_user((uname, upass)): self.ids.scrn_mngr.current = 'scrn_main' username.text = '' password.text = ''
class MainWindow(BoxLayout): def __init__(self, **kwargs): super().__init__(**kwargs) self.db = Database() self.init_view() # def init_view(self): # all_tasks = self.db.get_task() # scroll_parent = Window # tw = self.ids.today_wrapper # uw = self.ids.upcoming_wrapper # for t in all_tasks: # checkin, date1 = t[2], t[2] # if self.clear_date(date1): # task = Today() # task.rooms = t[1] # task.date1 = date1 # task.checkin = checkin # task.checkout, task.date2 = t[3], t[3] # task.room_type = t[4] # task.NumOfAdults = t[5] # task.NumOfChild = t[6] # task.size_hint = (None, 1) # task.size = [scroll_parent.width / 2.4, 45] # tw.add_widget(task) # else: # task = Upcoming() # task.rooms = t[1] # task.checkin = ''.join(date1) # task.checkin = checkin # task.checkout, task.date2 = t[3], t[3] # task.room_type = t[4] # task.NumOfAdults = t[5] # task.NumOfChild = t[6] # task.size_hint = (1, None) # task.height = dp(100) # uw.add_widget(task) def init_view(self): all_tasks = self.db.get_task() scroll_parent = Window tw = self.ids.today_wrapper for t in all_tasks: task = Today() task.rooms = t[1] task.checkin,task.date1 = t[2],t[3] print(task.checkin,task.date1) task.checkout, task.date2 = t[4], t[5] print(task.checkout, task.date2) # task.checkout = t[3] task.room_type = t[6] # task.checkin, task.date1 = t[2], t[3] # print(task.checkin, task.date1) task.NumOfAdults = t[7] task.NumOfChild = t[8] task.size_hint = (None, 1) # task.size = [100,200] task.size = [scroll_parent.width / 2.4, 45] itask = Today() itask.rooms = t[1] itask.room_type = t[6] itask.checkin, itask.date1 = t[2], t[3] itask.size_hint = (None, None) itask.size = [scroll_parent.width / 2.4, round(scroll_parent.height / 3)] tw.add_widget(task) self.ids.all_today.add_widget(itask) def clear_date(self, date: str): today = datetime.today() _date = date.split('/') print("date = ", _date) if len(_date) < 3: _date = date.split('-') date_ = [int(x) for x in reversed(_date)] print(date_) task_date = datetime(date_[0], date_[1], date_[2]) x = abs((today - task_date).days) print(x) if x == 0: return True else: return False def get_update(self,inst): nt = NewTask() nt.ids.task_rooms.text = inst.rooms nt.ids.task_checkin.text = inst.date1 nt.ids.task_date1.text = inst.checkin nt.ids.task_checkout.text = inst.date2 nt.ids.task_date2.text = inst.checkout nt.ids.task_room_type.text = inst.room_type nt.ids.task_adults.text = inst.NumOfAdults nt.ids.task_child.text = inst.NumOfChild nt.ids.submit_wrapper.clear_widgets() submit = Button(text='Update Reserve',background_normal='', background_color=rgba('#0e5174')) submit.bind(on_release=lambda x:self.update_task(nt,inst)) nt.ids.submit_wrapper.add_widget(submit) nt.open() def update_task(self,task_data,task): xtask = [ task_data.ids.task_rooms.text, task_data.ids.task_date1.text, task_data.ids.task_checkin.text, task_data.ids.task_date2.text, task_data.ids.task_checkout.text, task_data.ids.task_room_type.text, task_data.ids.task_adults.text, task_data.ids.task_child.text, task_data.ids.submit_wrapper.clear_widgets() ] error = None for t in xtask: if t is not None: if len(t)<1: t.hint_text = 'Field required' t.hint_text_color = [1,0,0,1] error = True if error: pass else: # xtask = [xtask[0],''.join(xtask[1:]),task.rooms] if self.db.update_task(xtask): task.rooms = task_data.ids.task_rooms.text task.date1 = task_data.ids.task_checkin.text task.checkin = task_data.ids.task_date1.text task.date2 = task_data.ids.task_checkout.text task.checkout = task_data.ids.task_date2.text task.room_type = task_data.ids.task_room_type.text task.NumOfAdults = task_data.ids.task_adults.text task.NumOfChild = task_data.ids.task_child.text task_data.dismiss() def delete_task(self, task: Today): rooms = task.rooms if self.db.delete_task(rooms): task.parent.remove_widget(task) def add_new(self): nt = NewTask() nt.open() def add_task(self, mv, xtask: tuple): error = False scroll_parent = self.ids.scroll_parent tw = self.ids.today_wrapper for t in xtask: if len(t.text) < 1: t.hint_text = 'Field required' t.hint_text_color = [1, 0, 0, 1] error = True if error: pass else: task = Today() task.rooms = xtask[0].text task.checkin = xtask[2].text task.date1 = xtask[1].text task.checkout = xtask[4].text task.date2 = xtask[3].text task.room_type = xtask[5].text task.NumOfAdults = xtask[6].text task.NumOfChild = xtask[7].text task.size_hint = (None, None) task.size = [scroll_parent.width / 2.4, scroll_parent.height - (.1 * scroll_parent.height)] # add tasks1 to db # checkin_date = ''.join([xtask[1].text, xtask[2].text]) # checkout_date = ''.join([xtask[3].text, xtask[4].text]) task_ = ( xtask[0].text, xtask[1].text, xtask[2].text, xtask[3].text, xtask[4].text, xtask[5].text, xtask[6].text, xtask[7].text) if self.db.add_task(task_): tw.add_widget(task) mv.dismiss() # check if we have enough tasks to show # if len(tw.children)>1: # for child in tw.children: # if type(child) == NewButton: # tw.remove_widget(child) # break def add_user(self,username,password): if len(username.text)<3 or len(password.text)<6: pass else: user = (username.text,password.text) if self.db.add_user(user): self.ids.scrn_mngr.current = 'scrn_signin' def auth_user(self, username, password): uname = username.text upass = password.text if self.db.auth_user((uname,upass)): self.ids.scrn_mngr.current = 'scrn_main' username.text='' password.text=''
class CameraClick(BoxLayout): db = Database() def capture(self): ''' Function to capture the images and give them the names according to their captured time and date. ''' camera = self.ids['camera'] timestr = time.strftime("%Y%m%d_%H%M%S") error_sound = SoundLoader.load('windows_error.mp3') # if not path.exists("/sdcard/kivy_temp"): # mkdir("/sdcard/kivy_temp") # Clock.schedule_once(partial(camera.export_to_png, # "/sdcard/kivy_temp/IMG_{}.png".format(timestr))) camera.export_to_png("IMG_{}.png".format(timestr)) with open("IMG_{}.png".format(timestr), "rb") as image_file: encoded_string = base64.b64encode(image_file.read()) # with open("/sdcard/kivy_temp/IMG_{}.png".format(timestr), "rb") as image_file: # encoded_string = base64.b64encode(image_file.read()) data = {'img_string': encoded_string} # r = requests.post(url="http://localhost:5000", data=data) r = requests.post( url="https://guarded-sea-73072.herokuapp.com/", data=data) pastebin_url = r.text # print("The pastebin URL is:%s"%pastebin_url) if r.status_code != 200: print(r.status_code, "bad analysis") error_sound.play() # vibrator.vibrate(0.5) else: print(r.status_code, r.reason, r.content.decode('utf-8')) if r.content.decode('utf-8') != "Another One": content = r.content.decode('utf-8') body = "" start_of_time = False start_of_body = False for line in content.splitlines(): print(line, start_of_body, start_of_time) if start_of_time: task_ = (body, line[:19]) self.db.add_task(task_) # vibrator.vibrate(0.2) # time.sleep(0.1) # vibrator.vibrate(0.2) if line.strip() == "The alarms are set for:": start_of_time = True start_of_body = False if start_of_body: body += line if line.strip() == "This is the event below:": start_of_body = True else: error_sound.play() # vibrator.vibrate(0.5) remove("IMG_{}.png".format(timestr))
def __init__(self, **kw): super().__init__(**kw) self.db = Database() self.ring_sound = SoundLoader.load('ring_ring.mp3') self.init_view()
class MainWindow (BoxLayout): def __init__(self, **kw): super().__init__(**kw) self.db = Database() self.ring_sound = SoundLoader.load('ring_ring.mp3') self.init_view() def my_callback(self, dt): all_tasks = self.db.get_tasks() uw = self.ids.upcoming for t in all_tasks: date, time = t[2].rsplit(' ', 1) date_object = datetime.strptime(date[2:]+" "+time, '%y-%m-%d %H:%M:%S') # print(date_object, datetime.today()) if date_object < datetime.today(): print("deleting a task") print(t) self.ring_sound.play() self.db.delete_task_by_time(t[2]) for child in uw.children: if child.date == date and child.time == time: uw.remove_widget(child) else: pass def init_view(self): all_tasks = self.db.get_tasks() scroll_parent = Window tw = self.ids.today_wrapper uw = self.ids.upcoming # self.background_thread() Clock.schedule_interval(self.my_callback, 5) for t in all_tasks: date, time = t[2].rsplit(' ', 1) date_object = datetime.strptime(date[2:]+" "+time, '%y-%m-%d %H:%M:%S') task = Upcoming() task.name = t[1] task.og_name = t[1] task.time = time task.date = date task.size_hint = (1, None) task.height = dp(100) itask = Upcoming() itask.name = t[1] itask.og_name = t[1] itask.time = time itask.date = date itask.size_hint = (1, None) itask.height = dp(100) uw.add_widget(task) self.ids.all_upcoming.add_widget(itask) # task.size = [100, 200] if len(tw.children) > 1: for child in tw.children: if type(child) == NewButton: tw.remove_widget(child) def clean_date(self, date: str): today = datetime.today() _date = date.split('/') if len(_date) < 3: _date = date.split('-') date_ = [int(x) for x in reversed(_date)] # Change this later task_date = today # task_date = datetime(date_[0], date_[1], date_[2]) x = abs((today - task_date).days) if x == 0: return True else: return False def get_update(self, inst): nt = NewTask() nt.ids.task_name.text = inst.name nt.ids.task_time.text = inst.time # nt.ids.task_date.text = inst.date nt.ids.submit_wrapper.clear_widgets() submit = Button(text='Update Task', background_normal='', background_color=rgba('#0e5174')) submit.bind(on_release=lambda x: self.update_task(nt, inst)) nt.ids.submit_wrapper.add_widget(submit) nt.open() def update_task(self, task_data, task): error = False xtask = [ task_data.ids.task_name.text, # task_data.ids.task_date.text, task_data.ids.task_time.text ] for t in xtask: if len(t) < 3: t.hint_text = 'Field required' t.hint.text_color = [1, 0, 0, 1] error = True if error: pass else: # Change this later # xtask = [xtask[0], ' '.join(xtask[1:]), task.og_name] xtask = [xtask[0], ' '.join(xtask[1:]), task.og_name] if self.db.update_task(xtask): task.name = task_data.ids.task_name.text # Change this later # task.date = task_data.ids.task_date.text task.date = str(datetime.today()).split(" ")[0] task.time = task_data.ids.task_time.text task_data.dismiss() def delete_task(self, task: Today): date = task.date + " " + task.time # if self.db.delete_task(name): print(date) if self.db.delete_task_by_time(date): task.parent.remove_widget(task) def add_new(self): nt = NewTask() nt.open() def add_task(self, mv, xtask: tuple): error = False scroll_parent = self.ids.scroll_parent tw = self.ids.today_wrapper uw = self.ids.upcoming for t in xtask: if len(t.text) < 3: t.hint_text = 'Field required' # t.hint.text_color = [1, 0, 0, 1] # Change this later # error = True if error: pass else: # Change this later # date = ' '.join([xtask[1].text, xtask[2].text]) date = xtask[1].text task_ = (xtask[0].text, date) # Change this later task = Upcoming() task.og_name = xtask[0].text task.date = str(datetime.today()).split(' ')[0] task.name = xtask[0].text # Change this later # task.time = xtask[2].text # task.date = xtask[1].text task.time = xtask[1].text task.size_hint = (1, None) task.height = dp(100) if self.db.add_task(task_): uw.add_widget(task) # if self.clean_date(xtask[1].text): # task = Today() # task.og_name = xtask[0].text # task.name = xtask[0].text.upper() # task.time = xtask[2].text # task.date = xtask[1].text # task.size_hint = (None, None) # task.size = [scroll_parent.width / # 2.4, scroll_parent.height * .9] # if self.db.add_task(task_): # tw.add_widget(task) # else: # task = Upcoming() # task.og_name = xtask[0].text # task.name = xtask[0].text.upper() # task.time = xtask[2].text # task.date = xtask[1].text # task.size_hint = (1, None) # task.height = dp(100) # if self.db.add_task(task_): # uw.add_widget(task) # add task to db mv.dismiss() # check if we have enough tasks to show if len(tw.children) > 1: for child in tw.children: if type(child) == NewButton: tw.remove_widget(child) def add_user(self, username, password): if len(username.text) < 3 or len(password.text) < 6: pass else: user = (username.text, password.text) if self.db.add_user(user): self.ids.scrn_mngr.current = 'scrn_main' def auth_user(self, username, password): uname = username.text upass = password.text if self.db.auth_user((uname, upass)): self.ids.scrn_mngr.current = 'scrn_main' username.text = '' password.text = ''