Exemple #1
0
    def apply_rotate(self, image, type):
        'rotate an image it takes type temp or real'

        if type == 'temp':
            try:
                pil_image = PilImage.open(image)

                filename = os.path.basename(image)
                save_path = os.path.join(
                    os.path.join(self.data_dir, '.UniCloud/.effect_tmp'),
                    filename)
                pil_image.transpose(PilImage.ROTATE_90).save(save_path)

                self.rotate_modal.source_image = save_path
                self.rotate_modal.source_image_cls.reload()
            except Exception:
                fast_toast('Can\'t rotate this image type')

        else:
            shutil.copy(image, os.path.join(self.data_dir,
                                            '.UniCloud/.images'))
            real_image = self.get_real_image(image)

            thumbnail_path = self.make_thumbnails(real_image)

            #then load the image
            self.selected.source = thumbnail_path
            self.selected.image_cls.reload()
            self.edit_modal.dismiss()
Exemple #2
0
    def set_info(self, matrix):
        box_guy = Box_guy()
        year_display = self.ids.year_display
        level_display = self.ids.level_display
        department_display = self.ids.department_display
        falculty_display = self.ids.falculty_display
        position_display = self.ids.position_display

        try:
            matrix = int(matrix)
            year_level = self.get_year(matrix)
            year = str(year_level[1])
            level = str(year_level[0])

            department = str(self.get_department(matrix))
            falculty = str(self.get_falculty(matrix))
            position = str(self.get_position(matrix))

        except Exception as e:
            import traceback
            traceback.print_exc()
            year_display.text = ''
            level_display.text = ''
            department_display.text = ''
            falculty_display.text = ''
            position_display.text = ''
            from mahartstudios.android.notification import fast_toast
            fast_toast('Not found in database.')
        else:
            year_display.text = year
            level_display.text = level
            department_display.text = department
            falculty_display.text = falculty
            position_display.text = position
Exemple #3
0
 def downloading_done(self, filepath):
     print('Toast downloading done', filepath)
     fast_toast('{} donwloader'.format(filepath))
     if hasattr(self, 'downloading_btn'):
         download_page = screens.get_screen('download_page')
         grid = download_page.ids.downloading_grid
         grid.remove_widget(self.downloading_btn)
Exemple #4
0
 def download_later(self, data):
     if unicloud_store.exists(data['name']):
         print('Toast: already saved')
         fast_toast('Already saved')
     else:
         unicloud_store.put(data['name'], data=data)
         page = screens.get_screen('download_page')
         grid = page.ids.download_later
         grid.data.append({'material_data': data})
         grid.refresh_from_data()
Exemple #5
0
 def crop_manager(self):
     if self.selected is None:
         print('[Error  ]  No valid selection')
         fast_toast('No valid selection made')
     else:
         if self.selected.type == 'pdf_image':
             self.crop_modal.croper.source = self.get_real_image(
                 self.selected.source)
             self.crop_modal.open()
         else:
             print('Toast can\'t crop a custom page')
             fast_toast('Can\'t crop a custom page')
Exemple #6
0
    def rotate_manager(self):
        if self.selected is None:
            print('[Error  ]  No valid selection')
            fast_toast('No valid selection made')

        else:
            if self.selected.type == 'pdf_image':
                self.rotate_modal.open()
                real_image = self.get_real_image(self.selected.source)
                self.rotate_modal.source_image = real_image
                self.rotate_modal.source_image_cls.reload()
            else:
                print('Toast can\'t rotate a custom page')
                fast_toast('Can\'t rotate a custom page')
Exemple #7
0
    def load_project(self, project_name):
        project_dir = os.path.join(self.data_dir,
                                   'saved project/{}'.format(project_name))

        # try:
        self.create_temps_dir()
        self.handle_copy(os.path.join(project_dir, '.images'),
                         os.path.join(self.data_dir, '.UniCloud/.images'))
        self.handle_copy(os.path.join(project_dir, '.templates'),
                         os.path.join(self.data_dir, '.UniCloud/.templates'))
        self.handle_copy(os.path.join(project_dir, '.thumbnails'),
                         os.path.join(self.data_dir, '.UniCloud/.thumbnails'))
        # except Exception as e:
        # 	raise e
        # 	# print('an error occured 2',e)
        # 	self.create_temps_dir()
        # 	return

        if project_store.exists(project_name):
            saved_data = project_store.get(project_name)['saved_data']

            self.clear_all_widget()
            for data in saved_data:
                if data['type'] == 'pdf_image':
                    pdf = PdfImage(source=data['source'],
                                   tag_num=str(len(self.pics_grid.children)))
                else:
                    pdf = PdfImage(source=data['source'],
                                   tag_num=str(len(self.pics_grid.children)))
                    pdf.template_func = data['template_func']
                    pdf.data_list = data['data_list']
                    pdf.id_num = data['id_num']

                pdf.type = data['type']
                pdf.bind(state=self.selection_made)
                self.pics_grid.add_widget(pdf, index=1)

        else:
            print('Toast: cant find project')
            fast_toast('Can\'t find project')
            return

        self.project_name = project_name
        self.current = 'home'
Exemple #8
0
    def edit_manager(self):
        if self.selected is None:
            print('[Error  ]  No valid selection')
            fast_toast('No valid selection made')

        elif self.selected is not None and len(self.pics_grid.children) != 1:
            if self.selected.type == 'pdf_image':
                effect_list = self.get_effect_list(self.selected.source)

                if effect_list is not None:
                    self.edit_modal.open()
                    real_image = self.get_real_image(self.selected.source)

                    # add the original thumbnail
                    effect_list = [self.selected.source] + effect_list

                    self.edit_modal.source_image = real_image
                    self.edit_modal.effect_images = effect_list

                    # Then reload all the images
                    for button in self.edit_modal.edit_grid.children[:]:
                        button.image_cls.reload()
                else:
                    print('toast can\'t edit image the image type')
                    fast_toast('Can\'t edit image the image type')
            else:
                self.current = 'templates'
                screener = self.get_screen('templates')
                screener.currrent_working_data = self.selected.data_list
                screener.current = self.selected.template_func
        else:
            print('Toast noting to edit')
            fast_toast(msg='Noting to edit')
Exemple #9
0
    def delete_pic(self):

        if self.selected is None:
            print('[Error  ]  No valid selection')
            fast_toast('No valid selection made')

        elif self.selected is not None and len(self.pics_grid.children) != 1:
            if self.selected.type == 'pdf_image':

                index = self.pics_grid.children.index(self.selected)

                self.pics_grid.remove_widget(self.selected)

                #remove real image
                os.remove(self.get_real_image(self.selected.source))
                # remove thumbnail
                os.remove(self.selected.source)

                selected = self.pics_grid.children[index - 1]
                selected.state = 'down'
                if index == 1:
                    self.selected = None
            else:
                index = self.pics_grid.children.index(self.selected)
                self.pics_grid.remove_widget(self.selected)

                num = self.selected.id_num
                image_name = '.UniCloud/.templates/template{}.png'.format(num)
                os.remove(os.path.join(self.data_dir, image_name))

                selected = self.pics_grid.children[index - 1]
                selected.state = 'down'
                if index == 1:
                    self.selected = None

        else:
            print('Toast noting to delete')
            fast_toast('Noting to delete')
Exemple #10
0
 def apply_effect(self):
     if self.current_index != 0:
         root_cls.apply_effect(self.current_index)
     else:
         print('toast:  No Effect Selected')
         fast_toast('No effect selected')