Esempio n. 1
0
    def _on_click(self, instance):
        """Pre-dismiss method.
        Gathers widget values. Checks the required fields.
        Ignores it all if the "Cancel" was pressed.
        """
        instance_id = instance.text
        if instance_id != self.BUTTON_CANCEL:
            self.values = {}
            required_errors = []
            for widget in self._ui_form_container.walk(restrict=True):
                t_id = widget.__class__
                if t_id is not None:
                    if isinstance(widget, TextInput):
                        t_value = widget.text
                        if self.required_fields and\
                                t_id in self.required_fields.keys()\
                                and not t_value:
                            required_errors.append(self.required_fields[t_id])
                    elif isinstance(widget, Switch)\
                            or isinstance(widget, CheckBox):
                        t_value = widget.active
                    elif isinstance(widget, Slider):
                        t_value = widget.value
                    else:
                        t_value = 'Not supported: ' + widget.__class__.__name__

                    self.values[t_id] = t_value

            if required_errors:
                Error(text='Following fields are required:\n' +
                      ', '.join(required_errors))
                return

        super(Form, self)._on_click(instance)
Esempio n. 2
0
    def remove_file(self, archivo, *args):

        origen = os.path.abspath(archivo)

        def remove(origen, *args):
            try:
                os.remove(origen)
            except IOError as e:
                Error(text='Don`t panic!. ' + str(e.args) + origen,
                      title='Message Exception')

        if self.path:
            try:
                Clock.schedule_once(partial(
                    remove,
                    origen,
                ), -1)
            except Exception as e:
                Error(text='Don`t panic! ' + str(e.args),
                      title='Message Exception')
        else:
            Error(text='Do not exist directory. ' + str(self.path),
                  title='Message Exception')
Esempio n. 3
0
    def move_box(self, box, *args):
        video = os.path.basename(box.movie)
        new_video_path = os.path.join(self.path, video)
        caja = Box(movie=new_video_path)

        def mueve(origen, destino, *args):
            try:
                shutil.move(origen, destino)
            except IOError as e:
                Error(text='Don`t panic!. ' + str(e.args) + origen)

        try:
            Clock.schedule_once(partial(mueve, box.movie, caja.movie), -1)
            Clock.schedule_once(partial(mueve, box.picture, caja.picture), -1)
        except Exception as e:
            Error(text='Don`t panic!. ' + str(e.args))
Esempio n. 4
0
    def move_file(self, archivo, *args):

        origen = os.path.abspath(archivo)
        filename = os.path.basename(origen)

        def mueve(origen, destino, *args):
            try:
                shutil.move(origen, destino)
            except IOError as e:
                Error(text='Don`t panic!. ' + str(e.args) + origen)

        if self.path:
            try:
                Clock.schedule_once(
                    partial(mueve, origen, join(self.path, filename)), -1)
            except Exception as e:
                Error(text='Don`t panic!. ' + str(e.args))
Esempio n. 5
0
    def copy_file(self, archivo, *args):

        origen = os.path.abspath(archivo)
        filename = os.path.basename(origen)  #origen.split('\\')[-1]

        def copia(origen, destino, *args):
            try:
                shutil.copy(origen, destino)
            except IOError as e:
                Error(text='Don`t panic!. ' + str(e.args) + origen)

        if self.path:
            try:
                Clock.schedule_once(
                    partial(copia, origen, join(self.path, filename)), -1)
            except Exception as e:
                Error(text='Don`t panic!. ' + str(e.args))
Esempio n. 6
0
 def mueve(origen, destino, *args):
     try:
         shutil.move(origen, destino)
     except IOError as e:
         Error(text='Don`t panic!. ' + str(e.args) + origen)
Esempio n. 7
0
 def remove(origen, *args):
     try:
         os.remove(origen)
     except IOError as e:
         Error(text='Don`t panic!. ' + str(e.args) + origen,
               title='Message Exception')
Esempio n. 8
0
 def copia(origen, destino, *args):
     try:
         shutil.copy(origen, destino)
     except IOError as e:
         Error(text='Don`t panic!. ' + str(e.args) + origen)