def show_time_picker(self): today = datetime.today() time_dialog = MDTimePicker() time_dialog.set_time(time(hour=today.hour, minute=today.minute)) time_dialog.bind(time=self.set_time) time_dialog.open()
def time_picker(self,obj): from datetime import datetime previous_time = datetime.strptime("16:20:00", '%H:%M:%S').time() picker=MDTimePicker() picker.set_time(previous_time) picker.bind(time=self.got_time) picker.open()
def show_time_picker(self): global user if user == "": pass time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time) time_dialog.open()
def show_time_picker(self): from datetime import datetime # Must be a datetime object now = datetime.now() time_dialog = MDTimePicker() time_dialog.set_time(now) time_dialog.bind(time=self.get_time) time_dialog.open()
def show_time_picker(self): time_dialog = MDTimePicker() #previous_time = datetime.strptime("00:00:00", '%H:%M:%S').time() #time_dialog = MDTimePicker() #time_dialog.set_time(previous_time) time_dialog.bind(time=self.get_time) time_dialog.open()
def show_example_time_picker(self, military): time_dialog = MDTimePicker(military=military) time_dialog.bind(time=self.get_time_picker_date) if self.ids.time_picker_use_previous_time.active: try: time_dialog.set_time(self.previous_time) except AttributeError: pass time_dialog.open()
def show_time_picker(self): from datetime import datetime # Define default time default_time = datetime.strptime("4:20:00", '%H:%M:%S').time() time_dialog = MDTimePicker() # Set default Time time_dialog.set_time(default_time) time_dialog.bind(on_cancel=self.on_cancel, time=self.get_time) time_dialog.open()
def show_example_time_picker(self): from kivymd.uix.picker import MDTimePicker time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time_picker_date) if self.ids.time_picker_use_previous_time.active: try: time_dialog.set_time(self.previous_time) except AttributeError: pass time_dialog.open()
def open_time_picker(self): """ Opens up time picker dialog for selection of alarm time. """ time_dialog = MDTimePicker() # getting the previous time text in the button previous_time = datetime.strptime(self.time_picker.text, '%H:%M').time() # setting the previous time in the dialog time_dialog.set_time(previous_time) # binds a method that sets the time chosen time_dialog.bind(time=self.get_time_picker_time) time_dialog.open()
def change_reminder(self, *args): # sets default time for value of Reminder.text # if empty --> default time is now default_time = datetime.datetime.now() if self.text in [ None, '', ' ' ] else datetime.datetime.strptime(self.text, '%H:%M') # open MDTimePicker preset to default_time time_dialog = MDTimePicker() time_dialog.set_time(default_time) time_dialog.open() time_dialog.bind(on_dismiss=lambda *args: self. update_reminder_time(time_dialog.time))
def show_example_time_picker(self): """Show MDTimePicker from the screen Pickers.""" from kivymd.uix.picker import MDTimePicker time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time_picker_date) if self.data["Pickers"][ "object"].ids.time_picker_use_previous_time.active: try: time_dialog.set_time(self.previous_time) except AttributeError: pass time_dialog.open()
def add_reminder(self, *args): # sets default time to now default_time = datetime.datetime.now() # creates new Reminder with text of time from MDTimePicker def set_reminder_time(self, time, *args): if time not in [None, '', ' ']: self.reminder_list_instance.add_widget( self.root_instance.Reminder(text=f'{time:%H:%M}')) # open MDTimePicker set to default_time time_dialog = MDTimePicker() time_dialog.set_time(default_time) time_dialog.open() time_dialog.bind(on_dismiss=lambda *args: set_reminder_time( self, time_dialog.time))
def choose_due_time(self, date, *args): # define default_time from task.secondary_text (second part / time-part) due_time = '' if self.text in [None, '', ' '] else self.text.split(' ')[ 1] default_time = datetime.datetime.now() if due_time in [ None, '', ' '] else datetime.datetime.strptime(due_time, '%H:%M') # setting Task.due_date to values from MDDatePicker and MDTimePicker def set_due_date_time(self, date, time, *args): if all([date != None, time != None]): due_date_time = ' '.join( [f'{date:%d.%m.%Y}', f'{time:%H:%M}']) self.text = due_date_time # open MDTimePicker preset to default_time time_dialog = MDTimePicker() time_dialog.set_time(default_time) time_dialog.open() time_dialog.bind( on_dismiss=lambda *args: set_due_date_time( self, date, time_dialog.time) )
def open_time_picker(self): picker = MDTimePicker() picker.bind(time=self.on_time) picker.open()
class Test(MDApp): def build(self): self.theme_cls.theme_style = 'Dark' self.theme_cls.primary_palette = "Purple" Builder.load_file( f"{os.environ['Scheduler-master']}/KivyFiles/Login_Signup/loginwindow.kv" ) Builder.load_file( f"{os.environ['Scheduler-master']}/KivyFiles/Login_Signup/newinput.kv" ) Builder.load_file( f"{os.environ['Scheduler-master']}/KivyFiles/Login_Signup/signupwindow.kv" ) self.sm = ScreenManager() self.sm.add_widget(loginwindow()) self.sm.add_widget(signupwindow()) self.sm.add_widget(newinput()) return self.sm dialog = None inpasdialog = None inusedialog = None emptydialog = None alreadydialog = None sameemaildialog = None samepassdialog = None dynamic_ip = None val012 = None previous_time = ObjectProperty() fixedtimedict = {} def get_info(self): self.emptydialog = MDDialog( title='[color=#FFFFFF]Empty details[/color]', text='Please fill all the required details!', size_hint=(0.4, 0.3), buttons=[ MDRaisedButton(text='OK', on_release=self.empty_close, text_color=self.theme_cls.primary_color) ]) self.alreadydialog = MDDialog( title='[color=#FFFFFF]Can not register![/color]', text='Email already exists!', size_hint=(0.4, 0.3), buttons=[ MDRaisedButton(text='OK', on_release=self.already_close, text_color=self.theme_cls.primary_color) ]) self.sameemaildialog = MDDialog( title='[color=#FFFFFF]Can not register![/color]', text='Email and Confirm email do not match!', size_hint=(0.4, 0.3), buttons=[ MDRaisedButton(text='OK', on_release=self.sameemail_close, text_color=self.theme_cls.primary_color) ]) self.samepassdialog = MDDialog( title='[color=#FFFFFF]Can not register![/color]', text='Password and Confirm password do not match!', size_hint=(0.4, 0.3), buttons=[ MDRaisedButton(text='OK', on_release=self.samepass_close, text_color=self.theme_cls.primary_color) ]) name = str(self.sm.get_screen('signup').ids.name.text) email = str(self.sm.get_screen('signup').ids.email.text) self.mainemail = email confirm_email = str( self.sm.get_screen('signup').ids.confirm_email.text) password = str(self.sm.get_screen('signup').ids.password.text) confirm_pass = str( self.sm.get_screen('signup').ids.confirm_password.text) if name == '' or email == '' or confirm_email == '' or password == '' or confirm_pass == '': self.emptydialog.open() elif email != confirm_email: self.sameemaildialog.open() elif password != confirm_pass: self.samepassdialog.open() elif mysqllog.check(email, password) == 1 or mysqllog.check( email, password) == 2: self.alreadydialog.open() else: mysqllog.add_new_user([email, password]) self.show_dialog() def time_picker(self): self.time_dialog = MDTimePicker() self.time_dialog.bind(time=self.show) self.time_dialog.open() def show(self, instance, time): self.sm.get_screen('ninput').ids[self.dynamic_ip].text = str(time) mysqllog.add_user_data(self.mainemail, [(str(self.dynamic_ip), str(time))]) self.fixedtimedict[self.dynamic_ip] = time def MainApp(self, *args): self.stop() MainApp.TestNavigationDrawer().run() def show_dialog(self, *args): if not self.dialog: self.dialog = MDDialog( title='[color=#FFFFFF]Confirmation[/color]', text='You have been registered.', size_hint=(0.4, 0.3), buttons=[ MDFlatButton(text='CANCEL', on_release=self.dialog_close, text_color=self.theme_cls.primary_color), MDRaisedButton(text="OK!", on_release=self.on_signup, text_color=self.theme_cls.primary_color) ]) self.dialog.open() def on_stop(self): return True def show_dialog(self, *args): if not self.dialog: self.dialog = MDDialog( title='[color=#FFFFFF]Confirmation[/color]', text='You have been registered.', size_hint=(0.4, 0.3), buttons=[ MDFlatButton(text='CANCEL', on_release=self.dialog_close, text_color=self.theme_cls.primary_color), MDRaisedButton(text="OK!", on_release=self.on_signup, text_color=self.theme_cls.primary_color) ]) self.dialog.open() def checkpass(self, *args): self.inusedialog = MDDialog( title='[color=#FFFFFF]Username Incorrect[/color]', text='Your email is not registered!.', size_hint=(0.4, 0.3), buttons=[ MDRaisedButton(text='OK', on_release=self.inusedialog_close, text_color=self.theme_cls.primary_color) ]) self.inpasdialog = MDDialog( title='[color=#FFFFFF]Password Incorrect[/color]', text='You have entered the incorrect password.', size_hint=(0.4, 0.3), buttons=[ MDRaisedButton(text='OK', on_release=self.inpasdialog_close, text_color=self.theme_cls.primary_color) ]) self.val012 = mysqllog.check( str(self.sm.get_screen('login').ids.username.text), str(self.sm.get_screen('login').ids.password.text)) if self.val012 == 1: self.stop() self.mainemail = str(self.sm.get_screen('login').ids.username.text) MainApp.email = str(self.sm.get_screen('login').ids.username.text) MainApp.TestNavigationDrawer().run() elif self.val012 == 2: self.inpasdialog.open() elif self.val012 == 0: self.inusedialog.open() def check_focus(self, instance, text): if not text: self.sm.get_screen('signup').ids[ self.ip2].helper_text = 'Re-Enter your {}!'.format(self.ip1) return if text != self.sm.get_screen('signup').ids[self.ip1].text: self.sm.get_screen('signup').ids[ self.ip2].helper_text = '{} does not match!'.format(self.ip1) instance.error = True Animation( duration=0.2, _current_error_color=instance.error_color).start(instance) Animation( duration=0.2, _current_line_color=instance.error_color, _current_hint_text_color=instance.error_color, _current_right_lbl_color=instance.error_color, ).start(instance) else: self.sm.get_screen('signup').ids[ self.ip2].helper_text = 'Re-Enter your {}!'.format(self.ip1) Animation(duration=0.2, _current_error_color=(0, 0, 0, 0)).start(instance) Animation( duration=0.2, _current_line_color=instance.line_color_focus, _current_hint_text_color=instance.line_color_focus, _current_right_lbl_color=instance.line_color_focus, ).start(instance) instance.error = False def dialog_close(self, *args): self.dialog.dismiss() def inusedialog_close(self, *args): self.inusedialog.dismiss() def inpasdialog_close(self, *args): self.inpasdialog.dismiss() def empty_close(self, *args): self.emptydialog.dismiss() def already_close(self, *args): self.alreadydialog.dismiss() def sameemail_close(self, *args): self.sameemaildialog.dismiss() def samepass_close(self, *args): self.samepassdialog.dismiss() def on_stop(self): return True def on_signup(self, *args): self.dialog.dismiss() self.sm.current = 'ninput'
def show_time_picker(self): picker = MDTimePicker() picker.bind(time= self.get_time) s = active_child[self.time_senter] if active_button[s]: picker.open()
def select_time(self): time_dialog = MDTimePicker() time_dialog.bind(time=self.set_time) time_dialog.open()
def show_time_picker(self): time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time) time_dialog.open()
def show_timepicker(self): picker = MDTimePicker() picker.bind(time=self.got_time) picker.open()
def time_picker(self, *args): tm_dia = MDTimePicker() tm_dia.bind(time=self.get_time) tm_dia.open()
def show_time_picker(self): """Open time picker dialog.""" time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time) time_dialog.open()
def clock(self): time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time) time_dialog.open()
def show_time_picker( self): #funcion con la cual se utiliza el picker de hora time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time) time_dialog.open()
def show_example_time_picker(self): time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time_picker_date) time_dialog.open()
def show_time_picker(self): time_dialog = MDTimePicker() time_dialog.bind(time=self.get_time) previous_time = datetime.now() time_dialog.set_time(previous_time) time_dialog.open()
class YalbApp(MDApp): title = "Yet Another LogBook" # theme_cls = ThemeManager() previous_date = ObjectProperty() def __init__(self, **kwargs): super().__init__(**kwargs) self.time_dialog = MDTimePicker() self.previous_time = datetime.utcnow() def build(self): table = TV( size=(Window.size[0], Window.size[1]), pos_hint={ 'x': 0.0, 'y': 0.0 }, do_scroll_x=True, ) table.populate("log.db") #print(str(table)) self.root.ids.sm.transition = NoTransition() self.root.ids.scr_second_box.add_widget(table) def _on_rotate(obj, *args): #print(*args) self.on_rotate(*args) Window.bind(on_rotate=_on_rotate) Window.bind(on_resize=_on_rotate) #scr2.add_widget(RV()) print("Vsykuyu hernyu delat tut") def calculate_night_time(self, coords_departure, coords_arrival, takeoff, landing): if landing < takeoff: landing += timedelta(days=1) departure_ap = ephem.Observer() departure_ap.lat = radians(coords_departure[0]) departure_ap.lon = radians(coords_departure[1]) arrival_ap = ephem.Observer() arrival_ap.lat = radians(coords_arrival[0]) arrival_ap.lon = radians(coords_arrival[1]) departure_ap.date = takeoff arrival_ap.date = takeoff + timedelta( days=(departure_ap.lon - arrival_ap.lon) / pi / 12.0) s = ephem.Sun() plane = ephem.Observer() plane.date = takeoff flight_time_minutes = int((landing - takeoff).total_seconds() // 60) print("ldgt-to in minutes:", flight_time_minutes, "HH:MM :", timedelta(hours=flight_time_minutes / 60.0)) dlat = (arrival_ap.lat - departure_ap.lat) / flight_time_minutes dlon = (arrival_ap.lon - departure_ap.lon) / flight_time_minutes dt = timedelta(seconds=60) nt = 0 for i in range(flight_time_minutes): plane.date = takeoff + dt * float(i + 0.5) plane.lat = departure_ap.lat + dlat * float(i) plane.lon = departure_ap.lon + dlon * float(i) try: if plane.next_rising(s) < plane.next_setting(s): nt += 1 except ephem.NeverUpError: nt += 1 except ephem.AlwaysUpError: pass nt = timedelta(hours=nt / 60.0) return nt def new_leg(self): date = self.root.ids.date_picker_input.text flightno = self.root.ids.flight_no_item_input.text acno = self.root.ids.aircraft_id_item_input.text fromap = self.root.ids.from_item_input.text toap = self.root.ids.to_item_input.text ofbt = self.root.ids.offblock_item_input.text tot = self.root.ids.takeoff_item_input.text lt = self.root.ids.landing_item_input.text onbt = self.root.ids.onblock_item_input.text offblocktime = datetime.strptime(date + " " + ofbt, "%Y-%m-%d %H:%M") onblocktime = datetime.strptime(date + " " + onbt, "%Y-%m-%d %H:%M") takeofftime = datetime.strptime(date + " " + tot, "%Y-%m-%d %H:%M") landingtime = datetime.strptime(date + " " + lt, "%Y-%m-%d %H:%M") if offblocktime > onblocktime: # Check next day onblocktime += timedelta(days=1) blktime = onblocktime - offblocktime if landingtime < takeofftime: # Check next day landingtime += timedelta(days=1) flttime = landingtime - takeofftime #coords_departure = self.get_ap_coords(fromap) coords_departure = (51.8779638888889, -176.646030555556) #coords_arrival = self.get_ap_coords(toap) coords_arrival = (44.814998626709, 136.292007446289) takeoff = takeofftime landing = landingtime night_time = self.calculate_night_time(coords_departure, coords_arrival, takeoff, landing) connection = sqlite3.connect("log.db") print("db_connected debug") cursor = connection.cursor() print("cursor_connected debug") sql = "INSERT INTO log ('Date', 'FlightNumber', 'Aircraft', 'AirportDeparture', 'AirportArrival', 'OffBlock', 'TakeOff', 'Landing', 'OnBlock', 'FlightTime', 'BlockTime', 'NightTime')" \ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?)" data = (date, flightno, acno, fromap, toap, ofbt, tot, lt, onbt, str(flttime)[:-3], str(blktime)[:-3], str(night_time)[:-3]) cursor.execute(sql, data) print("cursor_executedted debug") connection.commit() print("connection_commited debug") cursor.close() print("cursor_closed debug") if connection: connection.close() print("conecion_closed debug") print(blktime, flttime, night_time) print(date, flightno, acno, fromap, toap, ofbt, tot, lt, onbt) def get_id(self, instance): for id, widget in self.root.ids.items(): if widget.__self__ == instance: return id def on_rotate(self, angle, *args): table = self.root.ids.scr_second.children[0].children[0] table.layout.width = max(Window.size[0], Window.size[1]) def on_refresh(self): self.on_rotate(0) def get_time_picker_data(self, instance, time): name = self.get_id(instance) if not name: return self.root.ids[name + "_item_input"].text = str(time)[:-3] self.previous_time = time def show_time_picker(self, instance): self.time_dialog = MDTimePicker() self.time_dialog.bind( time=lambda x, time: self.get_time_picker_data(instance, time)) try: self.time_dialog.set_time(self.previous_time) except AttributeError: pass self.time_dialog.open() def set_previous_date(self, date_obj): self.previous_date = date_obj self.root.ids.date_picker_input.text = str(date_obj) def show_date_picker(self): pd = self.previous_date try: MDDatePicker(self.set_previous_date, pd.year, pd.month, pd.day).open() except AttributeError: MDDatePicker(self.set_previous_date).open() def screen_main(self): sm = self.root.ids.sm sm.switch_to(self.root.ids.scr_main) def scr_edit(self): sm = self.root.ids.sm sm.switch_to(self.root.ids.scr_edit) def screen_second(self): sm = self.root.ids.sm sm.switch_to(self.root.ids.scr_second) self.root.ids.ap.title = sm.current_screen.name def screen_debug(self): sm = self.root.ids.sm sm.switch_to(self.root.ids.scr_debug) self.root.ids.ap.title = sm.current_screen.name
class EventChooser(MDScreen): def __init__(self, **kw): super().__init__(**kw) self.name = 'chooser' self.repeat = RepeatDialog(size_hint_y=None, height=800) self.dialog = MDDialog(title="Repeat", type="custom", content_cls=self.repeat) self.date = MDDatePicker() self.date.bind(on_save=self.on_date_save) self.time = MDTimePicker() self.time.bind(on_save=self.on_time_save) self.ttime, self.ddate = None, None self.dialog.size_hint_x = .9 def on_date_save(self, instance, value, date_range): iso = datetime.date(datetime.datetime.now().year, datetime.datetime.now().month, datetime.datetime.now().day) if not str(value) > str(iso) or not str(value) < "2071-01-01": toast('Invalid Date! Must be in the future!') if str(value) > str(iso) and str(value) < "2071-01-01": self.ddate = str(value) def on_time_save(self, instance, time): self.ttime = str(time) def save_event(self, name, time, date): if not name: toast("Please Enter Event Name!") elif not time and not self.ids.ad.active: toast("Please Choose a time for the Event") elif not date: toast("Please Choose a date for the Event") else: repeat = self.repeat.get_repeat() with open('./lib/data/events.json', 'r') as f: file = json.load(f) file['events'][date] = { "name": name, "time": time, "repeat": repeat } if self.ids.ad.active: file['events'][date] = {"name": name, "repeat": repeat} with open('./lib/data/events.json', 'w') as f: json.dump(file, f) self.parent.transition.direction = 'right' self.parent.current = "home" self.clear() self.snackbar(name, date) self.parent.transition.direction = 'left' def clear(self): self.ttime, self.ddate = None, None self.ids.text_field.text = '' self.ids.ad.active = False self.repeat.custom = False self.repeat.repeat_type = None self.repeat.customdict = {} self.repeat.days = [] self.repeat.custom_end = '' self.repeat.customrepeat.ids.fr.active = False def snackbar(self, text, date): snackbar = CustomSnackbar( text=f"Successfully Created {text}! Date: {date}", icon="information", snackbar_x="10dp", snackbar_y="10dp", ) snackbar.size_hint_x = (Window.width - (snackbar.snackbar_x * 2)) / Window.width snackbar.open()
class TestNavigationDrawer(MDApp): main_text = '' temp_instance = None main_event_list = [] main_meeting_list = [] main = [] my_event = None mytime = None starttime = None endtime = None data = {'delete': 'Delete', 'pencil': 'Add'} # def callback(self, instance, *args): # self.cstm_evnt = MDDialog(title='Custom Event',type='custom',content_cls=custom_events()) # pass def build(self): self.theme_cls.theme_style = 'Dark' Builder.load_file( f"{os.environ['Scheduler-master']}/KivyFiles/Main App/content.kv") Builder.load_file( f"{os.environ['Scheduler-master']}/KivyFiles/Main App/content2.kv") #Builder.load_file(f"{os.environ['Scheduler-master']}/KivyFiles/Main App/content3.kv") return Builder.load_string(KV) #self.refresh_callback() def on_start(self): self.load_schedule() def load_schedule(self): for i in mysqllog.return_schedule(email): starttime = mintohhmmss(i[0]) endtime = mintohhmmss(i[1]) evnt = i[2] self.main.append((evnt, starttime, endtime)) instance = SwipeToDeleteItem(text=evnt, text2=starttime + ' - ' + endtime) self.root.ids.md_list.add_widget(instance) cstm_evnt = None cstm_evnt2 = None confirmd2 = None confirmdf = None deleteb = None dlt_event = None def add(self): #self.time_dialog=MDTimePicker() if not self.cstm_evnt: self.cstm_evnt = MDDialog( title='[color=#FFFFFF]Add Event[/color]', type='custom', content_cls=custom_events(), size_hint=(0.4, 0.3), buttons=[ MDFlatButton(text='CANCEL', on_release=self.cstm_evnt_close, text_color=self.theme_cls.primary_color), MDFillRoundFlatIconButton(text='Set Time', icon='clock', on_release=self.time_picker) ]) self.cstm_evnt.open() def addM(self): #self.time_dialog=MDTimePicker() if not self.cstm_evnt2: self.cstm_evnt2 = MDDialog( title='[color=#FFFFFF]Add Meeting[/color]', type='custom', content_cls=custom_events2(), size_hint=(0.4, 0.3), buttons=[ MDFlatButton(text='CANCEL', on_release=self.cstm_evnt_close2, text_color=self.theme_cls.primary_color), MDFillRoundFlatIconButton(text='Starting Time', icon='clock', on_release=self.time_picker2) ]) self.cstm_evnt2.open() def delete(self): self.cstm_evnt2 = None #self.time_dialog=MDTimePicker() if not self.cstm_evnt2: self.cstm_evnt2 = MDDialog( title='[color=#FFFFFF]Delete[/color]', type='custom', content_cls=custom_events2(), size_hint=(0.4, 0.3), buttons=[ MDFlatButton(text='CANCEL', on_release=self.cstm_evnt_close2, text_color=self.theme_cls.primary_color), MDRaisedButton(text='Delete', on_release=self.deleteevent) ]) self.cstm_evnt2.open() def deleteevent(self, *args): for i in self.ids.md_list: if str(i.text) == self.my_event: self.root.ids.md_list.remove_widget(i) try: mysqllog.remove_routine(email, self.my_event) except: mysqllog.remove_user_data(email, self.my_event) def time_picker(self, *args): self.time_dialog = MDTimePicker() #self.time_dialog.title=self.my_event self.time_dialog.bind(time=self.show) self.time_dialog.open() self.cstm_evnt.dismiss() self.cstm_event = None #confirmd=None def time_picker2(self, *args): self.time_dialog = MDTimePicker() #self.time_dialog.title=self.my_event self.time_dialog.bind(time=self.show2) self.time_dialog.open() self.cstm_evnt2.dismiss() self.cstm_event2 = None def time_picker3(self, *args): self.time_dialog = MDTimePicker() #self.time_dialog.title=self.my_event self.time_dialog.bind(time=self.show3) self.time_dialog.open() self.confirmd2.dismiss() def show2(self, instance, time): self.starttime = time print(self.starttime) self.confirmd2 = None self.confirm2() def show3(self, instance, time): self.endtime = time print(self.endtime) self.confirmdf = None self.confirmfinal() def delete_callback(self): pass def confirm2(self): if not self.confirmd2: self.confirmd2 = MDDialog( title='[color=#FFFFFF]Confirm[/color]', size_hint=(0.4, 0.3), text="{},{}".format(self.my_event, self.starttime), buttons=[ MDFlatButton(text='Cancel', on_release=self.clconfirmd2, text_color=self.theme_cls.primary_color), MDFillRoundFlatIconButton(text='Ending Time', icon='clock', on_release=self.time_picker3) ]) self.confirmd2.open() def confirmfinal(self): if not self.confirmdf: self.confirmdf = MDDialog( title='[color=#FFFFFF]Confirm[/color]', size_hint=(0.4, 0.3), text="Add Meeting {} at {} to {}?".format( self.my_event, self.starttime, self.endtime), buttons=[ MDFlatButton(text='NO', on_release=self.clconfirmdf, text_color=self.theme_cls.primary_color), MDRaisedButton(text='YES', on_release=self.event_adder2) ]) self.confirmdf.open() def confirm(self): if not self.confirmd: self.confirmd = MDDialog( title='[color=#FFFFFF]Confirm[/color]', size_hint=(0.4, 0.3), text="Add Event {} at {} ?".format(self.my_event, self.mytime), buttons=[ MDFlatButton(text='NO', on_release=self.clconfirmd, text_color=self.theme_cls.primary_color), MDRaisedButton(text='YES', on_release=self.event_adder) ]) self.confirmd.open() def deletecl(self, *args): self.deleteb.dismiss() def clconfirmd(self, *args): self.confirmd.dismiss() def clconfirmd2(self, *args): self.confirmd2.dismiss() def clconfirmdf(self, *args): self.confirmdf.dismiss() def refresh_callback(self, *args): mysqllog.add_routine('*****@*****.**', self.main_meeting_list) mysqllog.add_user_data('*****@*****.**', self.main_event_list) self.main = sorted(self.main, key=itemgetter(1)) self.root.ids.md_list.clear_widgets() for i in self.main: if len(i) == 2: self.root.ids.md_list.add_widget( SwipeToDeleteItem(text=i[0], text2=i[1])) else: self.root.ids.md_list.add_widget( SwipeToDeleteItem(text=i[0], text2=i[1] + ' - ' + i[2])) #self.root.ids.md_list.add_widget(i) def textfrominstance(self, instance): return instance.text def show(self, instance, time): self.mytime = time self.confirmd = None self.confirm() #fixedtimedict[key]=time def cstm_evnt_close(self, *args): self.cstm_evnt.dismiss() def cstm_evnt_close2(self, *args): self.cstm_evnt2.dismiss() def remove_item(self, instance): print(instance.text) self.temp_instance = instance if not self.dlt_event: self.dlt_event = MDDialog( title='[color=#FFFFFF]Confirm Delete[/color]', size_hint=(0.4, 0.3), text="Delete {}?".format(instance.text), buttons=[ MDFlatButton(text='NO', on_release=self.cldelevent, text_color=self.theme_cls.primary_color), MDRaisedButton(text='YES', on_press=self.rem) ]) self.dlt_event.open() def rem(self, instance): print(self.main_event_list) self.dlt_event.dismiss() self.root.ids.md_list.remove_widget(self.temp_instance) for i in range(len(self.main_event_list)): if self.main_event_list[i][0] == self.temp_instance.text: del (self.main_event_list[i]) print(self.main_event_list) break self.dlt_event = None def cldelevent(self, instance): self.dlt_event.dismiss() def event_adder(self, instance): self.confirmd.dismiss() instance = SwipeToDeleteItem(text=self.my_event, text2=str(self.mytime)) self.main_event_list.append((instance.text, instance.text2)) self.main.append((str(self.my_event), str(self.mytime))) self.root.ids.md_list.add_widget(instance) mysqllog.add_user_data(email, [(self.my_event, self.mytime)]) def event_adder2(self, instance): self.confirmdf.dismiss() instance = SwipeToDeleteItem(text=self.my_event, text2=str(self.starttime) + ' - ' + str(self.endtime)) self.main_meeting_list.append( (str(self.my_event), str(self.starttime), str(self.endtime))) self.main.append( (str(self.my_event), str(self.starttime), str(self.endtime))) self.root.ids.md_list.add_widget(instance) mysqllog.add_routine(email, [(self.my_event, self.starttime, self.endtime)])
def show_time_picker(self, id): self.current_button_id = id time_dialog = MDTimePicker() time_dialog.set_time(datetime.now()) time_dialog.bind(on_save=self.on_save_time_picker, on_cancel=self.on_cancel_time_picker) time_dialog.open()
def show_time_picker(self): time_dialog = MDTimePicker() time_dialog.bind(time=self.get_timeFromPicker) time_dialog.set_time(datetime.now().time()) time_dialog.open()