def revert_changes(msg, history): history.project.file = history.file history.project.lastEdited = history.editDate history.project.image = history.image Container.save(history.project) msg.destroy() for li in self.historyItems: if li.dataObject.editDate >= history.editDate: Container.deleteObject(li.dataObject) li.destroy() photo = getdisplayableimage(history.image, (self.frm_preview.winfo_width(), self.frm_preview.winfo_height())) self.lbl_image.configure(image=photo) self.lbl_image.image = photo MessageModal( self, title=f'Success', message= f'Changes reverted to the following date:\n{history.editDate.strftime("%x - %X")}!', messageType='info') getattr( self, 'lbl_' + CollaborationWindow.lblSettings[2]['prop'] )['text'] = history.editDate.strftime( "%d/%m/%Y" ) if datetime.datetime.now( ).strftime("%x") != history.editDate.strftime( "%x") else 'Today at - ' + history.editDate.strftime("%X")
def set_image(self, image): # calculate actual size actual_size = self.size - self.imgPadding # Configure image & draw image if isinstance(image, str): # construct a cache key cache_key = image + f'_{self.size}_{self.imgPadding}' # attempt to retrieve image from cache self._image = CacheManager.get_cached_image(cache_key) # repair image if self._image == None: # assign image self._image = CacheManager.get_or_add_if_absent( cache_key, ImageTk.PhotoImage( Img.open(image).resize((actual_size, actual_size)))) else: self._image = getdisplayableimage(image, (actual_size, actual_size)) # display image if hasattr(self, 'img_image'): self.delete(self.img_image) self.img_image = self.create_image(self.size / 2, self.size / 2, image=self._image)
def resize_image(event, label): if self.session.project.image != None: photo = getdisplayableimage(self.session.project.image, (self.frm_preview.winfo_width(), self.frm_preview.winfo_height())) label.configure(image=photo) label.image = photo
def configure_settings(self): # get_label = lambda prop: getattr(self, f'lbl_{prop}') # change label get_label(CollaborationWindow.lblSettings[0] ['prop'])['text'] = self.session.title get_label( CollaborationWindow.lblSettings[1]['prop'] )['text'] = self.session.creationDate.strftime( "%d/%m/%Y" ) if datetime.datetime.now( ).strftime("%x") != self.session.creationDate.strftime( "%x") else 'Today at - ' + self.session.creationDate.strftime("%X") get_label( CollaborationWindow.lblSettings[2]['prop'] )['text'] = self.session.project.lastEdited.strftime( "%d/%m/%Y" ) if datetime.datetime.now( ).strftime("%x") != self.session.project.lastEdited.strftime( "%x" ) else 'Today at - ' + self.session.project.lastEdited.strftime("%X") get_label(CollaborationWindow.lblSettings[3]['prop'])['text'] = str( Container.filter(Collaboration, Collaboration.sessionId == self.session.id).count() + 1) # change image if self.session.project.image != None: photo = getdisplayableimage(self.session.project.image, (self.frm_preview.winfo_width(), self.frm_preview.winfo_height())) self.lbl_image.configure(image=photo) self.lbl_image.image = photo # fill self.fill_collaboration() self.fill_members()
def configure_settings(self): def get_label(prop): return getattr(self, f'lbl_{prop}') # changing texts get_label( ProjectWindow.lblSettings[0]['prop'])['text'] = self.project.title get_label( ProjectWindow.lblSettings[1]['prop'] )['text'] = self.project.creationDate.strftime( "%d/%m/%Y" ) if datetime.datetime.now( ).strftime("%x") != self.project.creationDate.strftime( "%x") else 'Today at - ' + self.project.creationDate.strftime("%X") get_label( ProjectWindow.lblSettings[2]['prop'] )['text'] = self.project.lastEdited.strftime( "%d/%m/%Y" ) if datetime.datetime.now( ).strftime("%x") != self.project.lastEdited.strftime( "%x") else 'Today at - ' + self.project.lastEdited.strftime("%X") # update image if self.project.image == None: return # proceed photo = getdisplayableimage( self.project.image, (self.frm_preview.winfo_width(), self.frm_preview.winfo_height())) self.lbl_image.configure(image=photo) self.lbl_image.image = photo
def set_image(self, img): setattr(self, 'image', img) if img != None: photo = getdisplayableimage(img, (160, 150)) self.lbl_image.configure(image=photo) self.lbl_image.image = photo self.lbl_image.pack()
def set_image(self, li, image): if image != None: photo = getdisplayableimage(image,(li.winfo_width(),205)) li.lbl_image.configure(image=photo) li.lbl_image.image = photo