def toggle_connection(a, b, value=True):
    if value:
        Connection(a, b)
    else:
        EventHandler.trigger('DeleteConnection', None, {
            'value': value,
            'parents': [a, b]
        })
Пример #2
0
 def button_trigger(self):
     nombre = ''.join(self.input).upper()
     columns = []
     if self.status_precio:
         columns.append('precio')
     if self.status_isbn:
         columns.append('ISBN')
     selection = select_many(nombre, columns) if len(self.input) > 0 else []
     EventHandler.trigger('show_text', 'input', {'text': selection})
Пример #3
0
    def check(self):
        self.state = not self.state
        if self.state:
            self.image = self.img_true
        else:
            self.image = self.img_false

        EventHandler.trigger('check', self, {
            'name': self.nombre,
            'status': self.state
        })
Пример #4
0
 def button_trigger(self):
     nombre = ''.join(self.input).upper()
     txt = costo_por_clave('devir', nombre, 'nombre')
     if txt is None:
         txt = costo_por_clave('sd_dist', nombre, 'titulo')
     try:
         EventHandler.trigger('show_text', 'input', {
             'label': 'precio',
             'text': str(txt[0]),
             "show_price": '$'
         })
     except TypeError:
         text = probar_input(nombre, devolver_todos())
         EventHandler.trigger('show_text', 'input', {
             'label': 'precio',
             'text': str(text),
             "show_price": ''
         })
Пример #5
0
    def __init__(self, x, y, name, initial_state=False):
        super().__init__()
        self.x, self.y = x, y
        self.nombre = name
        self.img_true = self._crear(True)
        self.img_false = self._crear(False)
        self.state = initial_state
        if self.state:
            self.image = self.img_true
        else:
            self.image = self.img_false
        self.rect = self.image.get_rect(center=(self.x, self.y))

        Renderer.add_widget(self)
        WidgetHandler.add_widget(self)
        EventHandler.trigger('check', self, {
            'name': self.nombre,
            'status': self.state
        })
Пример #6
0
    def configure(opcion):
        key, value = None, None
        if opcion == 'Generar una lista de reproducción.':
            import_module('lib.write_and_play')
            # import_module('backend.rate')

        elif opcion == 'Actualizar la cantidad de canciones.':
            key = 'songs'

        elif opcion == 'Cambiar la ruta base de las canciones':
            print('La ruta actual es: {}'.format(config['root']))
            print('\nIngrese la nueva ruta')
            key = 'root'

        elif opcion == 'Cambiar los pesos de las canciones.':
            print('Ésta operación aun no se encuentra disponible')
            print(len(songlist))

        elif opcion == 'Restaurar los pesos de las canciones.':
            key = 'weights'
            import_module('backend.update_songlist')

        elif opcion == 'Actualizar la lista de canciones.':
            if config['weights']:
                print(
                    '\nAlerta: Esta acción restablecerá los pesos de las canciones'
                )
                import_module('backend.update_songlist')

        elif opcion == 'Conservar la lista de reproducción':
            key = 'keeppls'

        elif opcion == 'Cambiar el nombre por defecto de las listas':
            print('\nIngrese el nuevo nombre por defecto')
            key = 'default'

        elif opcion == 'Salir':
            EventHandler.trigger('salir', 'Window', {'texto': 'normal'})

        if key is not None and value is not None:
            config[key] = value
            guardar_json(config, 'config.json')
Пример #7
0
    def update(cls):
        cls.clock.tick(30)
        events = event.get([KEYDOWN, MOUSEBUTTONDOWN, QUIT])
        event.clear()
        for e in events:
            if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
                EventHandler.trigger('salir', 'engine', {'mensaje': 'normal'})

            elif e.type == KEYDOWN:
                if cls.active is not None:
                    cls.active.on_keydown(e.key)

            elif e.type == KEYUP:
                if cls.active is not None:
                    cls.active.on_keyup(e.key)

            elif e.type == MOUSEBUTTONDOWN:
                for wig in cls.contents:
                    wig.active = False
                widgets = [
                    i for i in cls.contents.sprites()
                    if i.rect.collidepoint(e.pos)
                ]
                for w in widgets:
                    w.on_mousebuttondown(e.button)
                    cls.active = w

            elif e.type == MOUSEBUTTONUP:
                pass

            elif e.tyoe == MOUSEMOTION:
                pass

        x, y = mouse.get_pos()
        for widget in cls.contents.sprites():
            if widget.rect.collidepoint((x, y)):
                widget.on_mouseover()

        cls.contents.update()
Пример #8
0
    def checkout(cls):
        v = 0
        now = datetime.now()
        with cls.open_sales_file(now, 'r') as file:
            for line in file.readlines():
                if 'Venta' in line:
                    v += 1

        with cls.open_sales_file(now, 'a') as file:
            file.write('Venta #' + str(v) + ':' + str(now.hour) + ':' +
                       str(now.minute) + ':' + str(now.second) + '\n')
            for item in cls.cart.items:
                file.write(item.item.name.title() + '.....$' +
                           str(item.item.price) + '\n')
            file.write('Total: $' + str(cls.subtotal_acumulado) + '\n\n')

        cls.cart.clear()
        cls.total_lbl.update_text('Total\n$0.00', just=1)
        cls.subtotal_acumulado = 0

        if cls.ultima_chk.state:
            cls.ultima_compra(now)
            EventHandler.trigger('salir', 'AreaVentas', {})
 def on_mouseup(self, event):
     self.rect.normalize()
     EventHandler.trigger('EndSelection', 'SelectionObject',
                          {'value': False})
     Renderer.del_widget(self)
     WidgetHandler.del_widget(self)
Пример #10
0
 def add(self, event):
     item = CartedItem(self, event.data['item'], self.y + self.h, 12)
     self.h += item.h
     self.items.append(item)
     EventHandler.trigger('Subtotal', item.name, {'price': item.item.price})
Пример #11
0
 def export(self):
     EventHandler.trigger('AddToCart', self.name, {'item': self.item})