def restore(self, **kwargs): tipo = kwargs.get('tipo', '') if tipo == '': self.corda_from = 31 self.corda_to = 65535 self.sup_from = 31 self.sup_to = 65535 dic_restore = { 'sup_from': 31, 'sup_to': 65535, 'corda_from': 31, 'corda_to': 65535 } elif tipo == 'sup': self.sup_from = 31 self.sup_to = 65535 dic_restore = {'sup_from': 31, 'sup_to': 65535} elif tipo == 'corda': self.corda_from = 31 self.corda_to = 65535 dic_restore = {'corda_from': 31, 'corda_to': 65535} API_DB.update_range_freq(**dic_restore)
def __init__(self, **kwargs): self.pic_bytes = kwargs.get('pic_bytes', None) self.ImageObject = kwargs.get('ImageObject', None) self.pic_resolution = kwargs.get('pic_resolution', (100, 100)) self.pic_id = kwargs.get('pic_id', '') self.pic_name = kwargs.get('pic_name', '') self.pic_type = kwargs.get('pic_type') if self.pic_bytes is None and self.ImageObject is None and self.pic_name is not '': if self.pic_type == 'gui': dic_pic = API_DB.search_gui_pic(**kwargs) self.pic_bytes = dic_pic['pic_bytes'] if self.pic_bytes is None: self.no_pic() self.pic_name = dic_pic['pic_name'] self.pic_id = dic_pic['pic_id'] # Objeto Image instanciado: self.pic_file = PIL.Image.open(self.pic_bytes).resize( self.pic_resolution, PIL.Image.ANTIALIAS) self.PhotoImage = PIL.ImageTk.PhotoImage(self.pic_file) self.photo = self.PhotoImage else: try: self.pic_file = PIL.Image.open(self.pic_bytes).resize( self.pic_resolution, PIL.Image.ANTIALIAS) self.PhotoImage = PIL.ImageTk.PhotoImage(self.pic_file) self.photo = self.PhotoImage except Exception as Expt: # print(Expt) self.no_pic()
def loadAllExp(self, **kwargs): tipo_exp = kwargs.get('tipo', '') lst_dics = API_DB.loadAllExp(tipo=tipo_exp) lst_return = my_list() for elem in lst_dics: exp = PadraoExp(**elem) lst_return.append(exp) return lst_return
def loadAllPics(self, **kwargs): pattern = kwargs.get('pattern', '') if pattern == '': lst_pic = API_DB.extract_pictures() lst_return = my_list() for elem in lst_pic: photo = UI_app.wd_Image2(None, **elem) padrao = UI_app.PadraoExp(pic_id=photo.pic_id, picture=photo, freq=photo.pic_name) lst_return.append(padrao) return lst_return
def update(self, **kwargs): self.freq = kwargs.get('freq', self.freq) self.comprimento = kwargs.get('comprimento', self.comprimento) self.massa = kwargs.get('massa', self.massa) self.densidade_linear = kwargs.get('densidade', self.densidade_linear) kwargs['id'] = self.id picture_file = kwargs.get('PhotoImage', None) if picture_file is not None: stream_bytes = io.BytesIO() PIC_NAME = picture_file.filename[:-4] PIC_FORMAT = picture_file.format picture_file.save(stream_bytes, format=PIC_FORMAT) self.pic_bytes = stream_bytes self.PhotoImage = my_PhotoImage( pic_bytes=self.pic_bytes).PhotoImage self.photo = self.PhotoImage PIC_BYTES = stream_bytes.getvalue() kwargs['pic_name'] = PIC_NAME kwargs['pic_format'] = PIC_FORMAT kwargs['pic_bytes'] = PIC_BYTES kwargs['pic_id'] = self.pic_id API_DB.update_exp(**kwargs)
def load(self): kwargs = API_DB.loadFreqRange() self.corda_from = kwargs.get('corda_from', self.corda_from) self.corda_to = kwargs.get('corda_to', self.corda_to) self.sup_from = kwargs.get('sup_from', self.sup_from) self.sup_to = kwargs.get('sup_to', self.sup_to)
def update(self, **kwargs): self.corda_from = kwargs.get('corda_from', self.corda_from) self.corda_to = kwargs.get('corda_to', self.corda_to) self.sup_from = kwargs.get('sup_from', self.sup_from) self.sup_from = kwargs.get('sup_to', self.sup_to) API_DB.update_range_freq(**kwargs)