Example #1
0
    def build(self):
        #elementos home

        #boton de nueva materia
        BtnNuevaMateria = Button(text="+",size_hint=(None,None),background_color=(1, .3, .4,.50), background_normal= '',font_size=40)
        #llamado popup para agregar materias           
        BtnNuevaMateria.bind(on_release=popup_materia)
        #boton ir a libreria
        BtnAbrirLibreria = Button(text="Libreria",size_hint=(None,None),background_color=(0, .8, .0,.50), background_normal= '',font_size=27)
        #bind a libreria 
        BtnAbrirLibreria.bind(on_release=ir_a_libreria)

        #agregado de elementos a layout home
        #home.add_widget(BtnAbrirLibreria)

        home.add_widget(BtnNuevaMateria)
        
        
        #elementos libreria
        #boton volver a home
        #BtnAbrirHome = Button(text="Home",size_hint=(None,None),background_color=(0, .4, .8,.50), background_normal= '',font_size=27)
        #bind  home
        #BtnAbrirHome.bind(on_release=ir_a_home)

        #agregado elementos alayout libreria
        #barra_lateral.add_widget(BtnAbrirHome)

        #libreria.add_widget(barra_lateral)

        #elementos de barra lateral

        #agregado del estante



        libreria.add_widget(estante)

        #agregamos layouts a los screens
        
        #screen2.add_widget(libreria)
        screen.add_widget(home)
        
        

        #agregamos screns al manager
        sm.add_widget(screen)
        sm.add_widget(screen2)



        w = EffectWidget()
        w.add_widget(sm)

        principal.add_widget(w)
        principal.add_widget(libreria)


        return principal
Example #2
0
 def on_enter(self, *args):
     self.layout = RelativeLayout()
     self.carousel = MenuCarousel(direction='right')
     w = EffectWidget()
     bg = Image(source='data/images/animation.zip', allow_stretch=True, keep_ratio=False)
     w.add_widget(bg)
     w.effects = [FXAAEffect()]
     self.carousel.add_widget(self.menu())
     self.carousel.add_widget(self.new_game_menu())
     self.layout.add_widget(w)
     self.layout.add_widget(self.carousel)
     self.add_widget(self.layout)
     Window.bind(mouse_pos=self.on_mouse_pos)
Example #3
0
 def __init__(self, **kwargs):
     super(RoundedShadowButton, self).__init__(**kwargs)
     if kwargs.has_key('shadow_color'):
         self.shadow_color = kwargs['shadow_color']
     else:
         self.shadow_color = (1, 1, 1, 0)
     self.bind(size=self.update_rect)
     self.effect = EffectWidget(size_hint=[1, 1])
     self.button = RoundedFlatButton(**kwargs)
     self.button.pos = (SHADOW_RADIUS / divider, SHADOW_RADIUS / divider)
     self.button.size_hint = [None, None]
     self.effect.add_widget(self.button)
     self.effect.effects = [DropShadowEffect(radius=SHADOW_RADIUS / divider, tint=[0, 0, 0, 0.8])]
     self.add_widget(self.effect)
Example #4
0
class Dmd(MpfWidget, Widget):
    widget_type_name = 'DMD'

    def __init__(self, mc, config, key=None, **kwargs):
        super().__init__(mc=mc, config=config, key=key)

        self.source = self.mc.displays[self.config['source_display']]

        self.dmd_frame = EffectWidget()

        if self.config['dot_filter']:
            self.dmd_frame.effects = [
                DmdLook(width=self.width,
                        height=self.height,
                        dmd_width=self.source.width,
                        blur=self.config['blur'],
                        pixel_size=self.config['pixel_size'],
                        bg_color=self.config['bg_color'])]

        self.add_widget(self.dmd_frame)

        self.dmd_frame.add_widget(DmdSource(mc, config, key))

        self.dmd_frame.size = self.size

    def __repr__(self):  # pragma: no cover
        try:
            return '<DMD size={}, source_size={}>'.format(
                    self.size, self.source.size)
        except AttributeError:
            return '<DMD size={}, source_size=(none)>'.format(
                    self.size)

    def on_pos(self, *args):
        self.dmd_frame.pos = set_position(self.parent.width,
                                  self.parent.height,
                                  self.width, self.height,
                                  self.config['x'],
                                  self.config['y'],
                                  self.config['anchor_x'],
                                  self.config['anchor_y'],
                                  self.config['adjust_top'],
                                  self.config['adjust_right'],
                                  self.config['adjust_bottom'],
                                  self.config['adjust_left'])
Example #5
0
 def build(self):
     b = BoxLayout()
     b.add_widget(Button())
     return BoxLayoutKv()
     b = BoxLayout(orientation='vertical')
     b.add_widget(
         AnchorLagout(Button(size_hint=(.9, .2), pos_hint={'right': 1})))
     b.add_widget(Button())
     return b
     return Button1()
     return Popup(title='Test popup',
                  content=Label(text='Hello world'),
                  size_hint=(None, None),
                  size=(400, 400))
     return FileChooserListView()
     w = EffectWidget()
     w.add_widget(Button(text='Hello!'))
     w.effects = [InvertEffect(), HorizontalBlurEffect(size=2.0)]
Example #6
0
    def _setup_fbo(self, element, settings):
        """Setup FBO for a display."""
        source = self.machine.displays[element]

        # put the widget canvas on a Fbo
        texture = Texture.create(size=source.size, colorfmt='rgb')
        fbo = Fbo(size=source.size, texture=texture)

        effect_widget = EffectWidget()

        effect_list = list()

        effect_widget.effects = effect_list
        effect_widget.size = source.size

        fbo.add(effect_widget.canvas)

        return [fbo, effect_widget, source, settings, True]
Example #7
0
    def __init__(self, mc: "MpfMc", name: str, config: dict) -> None:
        """Initialise DMD."""

        self.mc = mc
        self.name = name

        self.mc.log.info('Initializing DMD')

        self.config = self._get_validated_config(config)

        self.source = self.mc.displays[self.config['source_display']]
        self.prev_data = None
        self._dirty = True

        # put the widget canvas on a Fbo
        texture = Texture.create(size=self.source.size, colorfmt='rgb')
        self.fbo = Fbo(size=self.source.size, texture=texture)

        self.effect_widget = EffectWidget()

        effect_list = list()
        effect_list.append(FlipVerticalEffect())

        if self.config['brightness'] != 1.0:
            if not 0.0 <= self.config['brightness'] <= 1.0:
                raise ValueError("DMD brightness value should be between 0.0 "
                                 "and 1.0. Yours is {}".format(
                                     self.config['brightness']))

            effect_list.append(GainEffect(gain=self.config['brightness']))

        if self.config['gamma'] != 1.0:
            effect_list.append(GammaEffect(gamma=self.config['gamma']))

        self.effect_widget.effects = effect_list
        self.effect_widget.size = self.source.size

        self.fbo.add(self.effect_widget.canvas)

        with self.source.canvas:
            self.callback = Callback(self._trigger_rendering)

        self._set_dmd_fps()
Example #8
0
    def btnPress(self, *args):
        self.settings.counter += 1
        # всплывает попап с отмазкой
        excuse = self.excuses[randint(0, len(self.excuses) - 1)]
        # textLabel = Label(text=markup_text(size=80, color='000000', text=exсuse, bold=False), markup=True, size_hint=(0.8, 0.8), valign='top')
        # textLabel.bind(size=textLabel.setter('text_size'))
        # popup = ModalView(title="ОТМАЗКА НА СЕГОДНЯ",
        #               title_color=(0x75 / 255.0, 0x86 / 255.0, 0x8F / 255.0, 1),  # 75868F
        #               title_size=46 / divider,
        #               #background='white',
        #               background_color=(1, 1, 1, 0),
        #               separator_color=(1, 1, 1, 1),
        #               content=textLabel,
        #               size_hint=(.7, .5))

        popup = ModalView(size_hint=[0.8, 0.6])
        effectWidget = EffectWidget(size_hint=[1.2, 1.2])
        effectLayout = AnchorLayout(anchor_x='center', anchor_y='center', size_hint=[1, 1])
        popupWidget = RoundedWidget(size_hint=[0.9, 0.9], background_color=(1, 1, 1, 1), shadow_color=(70, 70, 70, 1))
        widgetLayout = BoxLayout(orientation='vertical')

        def popupUpdate(instance, *args):
            x, y = instance.size
            widgetLayout.size = (x - 100, y - 100)
            w, h = instance.pos
            widgetLayout.pos = (w + 50, h + 50)

        popupWidget.bind(size=popupUpdate, pos=popupUpdate)  # popupButton.setter('text_size'))
        captionLabel = Label(text=markup_text(size=46, color='75868F', text='ОТМАЗКА НА СЕГОДНЯ', font='Roboto-Black'), markup=True, size_hint=(1, 0.35), valign='top', halign='left')
        captionLabel.bind(size=captionLabel.setter('text_size'))
        textLabel = Button(text=markup_text(size=80, color='000000', text=excuse, bold=False), markup=True, size_hint=(1, 0.65), valign='top', halign='left', background_color=(0, 0, 0, 0), on_press=popup.dismiss)
        textLabel.bind(size=textLabel.setter('text_size'))
        widgetLayout.add_widget(captionLabel)
        widgetLayout.add_widget(textLabel)
        popupWidget.add_widget(widgetLayout)
        effectLayout.add_widget(popupWidget)
        effectWidget.add_widget(effectLayout)
        effectWidget.effects = [DropShadowEffect(radius=SHADOW_RADIUS / divider, tint=[0, 0, 0, 0.7])]
        popup.add_widget(effectWidget)
        popup.background_color = (0.2, 0.2, 0.2, 0.6)

        popup.open()
Example #9
0
    def __init__(self, mc, config, key=None, **kwargs):
        super().__init__(mc=mc, config=config, key=key)

        self.source = self.mc.displays[self.config['source_display']]

        self.dmd_frame = EffectWidget()

        if self.config['dot_filter']:
            self.dmd_frame.effects = [
                DmdLook(width=self.width,
                        height=self.height,
                        dmd_width=self.source.width,
                        blur=self.config['blur'],
                        pixel_size=self.config['pixel_size'],
                        bg_color=self.config['bg_color'])]

        self.add_widget(self.dmd_frame)

        self.dmd_frame.add_widget(DmdSource(mc, config, key))

        self.dmd_frame.size = self.size
Example #10
0
    def __init__(self, mc, config, key=None, **kwargs):
        super().__init__(mc=mc, config=config, key=key)

        self.source = self.mc.displays[self.config['source_display']]

        stencil = StencilView(size_hint=(None, None),
                              size=(self.source.config['width'],
                                    self.source.config['height']))

        # Add the effects to make this look like a DMD
        effect_list = list()

        if 'luminosity' in self.config:
            effect_list.append(Monochrome(r=self.config['luminosity'][0],
                                          g=self.config['luminosity'][1],
                                          b=self.config['luminosity'][2]))

        if self.config['shades']:
            effect_list.append(Reduce(shades=self.config['shades']))

        if self.config['pixel_color']:
            effect_list.append(Colorize(r=self.config['pixel_color'][0],
                                        g=self.config['pixel_color'][1],
                                        b=self.config['pixel_color'][2]))

        if self.config['gain'] != 1.0:
            effect_list.append(Gain(gain=self.config['gain']))

        effect = EffectWidget()
        effect.effects = effect_list

        stencil.add_widget(effect)

        self.add_widget(stencil)

        try:
            effect.add_widget(self.source)
        except WidgetException:
            self.source.parent = None
            effect.add_widget(self.source)

        effect.size = (self.config['width'], self.config['height'])

        effect.texture.mag_filter = 'nearest'
        effect.texture.min_filter = 'nearest'

        self.scale = min(self.width / self.source.width,
                         self.height / self.source.height)

        self.pos = (0, 0)
Example #11
0
    def _setup_fbo(self, element, settings):
        """Setup FBO for a display."""
        if element not in self.machine.displays:
            raise AssertionError(
                "Display {} not found. Please create it to use display_light_player."
                .format(element))
        source = self.machine.displays[element]

        # put the widget canvas on a Fbo
        texture = Texture.create(size=source.size, colorfmt='rgb')
        fbo = Fbo(size=source.size, texture=texture)

        effect_widget = EffectWidget()

        effect_list = list()

        effect_widget.effects = effect_list
        effect_widget.size = source.size

        fbo.add(effect_widget.canvas)

        return [fbo, effect_widget, source, settings, True]
Example #12
0
    def __init__(self, start_pos, end_pos):
        xpos = start_pos[0]
        tlx = Settings.GAME_ZONE_TOPLEFT_CORNER[0]

        if xpos < tlx + 106:
            self.type = 'triangle'
        elif xpos < tlx + 106 * 2:
            self.type = 'box'
        elif xpos < tlx + 106 * 3:
            self.type = 'circle'
        else:
            raise Exception('Wrong start pos %s' % xpos)

        w = EffectWidget(
            size = (45, 45),
            background_color = (0,0,0,0),
            pos = start_pos
        )
        w.effects = [effects_map.get(self.type)()]

        self.widget = w

        self.speed = 5
        self.dir_vector = (Vector(*end_pos) - Vector(*start_pos)).normalize()
Example #13
0
    def __init__(self, mc, name, config):
        """Initialise DMD."""

        self.mc = mc
        self.name = name

        self.mc.log.info('Initializing Physical DMD')

        self.config = self._get_validated_config(config)

        self.source = self.mc.displays[self.config['source_display']]
        self.prev_data = None

        # put the widget canvas on a Fbo
        texture = Texture.create(size=self.source.size, colorfmt='rgb')
        self.fbo = Fbo(size=self.source.size, texture=texture)

        self.effect_widget = EffectWidget()

        effect_list = list()
        effect_list.append(FlipVertical())

        if self.config['brightness'] != 1.0:
            if not 0.0 <= self.config['brightness'] <= 1.0:
                raise ValueError("DMD brightness value should be between 0.0 "
                                 "and 1.0. Yours is {}".format(
                                     self.config['brightness']))

            effect_list.append(Gain(gain=self.config['brightness']))

        self.effect_widget.effects = effect_list
        self.effect_widget.size = self.source.size

        self.fbo.add(self.effect_widget.canvas)

        self._set_dmd_fps()
Example #14
0
    def __init__(self, mc: "MpfMc", config: dict, key: Optional[str]=None, **kwargs) -> None:
        del kwargs
        self.display = None

        super().__init__(mc=mc, config=config, key=key)

        self.display = self.mc.displays[self.config['source_display']]
        self.effects = EffectWidget(pos=self.pos, size_hint=(1, 1))
        self.effects.key = None

        if 'effects' in self.config:
            self._add_effects(self.config['effects'])

        # Establish link between display and this display widget
        self.add_widget(self.effects)
        self.display_output = DisplayOutput(self.effects, self.display)
Example #15
0
    def _update_electrodes(self):
        self.clear_widgets()

        # Create LED layout
        led_layer = BoxLayout(orientation='horizontal', size=self.size, pos=self.pos)
        # Create diffuser on top of LED layout
        led_diffuser = EffectWidget()
        led_diffuser.effects = []
        if self.diffuser_width >= 0:
            led_diffuser.effects.append(HorizontalBlurEffect(size=self.diffuser_width))
        led_diffuser.add_widget(led_layer)
        self.add_widget(led_diffuser)

        # Fix ids reference since kivy doesn't have built-in mechanics to do it
        self.ids['led_diffuser'] = weakref.proxy(led_diffuser)
        led_diffuser.ids['leds'] = weakref.proxy(led_layer)

        if self.slider_layout == 'diva':
            self.electrodes = 32
            self.leds = 32
            electrode_layer = BoxLayout(orientation='horizontal', size=self.size, pos=self.pos)
            for i in range(self.electrodes):
                electrode_layer.add_widget(ElectrodeWidget(electrode_index=i, top_slider_object=self))
            for i in range(self.leds):
                led_layer.add_widget(LEDWidget(led_index=i, top_slider_object=self))
            self.add_widget(electrode_layer)
            self.ids['electrodes'] = weakref.proxy(electrode_layer)
        elif self.slider_layout == 'chu':
            self.electrodes = 32
            self.leds = 31
            electrode_layer = GridLayout(rows=2)
            for i in range(self.electrodes):
                # Calculate the actual ID according to widget insertion sequence
                r = i // 16
                c = 15 - (i % 16)
                electrode_index = c * 2 + r
                electrode_layer.add_widget(ElectrodeWidget(electrode_index=electrode_index, top_slider_object=self))
            for i in range(self.leds):
                if i % 2 == 1:
                    # Partition
                    led_layer.add_widget(LEDWidget(led_index=self.leds-1-i, width=3, size_hint=(None, 1.0), top_slider_object=self))
                else:
                    # Panel
                    led_layer.add_widget(LEDWidget(led_index=self.leds-1-i, top_slider_object=self))
            self.add_widget(electrode_layer)
            self.ids['electrodes'] = weakref.proxy(electrode_layer)
Example #16
0
class DmdBase(object):
    """Base class for DMD devices."""

    dmd_name_string = 'DMD'

    def __init__(self, mc: "MpfMc", name: str, config: dict) -> None:
        """Initialise DMD."""

        self.mc = mc
        self.name = name

        self.mc.log.info('Initializing DMD')

        self.config = self._get_validated_config(config)

        self.source = self.mc.displays[self.config['source_display']]
        self.prev_data = None

        # put the widget canvas on a Fbo
        texture = Texture.create(size=self.source.size, colorfmt='rgb')
        self.fbo = Fbo(size=self.source.size, texture=texture)

        self.effect_widget = EffectWidget()

        effect_list = list()
        effect_list.append(FlipVerticalEffect())

        if self.config['brightness'] != 1.0:
            if not 0.0 <= self.config['brightness'] <= 1.0:
                raise ValueError("DMD brightness value should be between 0.0 "
                                 "and 1.0. Yours is {}".format(
                                     self.config['brightness']))

            effect_list.append(GainEffect(gain=self.config['brightness']))

        if self.config['gamma'] != 1.0:
            effect_list.append(GammaEffect(gamma=self.config['gamma']))

        self.effect_widget.effects = effect_list
        self.effect_widget.size = self.source.size

        self.fbo.add(self.effect_widget.canvas)

        self._set_dmd_fps()

    def _get_validated_config(self, config: dict) -> dict:
        raise NotImplementedError

    def _set_dmd_fps(self) -> None:
        # fps is the rate that the connected client requested. We'll use the
        # lower of the two

        mc_fps = self.config['fps']

        if mc_fps == 0:
            # pylint: disable-msg=protected-access
            mc_fps = Clock._max_fps

        # pylint: disable-msg=protected-access
        if mc_fps > Clock._max_fps:
            self.mc.log.warning(
                "%s fps is higher than mpf-mc fps. "
                "Will use mpf-mc fps setting for the DMD.",
                DmdBase.dmd_name_string)
            # pylint: disable-msg=protected-access
            fps = Clock._max_fps
            update = 0
        # pylint: disable-msg=protected-access
        elif Clock._max_fps > mc_fps > 0:
            fps = mc_fps
            update = 1 / fps
        else:
            # pylint: disable-msg=protected-access
            fps = Clock._max_fps
            update = 0

        Clock.schedule_interval(self.tick, update)
        self.mc.log.info("Setting %s to %sfps", DmdBase.dmd_name_string, fps)

    def tick(self, dt) -> None:
        """Draw image for DMD and send it."""
        del dt
        widget = self.source
        fbo = self.fbo

        # detach the widget from the parent
        parent = widget.parent
        if parent:
            parent.remove_widget(widget)

        self.effect_widget.add_widget(widget)

        # clear the fbo background
        fbo.bind()
        fbo.clear_buffer()
        fbo.release()

        fbo.draw()

        fbo.bind()
        data = glReadPixels(0, 0, widget.native_size[0], widget.native_size[1],
                            GL_RGB, GL_UNSIGNED_BYTE)
        fbo.release()

        # reattach to the parent
        if parent:
            self.effect_widget.remove_widget(widget)
            parent.add_widget(widget)

        if not self.config['only_send_changes'] or self.prev_data != data:
            self.prev_data = data
            self.send(data)

    def send(self, data: bytes) -> None:
        """Send data to DMD via BCP."""
        raise NotImplementedError
Example #17
0
 def build(self):
     w = EffectWidget()
     w.add_widget(Button(text='Hello!'))
     w.effects = [InvertEffect(), HorizontalBlurEffect(size=5.0)]
     return w