def delete_link(self): """Remove the link from the layout""" self.link_layout.links_list.remove_widget(self) self.link_layout.links.remove(self.text) utils.update_data() utils.data[self.link_layout.parent_screen. name]['links'] = self.link_layout.links utils.save_project_data( utils.data[self.link_layout.parent_screen.name], f"{utils.data[self.link_layout.parent_screen.name]['proj_path']}/project_data.json" )
def change_project_path(self): root = tkinter.Tk() root.withdraw() selected_folder = tkinter.filedialog.askdirectory() self.update_data() self.project_path_label.text = selected_folder self.project_path = selected_folder self.data["proj_path"] = selected_folder utils.save_project_data(self.data, f"{self.project_path}/project_data.json") self.update_data() self.data = utils.data
def update(self, amount): self.update_data() self.data = utils.data[self.parent_screen.name] self.progress_bar.value += amount self.progress_label.text = f"[b]Progress: {self.progress_bar.value}%[/b]" # most recent date where progress was made recent_date = self.data["recent_progress"] today = date.today().strftime("%m/%d/%y%y") # only update the recent work date if it is different than today's date if not today == recent_date: self.data["recent_progress"] = today self.recent_label.text = f"[b]Recent Progress: {self.data['recent_progress']}, Progress made: " \ f"{self.progress_bar.value - self.data['recent_amount']}%[/b]" # value - amount because we want the difference in the progressbar.value and our # recent progress to make it not 0 self.data["recent_amount"] = self.progress_bar.value - amount self.recent_label.text = f"[b]Recent Progress: {self.data['recent_progress']}, Progress made: " \ f"{self.progress_bar.value - self.data['recent_amount']}%[/b]" self.data["progress"] = self.progress_bar.value # if progress = 100%, update the completion field to todays date because the project is completed, # only works with default 'In progress' tag if self.progress_bar.value == 100.0 and self.data[ "completion"] == "In progress": self.complete_field.text = today self.data["completion"] = today else: self.complete_field.text = "In progress" self.data["completion"] = "In progress" # write changes to the json file utils.save_project_data(self.data, f"{self.project_path}/project_data.json") self.update_data() # update the progress information in the ProjectCard for this project for project_card in utils.project_cards: if project_card.project == self.parent_screen.name: project_card.home_progress_bar.value = self.progress_bar.value project_card.home_progress_label.text = f"{self.progress_bar.value}%"
def add_pressed(self): """ Called when the plus button is pressed, if the link is valid add it :return: None """ new_link = self.link_field.text self.links_list.add_widget(LinkIconListItem(self, text=new_link)) self.link_field.text = "" self.add_link_button.disabled = True self.link_field.focus = False self.link_field.helper_text = "Please enter a valid url" self.links.append(new_link) utils.update_data() utils.data[self.parent_screen.name]["links"] = self.links utils.save_project_data( utils.data[self.parent_screen.name], f"{utils.data[self.parent_screen.name]['proj_path']}/project_data.json" )
def grab_text_title(self, inst): """ Grab the altered text from the edited title, update and save that data method called when the save button is pressed, saves the title text to project json key and sets the title :param inst: button instance :return: None """ # this loops through all the children in the dialog_title dialog box and if it is the text field, # set the title to the shortened (if needed) text field text for obj in self.dialog_title.content_cls.children: if isinstance(obj, MDTextField): if obj.text != "" and obj.text != self.title.text: self.title.text = self.shorten_text(obj.text, 31) self.data["title"] = obj.text self.dialog_title.title = f"[color=%s]Change project title, Current title: '{self.title.text}'[/color]" \ % get_hex_from_color(App.get_running_app().theme_cls.text_color) self.dialog_title.dismiss() # updates data with new title utils.save_project_data(self.data, f"{self.data['proj_path']}/project_data.json") utils.update_data() self.data = utils.data[self.parent_screen.name] # updates the title of the ProjectCard if the project cards name/project StringProperty match this page's parent # _screen's name for project_card in utils.project_cards: if project_card.project == self.parent_screen.name: project_card.home_project_title.text = project_card.home_page.shorten_title( self.title.text) # updates the project title for this project in the navigation drawer menu for project in utils.menu_projects: if project.next_win == self.parent_screen.name: utils.menu_projects[utils.menu_projects.index( project)].text = self.title.text
def grab_text_subtitle(self, inst): """ Grab the altered text from the edited subtitle, update and save that data method called when the save button is pressed, saves the subtitle text to project json key and sets the subtitle :param inst: button instance :return: None """ # this loops through all the children in the dialog_subtitle dialog box and if it is the text field, # set the subtitle to the shortened (if needed) text field text for obj in self.dialog_subtitle.content_cls.children: if isinstance(obj, MDTextField): if obj.text != "" and obj.text != self.subtitle.text: self.subtitle.text = self.shorten_text(obj.text, 45) self.data["subtitle"] = obj.text self.dialog_subtitle.title = f"[color=%s]Change project subtitle, Current subtitle: '{self.data['subtitle']}'" \ f"[/color]" % get_hex_from_color(App.get_running_app().theme_cls.text_color) self.dialog_subtitle.dismiss() # update data with new subtitle utils.save_project_data(self.data, f"{self.data['proj_path']}/project_data.json") utils.update_data() self.data = utils.data[self.parent_screen.name]
def save_completion(self): self.data["completion"] = self.complete_field.text utils.save_project_data(self.data, f"{self.project_path}/project_data.json") self.update_data()
def save_start(self): self.data["start_date"] = self.save_field.text utils.save_project_data(self.data, f"{self.project_path}/project_data.json") self.update_data()