def show_dialog_add_lineup_entry(self): """ Show a dialog to ask the name of the new lineup_entry. :return: """ creation_time = datetime.now().strftime("%Y%m%d-%H%M%S") text = f"Concert_{creation_time}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) # mdlbl1 = MDLabel(text=str(CU.tfs.dic['EXPLANATION_WORKSPACE_PATH'].value)) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"Name of song" mdtf1.helper_text = f"{CU.tfs.dic['EXPLANATION_PLAYLIST_SONG_NAME'].value}" mdtf1.helper_text_mode = "on_focus" # content_obj.add_widget(mdlbl1) content_obj.add_widget(mdtf1) CU.show_input_dialog( title=f"Enter Name of New Songentry", content_obj=content_obj, size_hint=(.7, .4), text_button_ok="Add", ok_callback_set=lambda text_button, instance, *args, **kwargs: { self.add_lineup_entry(instance.text_field.text), self.refresh_list() })
def show_dialog_add_playlist(self): """ Show a dialog to ask the name of the new playlist. :return: """ creation_time = datetime.now().strftime("%Y%m%d-%H%M%S") text = f"Concert_{creation_time}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"Name of playlist" mdtf1.helper_text = f"{CU.tfs.dic['EXPLANATION_PLAYLIST_SONG_NAME'].value}" mdtf1.helper_text_mode = "on_focus" content_obj.add_widget(mdtf1) CU.show_input_dialog( title=f"Enter Name of New Playlist", content_obj=content_obj, size_hint=(.7, .4), text_button_ok="Add", text_button_cancel="Cancel", ok_callback_set=lambda *args, **kwargs: (self.add_playlist(mdtf1.text), self.refresh_list()))
def show_dialog_rename_playlist(self, playlist_rowview): """ Show a dialog to ask for the new name of the playlist. :param playlist_rowview: :return: """ text = f"{str(playlist_rowview.playlist_obj.file_path.stem)}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"Name of playlist" mdtf1.helper_text = f"{CU.tfs.dic['EXPLANATION_PLAYLIST_SONG_NAME'].value}" mdtf1.helper_text_mode = "on_focus" content_obj.add_widget(mdtf1) CU.show_input_dialog(title=f"Enter New Name for Playlist", content_obj=content_obj, size_hint=(.7, .4), text_button_ok="Update", text_button_cancel="Cancel", ok_callback_set=lambda *args, **kwargs: (self.rename_playlist(playlist_rowview, mdtf1.text ), self.refresh_list()))
def handle_exception(self, exception): # app = App.get_running_app() # If the current problem is cleared, "accept" the next one: if self._current_exception is None: # In order to make a new dialog, we get rid of a previous one if any: self._error_dialog = None # While showing the popup to the user with the error's stacktrace, all subsequent calls to handle_exception() should PASS. It turns out that while in error, that his method is constantly triggered!! self._PASS_or_RAISE = ExceptionManager.PASS if self._error_dialog is None: self._current_exception = exception bl1 = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) # Make sure the height is such that there is something to scroll. bl1.bind(minimum_height=bl1.setter('height')) mdlbl1 = MDLabel( text= f"[color={get_hex_from_color((1, 0, 0))}][i]{str(self._current_exception)}[/i][/color]{os.linesep}{os.linesep}" f"[b]-> Our apologies for the inconvenience, please consult the stack trace below & mail screenshot to [email protected]:[/b]" f"{os.linesep}{traceback.format_exc()}", size_hint=(1, None), markup=True) # TODO: Rather try the .kv alternative also provided at "https://stackoverflow.com/questions/43666381/wrapping-the-text-of-a-kivy-label" and "https://kivy.org/doc/stable/api-kivy.uix.scrollview.html" that will cleaner and more maintainable mdlbl1.bind( width=lambda *args, **kwargs: mdlbl1.setter('text_size') (mdlbl1, (mdlbl1.width, None)), texture_size=lambda *args, **kwargs: mdlbl1.setter( 'height')(mdlbl1, mdlbl1.texture_size[1])) bl1.add_widget(mdlbl1) content_obj = ScrollView(do_scroll_x=False, do_scroll_y=True, size_hint=(1, None), scroll_type=['bars', 'content']) content_obj.add_widget(bl1) self._error_dialog = CU.show_input_dialog( title= f"{CU.tfs.dic['APP_NAME'].value} Encountered an Error & Needs to Shut Down", content_obj=content_obj, size_hint=(.8, .6), text_button_ok="Quit", text_button_cancel="Proceed @ Own Risk", ok_callback_set=lambda *args, **kwargs: (self.set_raise_or_pass(ExceptionManager.RAISE)), cancel_callback_set=lambda *args, **kwargs: (toast("Fingers crossed"), self.set_raise_or_pass(ExceptionManager.PASS))) return self._PASS_or_RAISE
def on_start(self): # As a proposal, the actual (default)value of the tf_workspace_path-param is copied to the clipboard: workspace_path_proposal = CU.tfs.dic['tf_workspace_path'].default_value pyperclip.copy(str(workspace_path_proposal)) # In case the user did configure a customized path, that path will be filled in: text = "" if (CU.tfs.dic['tf_workspace_path'].default_value == CU.tfs.dic['tf_workspace_path'].value ) else f"{CU.tfs.dic['tf_workspace_path'].value}" content_obj = BoxLayout(orientation='vertical', spacing="12dp", size_hint_y=None) # mdlbl1 = MDLabel(text=str(CU.tfs.dic['EXPLANATION_WORKSPACE_PATH'].value)) mdtf1 = MDTextField() mdtf1.text = text mdtf1.hint_text = f"{CU.tfs.dic['tf_workspace_path'].description}" mdtf1.helper_text = str(CU.tfs.dic['EXPLANATION_WORKSPACE_PATH'].value) mdtf1.helper_text_mode = "on_focus" # content_obj.add_widget(mdlbl1) content_obj.add_widget(mdtf1) CU.show_input_dialog( title= f"Enter Path to \"{CU.tfs.dic['WORKSPACE_NAME'].value}\"-Folder or to its Parent Folder", content_obj=content_obj, # hint_text=f"{CU.tfs.dic['tf_workspace_path'].description}", # size_hint=(.8, .4), text_button_ok="Load/Create", text_button_cancel="Cancel", ok_callback_set=lambda *args, **kwargs: (CU.tfs.dic['tf_workspace_path'].set_value(mdtf1.text), toast(str(CU.tfs.dic['tf_workspace_path'].value))), cancel_callback_set=lambda *args, **kwargs: toast( f"{CU.tfs.dic['WORKSPACE_NAME'].value} can still be changed anytime from the settings" ))