Пример #1
0
 def __init__(self, **kwargs):
     from kivy.base import EventLoop
     EventLoop.ensure_window()
     self._invalid_scale = True
     self._tiles = []
     self._tiles_bg = []
     self._tilemap = {}
     self._layers = []
     self._default_marker_layer = None
     self._need_redraw_all = False
     self._transform_lock = False
     self.trigger_update(True)
     self.canvas = Canvas()
     self._scatter = MapViewScatter()
     self.add_widget(self._scatter)
     with self._scatter.canvas:
         self.canvas_map = Canvas()
         self.canvas_layers = Canvas()
     with self.canvas:
         self.canvas_layers_out = Canvas()
     self._scale_target_anim = False
     self._scale_target = 1.
     self._touch_count = 0
     self.map_source.cache_dir = self.cache_dir
     Clock.schedule_interval(self._animate_color, 1 / 60.)
     self.lat = kwargs.get("lat", self.lat)
     self.lon = kwargs.get("lon", self.lon)
     super(MapView, self).__init__(**kwargs)
Пример #2
0
    def __init__(self, **kwargs):
        # XXX move to style.kv
        if 'size_hint' not in kwargs:
            if 'size_hint_x' not in kwargs:
                self.size_hint_x = None
            if 'size_hint_y' not in kwargs:
                self.size_hint_y = None
        if 'size' not in kwargs:
            if 'width' not in kwargs:
                self.width = 700
            if 'height' not in kwargs:
                self.height = 200
        if 'scale_min' not in kwargs:
            self.scale_min = .4
        if 'scale_max' not in kwargs:
            self.scale_max = 1.6
        if 'docked' not in kwargs:
            self.docked = False

        layout_mode = self._trigger_update_layout_mode = Clock.create_trigger(
            self._update_layout_mode)
        layouts = self._trigger_load_layouts = Clock.create_trigger(
            self._load_layouts)
        layout = self._trigger_load_layout = Clock.create_trigger(
            self._load_layout)
        fbind = self.fbind

        fbind('docked', self.setup_mode)
        fbind('have_shift', layout_mode)
        fbind('have_capslock', layout_mode)
        fbind('have_special', layout_mode)
        fbind('layout_path', layouts)
        fbind('layout', layout)
        super(VKeyboard, self).__init__(**kwargs)

        # load all the layouts found in the layout_path directory
        self._load_layouts()

        # ensure we have default layouts
        available_layouts = self.available_layouts
        if not available_layouts:
            Logger.critical('VKeyboard: unable to load default layouts')

        # load the default layout from configuration
        if self.layout is None:
            self.layout = Config.get('kivy', 'keyboard_layout')
        else:
            # ensure the current layout is found on the available layout
            self._trigger_load_layout()

        # update layout mode (shift or normal)
        self._trigger_update_layout_mode()

        # create a top layer to draw active keys on
        with self.canvas:
            self.background_key_layer = Canvas()
            self.active_keys_layer = Canvas()
Пример #3
0
    def __init__(self, **kwargs):
        self._touch = None
        self._trigger_update_from_scroll = Clock.create_trigger(
            self.update_from_scroll, -1)
        # create a specific canvas for the viewport
        from kivy.graphics import PushMatrix, Translate, PopMatrix, Canvas
        self.canvas_viewport = Canvas()
        self.canvas = Canvas()
        with self.canvas_viewport.before:
            PushMatrix()
            self.g_translate = Translate(0, 0)
        with self.canvas_viewport.after:
            PopMatrix()

        super(ScrollView, self).__init__(**kwargs)

        self.register_event_type('on_scroll_start')
        self.register_event_type('on_scroll_move')
        self.register_event_type('on_scroll_stop')

        # now add the viewport canvas to our canvas
        self.canvas.add(self.canvas_viewport)

        effect_cls = self.effect_cls
        if isinstance(effect_cls, string_types):
            effect_cls = Factory.get(effect_cls)
        if self.effect_x is None and effect_cls is not None:
            self.effect_x = effect_cls(target_widget=self._viewport)
        if self.effect_y is None and effect_cls is not None:
            self.effect_y = effect_cls(target_widget=self._viewport)

        trigger_update_from_scroll = self._trigger_update_from_scroll
        update_effect_widget = self._update_effect_widget
        update_effect_x_bounds = self._update_effect_x_bounds
        update_effect_y_bounds = self._update_effect_y_bounds
        fbind = self.fbind
        fbind('width', update_effect_x_bounds)
        fbind('height', update_effect_y_bounds)
        fbind('viewport_size', self._update_effect_bounds)
        fbind('_viewport', update_effect_widget)
        fbind('scroll_x', trigger_update_from_scroll)
        fbind('scroll_y', trigger_update_from_scroll)
        fbind('pos', trigger_update_from_scroll)
        fbind('size', trigger_update_from_scroll)
        fbind('scroll_y', self._update_effect_bounds)
        fbind('scroll_x', self._update_effect_bounds)

        trigger_update_from_scroll()
        update_effect_widget()
        update_effect_x_bounds()
        update_effect_y_bounds()
Пример #4
0
 def __init__(self, **kwargs):
     super(GeoJsonMapLayer, self).__init__(**kwargs)
     with self.canvas:
         self.canvas_polygon = Canvas()
         self.canvas_line = Canvas()
     with self.canvas_polygon.before:
         PushMatrix()
         self.g_matrix = MatrixInstruction()
         self.g_scale = Scale()
         self.g_translate = Translate()
     with self.canvas_polygon:
         self.g_canvas_polygon = Canvas()
     with self.canvas_polygon.after:
         PopMatrix()
Пример #5
0
    def create_window(self):
        '''Will create the main window and configure it.

        .. warning::
            This method is called automatically at runtime. If you call it, it
            will recreate a RenderContext and Canvas. This mean you'll have a
            new graphics tree, and the old one will be unusable.

            This method exist to permit the creation of a new OpenGL context
            AFTER closing the first one. (Like using runTouchApp() and
            stopTouchApp()).

            This method have been only tested in unittest environment, and will
            be not suitable for Applications.

            Again, don't use this method unless you know exactly what you are
            doing !
        '''
        from kivy.core.gl import init_gl
        init_gl()

        # create the render context and canvas
        from kivy.graphics import RenderContext, Canvas
        self.render_context = RenderContext()
        self.canvas = Canvas()
        self.render_context.add(self.canvas)
Пример #6
0
 def __init__(self, **kwargs):
     self.first_time = True
     self.initial_zoom = None
     super().__init__(**kwargs)
     with self.canvas:
         self.canvas_polygon = Canvas()
         self.canvas_line = Canvas()
     with self.canvas_polygon.before:
         PushMatrix()
         self.g_matrix = MatrixInstruction()
         self.g_scale = Scale()
         self.g_translate = Translate()
     with self.canvas_polygon:
         self.g_canvas_polygon = Canvas()
     with self.canvas_polygon.after:
         PopMatrix()
Пример #7
0
    def __init__(self, **kwargs):
        super(Widget, self).__init__()

        # Register touch events
        self.register_event_type('on_touch_down')
        self.register_event_type('on_touch_move')
        self.register_event_type('on_touch_up')

        # Before doing anything, ensure the windows exist.
        EventLoop.ensure_window()

        # Auto bind on own handler if exist
        properties = self.__properties.keys()
        for func in dir(self):
            if not func.startswith('on_'):
                continue
            name = func[3:]
            if name in properties:
                self.bind(**{name: getattr(self, func)})

        # Create the default canvas if not exist
        if self.canvas is None:
            self.canvas = Canvas()

        # Apply the existing arguments to our widget
        for key, value in kwargs.iteritems():
            if hasattr(self, key):
                setattr(self, key, value)

        # Apply all the styles
        if '__no_builder' not in kwargs:
            Builder.apply(self)
Пример #8
0
    def show_lines(self):
        indices = []
        grid = self.grid
        cols = grid.cols
        rows = grid.rows
        for col in range(grid.cols + 1):
            indices.extend((
                col * (rows + 1),
                col * (rows + 1) + rows,
            ))
        for row in range(grid.rows + 1):
            indices.extend((
                row,
                row + (cols * (rows + 1)),
            ))

        with self.canvas:
            self.g_canvas = Canvas()

        with self.g_canvas:
            Color(1, 0, 0, 0.5)
            PushMatrix()
            Scale(self.width, self.height, 1.)
            self.g_mesh = Mesh(vertices=self.grid.line_vertices,
                               indices=self.grid.line_indices,
                               mode="lines",
                               source="projectionmapping/data/white.png")
            PopMatrix()

        self.rebuild_informations()
Пример #9
0
    def __init__(self, **kwargs):
        self.canvas = Canvas()
        with self.canvas.before:
            Callback(self._set_blend_func)
        #self.size
        self.fbo_texture = Texture.create(size=self.size, colorfmt='rgba')

        self.fbo_texture.mag_filter = 'linear'
        self.fbo_texture.min_filter = 'linear'

        with self.canvas:
            #self.cbs = Callback(self.prepare_canvas)
            self.fbo = Fbo(size=self.size, texture=self.fbo_texture)
            #Color(1, 1, 1, 0)
            #self.fbo_rect = Rectangle()

        with self.fbo:
            ClearColor(0.0, 0.0, 0.0, 0.0)
            ClearBuffers()
            self.fbo_rect = Rectangle(size=self.size)

        #self.fbo.shader.source = resource_find('./kivy3dgui/gles2.0/shaders/invert.glsl')
        #with self.fbo.after:
        #    self.cbr = Callback(self.reset_gl_context)
        #    PopMatrix()

        with self.canvas.before:
            Callback(self._set_blend_func)

        # wait that all the instructions are in the canvas to set texture

        self.texture = self.fbo.texture
        super(FboFloatLayout, self).__init__(**kwargs)
Пример #10
0
    def build(self):
        radius = self.radius

        if not self.canvas_points:
            self.canvas_points = Canvas()
            self.canvas.add(self.canvas_points)
            with self.canvas_points:
                Color(1, 0, 0)
                for marker in points:
                    Rectangle(pos=(marker.x * 600, marker.y * 600),
                              size=(2, 2))

        self.canvas.before.clear()
        with self.canvas.before:
            if self.selection_center:
                Color(0, 1, 0, 0.5)
                x, y = self.selection_center
                r = radius * 600
                r2 = r * 2
                Ellipse(pos=(x - r, y - r), size=(r2, r2))

            if self.selection:
                Color(0, 0, 1)
                for m_id in self.selection:
                    # x = kdbush.coords[m_id * 2]
                    # y = kdbush.coords[m_id * 2 + 1]
                    marker = points[m_id]
                    x = marker.x
                    y = marker.y
                    Rectangle(pos=(x * 600 - 4, y * 600 - 4), size=(8, 8))
Пример #11
0
    def __init__(self, **kwargs):
        # Before doing anything, ensure the windows exist.
        EventLoop.ensure_window()

        # assign the default context of the widget creation
        if not hasattr(self, '_context'):
            self._context = get_current_context()

        super(Widget, self).__init__(**kwargs)

        # Create the default canvas if not exist
        if self.canvas is None:
            self.canvas = Canvas(opacity=self.opacity)

        # Apply all the styles
        if '__no_builder' not in kwargs:
            #current_root = Builder.idmap.get('root')
            #Builder.idmap['root'] = self
            Builder.apply(self)
            #if current_root is not None:
            #    Builder.idmap['root'] = current_root
            #else:
            #    Builder.idmap.pop('root')

        # Bind all the events
        for argument in kwargs:
            if argument[:3] == 'on_':
                self.bind(**{argument: kwargs[argument]})
Пример #12
0
    def __init__(self, overlay, **kwargs):
        super().__init__(**kwargs)
        # creating an interface
        self.controller = overlay
        self.size_hint = (.8, .8)
        self.orientation = 'vertical'
        # starting the gameloop
        self.event = Clock.schedule_interval(self.mainloop, 0)
        # create main canvas
        self.GAME = Widget()
        self.GAME.canvas = Canvas()
        self.add_widget(self.GAME)
        # game classes
        self.player = Player()
        self.sprites = Sprites()
        self.drawing = Drawing(self.GAME.canvas, None)

        # draw borders
        with self.canvas.after:
            Color(.05, .05, .05)
            Rectangle(pos=(0, 0), size=(NULLX, REAL_SCREEN_Y))
            Color(.01, .01, .01)
            Rectangle(pos=(NULLX, REAL_SCREEN_Y - NULLY),
                      size=(REAL_SCREEN_X - NULLX, NULLY))
            Color(.01, .01, .01)
            Rectangle(pos=(NULLX, 0), size=(REAL_SCREEN_X - NULLX, NULLY))
            Color(.05, .05, .05)
            Rectangle(pos=(REAL_SCREEN_X - NULLX, 0),
                      size=(REAL_SCREEN_X, REAL_SCREEN_Y))
Пример #13
0
    def start(self, manager):
        '''(internal) Starts the transition. This is automatically
        called by the :class:`ScreenManager`.
        '''
        self.manager = manager
        if hasattr(manager, 'c'):
            manager.canvas.remove(manager.c)

        manager.c = Canvas()
        with manager.c:
            opacity = 0
            Color(0, 0, 0, 0.6)
            Rectangle(size=manager.size, pos=manager.pos)
        super(CardTransition, self).start(manager)
        mode = self.mode
        a = self.screen_in
        b = self.screen_out
        # ensure that the correct widget is "on top"
        if mode == 'push':
            manager.canvas.add(manager.c)
            manager.canvas.remove(a.canvas)
            manager.canvas.add(a.canvas)
        elif mode == 'pop':
            manager.canvas.add(manager.c)
            manager.canvas.remove(b.canvas)
            manager.canvas.add(b.canvas)
Пример #14
0
    def __init__(self, **kwargs):
        # Before doing anything, ensure the windows exist.
        EventLoop.ensure_window()

        # Assign the default context of the widget creation.
        if not hasattr(self, '_context'):
            self._context = get_current_context()

        no_builder = '__no_builder' in kwargs
        if no_builder:
            del kwargs['__no_builder']
        on_args = {k: v for k, v in kwargs.items() if k[:3] == 'on_'}
        for key in on_args:
            del kwargs[key]

        super(Widget, self).__init__(**kwargs)

        # Create the default canvas if it does not exist.
        if self.canvas is None:
            self.canvas = Canvas(opacity=self.opacity)

        # Apply all the styles.
        if not no_builder:
            Builder.apply(self, ignored_consts=self._kwargs_applied_init)

        # Bind all the events.
        if on_args:
            self.bind(**on_args)
Пример #15
0
    def __init__(self, **kwargs):
        # Before doing anything, ensure the windows exist.
        EventLoop.ensure_window()

        # Register touch events
        self.register_event_type('on_touch_down')
        self.register_event_type('on_touch_move')
        self.register_event_type('on_touch_up')

        super(Widget, self).__init__(**kwargs)

        # Create the default canvas if not exist
        if self.canvas is None:
            self.canvas = Canvas(opacity=self.opacity)

        # Apply all the styles
        if '__no_builder' not in kwargs:
            #current_root = Builder.idmap.get('root')
            #Builder.idmap['root'] = self
            Builder.apply(self)
            #if current_root is not None:
            #    Builder.idmap['root'] = current_root
            #else:
            #    Builder.idmap.pop('root')

        # Bind all the events
        for argument in kwargs:
            if argument[:3] == 'on_':
                self.bind(**{argument: kwargs[argument]})
Пример #16
0
    def __init__(self, **kwargs):
        # XXX move to style.kv
        kwargs.setdefault('size_hint', (None, None))
        kwargs.setdefault('scale_min', .4)
        kwargs.setdefault('scale_max', 1.6)
        kwargs.setdefault('size', (700, 200))
        kwargs.setdefault('docked', False)
        self._trigger_update_layout_mode = Clock.create_trigger(
            self._update_layout_mode)
        self._trigger_load_layouts = Clock.create_trigger(
            self._load_layouts)
        self._trigger_load_layout = Clock.create_trigger(
            self._load_layout)
        self.bind(
            docked=self.setup_mode,
            have_shift=self._trigger_update_layout_mode,
            have_capslock=self._trigger_update_layout_mode,
            layout_path=self._trigger_load_layouts,
            layout=self._trigger_load_layout)
        super(VKeyboard, self).__init__(**kwargs)

        # load all the layouts found in the layout_path directory
        self._load_layouts()

        # ensure we have default layouts
        available_layouts = self.available_layouts
        if not available_layouts:
            Logger.critical('VKeyboard: unable to load default layouts')

        # load the default layout from configuration
        if self.layout is None:
            self.layout = Config.get('kivy', 'keyboard_layout')
        else:
            # ensure the current layout is found on the available layout
            self._trigger_load_layout()

        # update layout mode (shift or normal)
        self._trigger_update_layout_mode()

        # create a top layer to draw active keys on
        with self.canvas:
            self.background_key_layer = Canvas()
            self.active_keys_layer = Canvas()

        # prepare layout widget
        self.refresh_keys_hint()
        self.refresh_keys()
Пример #17
0
    def __init__(self, **kwargs):
        super(RippleBehavior, self).__init__(**kwargs)
        self.ripple_pane_bg = Canvas()
        self.canvas.add(self.ripple_pane_bg)
        self.bind(ripple_bg_color=self._ripple_set_bg_color, )
        self.ripple_rectangle = None
        self.ripple_bg_color_instruction = None

        self.ripple_pane = Canvas()
        self.canvas.add(self.ripple_pane)
        self.bind(ripple_color=self._ripple_set_color,
                  ripple_pos=self._ripple_set_ellipse,
                  ripple_rad=self._ripple_set_ellipse)
        self.ripple_ellipse = None
        self.ripple_col_instruction = None

        self.execution_index = 1
Пример #18
0
    def __init__(self, **kwargs):
        if platform == "ios":
	    user_data_dir = App.get_running_app().user_data_dir
    	    self.cache_dir = join(user_data_dir, "cache_dir") 
        self.first_time = True
        self.initial_zoom = None
        super(GeoJsonMapLayer, self).__init__(**kwargs)
        with self.canvas:
            self.canvas_polygon = Canvas()
        with self.canvas_polygon.before:
            PushMatrix()
            self.g_matrix = MatrixInstruction()
            self.g_scale = Scale()
            self.g_translate = Translate()
        with self.canvas_polygon:
            self.g_canvas_polygon = Canvas()
        with self.canvas_polygon.after:
            PopMatrix()
Пример #19
0
 def __init__(self, label, setting, color, **kwargs):
     super(Setting, self).__init__(**kwargs)
     Clock.schedule_once(self._finish_init)
     self._setting = setting
     self.label = label
     self.canvas = Canvas()
     with self.canvas.before:
         Color(rgba=color)
         self.rect = Rectangle(size=self.size, pos=self.pos)
     self.bind(pos=self.update_bg, size=self.update_bg)
Пример #20
0
    def __init__(self, **kwargs):
        self.canvas = Canvas()
        with self.canvas:
            self.fbo = Fbo(size=self.size)
            Color(1, 1, 1)
            self.fbo_rect = Rectangle()

        # wait that all the instructions are in the canvas to set texture
        self.texture = self.fbo.texture
        super(FboFloatLayout, self).__init__(**kwargs)
Пример #21
0
    def create_window(self, *largs):
        '''Will create the main window and configure it.

        .. warning::
            This method is called automatically at runtime. If you call it, it
            will recreate a RenderContext and Canvas. This means you'll have a
            new graphics tree, and the old one will be unusable.

            This method exist to permit the creation of a new OpenGL context
            AFTER closing the first one. (Like using runTouchApp() and
            stopTouchApp()).

            This method has only been tested in a unittest environment and
            is not suitable for Applications.

            Again, don't use this method unless you know exactly what you are
            doing!
        '''
        # just to be sure, if the trigger is set, and if this method is
        # manually called, unset the trigger
        Clock.unschedule(self.create_window)

        # ensure the window creation will not be called twice
        if platform in ('android', 'ios'):
            self._unbind_create_window()

        if not self.initialized:
            from kivy.core.gl import init_gl
            init_gl()

            # create the render context and canvas, only the first time.
            from kivy.graphics import RenderContext, Canvas
            self.render_context = RenderContext()
            self.canvas = Canvas()
            self.render_context.add(self.canvas)

        else:
            # if we get initialized more than once, then reload opengl state
            # after the second time.
            # XXX check how it's working on embed platform.
            if platform == 'linux' or Window.__class__.__name__ == 'WindowSDL':
                # on linux, it's safe for just sending a resize.
                self.dispatch('on_resize', *self.system_size)

            else:
                # on other platform, window are recreated, we need to reload.
                from kivy.graphics.context import get_context
                get_context().reload()
                Clock.schedule_once(lambda x: self.canvas.ask_update(), 0)
                self.dispatch('on_resize', *self.system_size)

        # ensure the gl viewport is correct
        self.update_viewport()
Пример #22
0
    def __init__(self, **kwargs):
        self.canvas = Canvas()
        with self.canvas:
            self.fbo = Fbo(size=self.size,
                           with_depthbuffer=True,
                           compute_normal_mat=True,
                           clear_color=(0., 0., 0., 0.))

            self.viewport = Rectangle(size=self.size, pos=self.pos)

        self.fbo.shader.source = resource_find(
            join(dirname(__file__), 'simple.glsl'))
        super(ObjectRenderer, self).__init__(**kwargs)
    def __init__(self, **kwargs):
        self._touch = None
        self._trigger_update_from_scroll = Clock.create_trigger(
            self.update_from_scroll, -1)
        # create a specific canvas for the viewport
        from kivy.graphics import PushMatrix, Translate, PopMatrix, Canvas
        self.canvas_viewport = Canvas()
        self.canvas = Canvas()
        with self.canvas_viewport.before:
            PushMatrix()
            self.g_translate = Translate(0, 0)
        with self.canvas_viewport.after:
            PopMatrix()

        super(ScrollView, self).__init__(**kwargs)

        # now add the viewport canvas to our canvas
        self.canvas.add(self.canvas_viewport)

        effect_cls = self.effect_cls
        if isinstance(effect_cls, string_types):
            effect_cls = Factory.get(effect_cls)
        if self.effect_x is None and effect_cls is not None:
            self.effect_x = effect_cls(target_widget=self._viewport)
        if self.effect_y is None and effect_cls is not None:
            self.effect_y = effect_cls(target_widget=self._viewport)
        self.bind(width=self._update_effect_x_bounds,
                  height=self._update_effect_y_bounds,
                  viewport_size=self._update_effect_bounds,
                  _viewport=self._update_effect_widget,
                  scroll_x=self._trigger_update_from_scroll,
                  scroll_y=self._trigger_update_from_scroll,
                  pos=self._trigger_update_from_scroll,
                  size=self._trigger_update_from_scroll)

        self._update_effect_widget()
        self._update_effect_x_bounds()
        self._update_effect_y_bounds()
Пример #24
0
    def __init__(self, **kwargs):
        """
        Set up inheritance of parent with the kwargs as well as add variables needed by all instances.

        :param kwargs: all available kwargs can be found at https://kivy.org/docs/api-kivy.uix.floatlayout.html
        """

        super().__init__(**kwargs)
        self.root = root = self
        self.root.canvas = Canvas()
        root.bind(angle=self.on_angle)

        self.rotate_animation = Animation(angle=0.5, duration=1)
        self.rotate_animation.start(self)
Пример #25
0
    def __init__(self, **kw):
        self.shader_file = kw.pop("shader_file", None)
        self.canvas = Canvas()
        super(Renderer, self).__init__(**kw)

        with self.canvas:
            self._viewport = Rectangle(size=self.size, pos=self.pos)
            self.fbo = Fbo(size=self.size,
                           with_depthbuffer=True, compute_normal_mat=True,
                           clear_color=(0., 0., 0., 0.))
        self._config_fbo()
        self.texture = self.fbo.texture
        self.camera = None
        self.scene = None
Пример #26
0
    def __init__(self, **kwargs):
        self.mesh_data = MeshData()
        self.canvas = Canvas()
        with self.canvas:
            self.fbo = Fbo(size=(10, 10), compute_normal_mat=True)
            self.fbo.add_reload_observer(self.populate_fbo)
        with self.fbo:
            ClearColor(0, 0, 0, 0)
            ClearBuffers()
        self.populate_fbo(self.fbo)

        super(GLWindow, self).__init__(**kwargs)

        Clock.schedule_interval(self.update_glsl, 1 / 60.)
Пример #27
0
def _highlight(results):
    from kivy.graphics import Color, Rectangle, Canvas
    from kivy.core.window import Window
    if not hasattr(Window, "_telenium_canvas"):
        Window._telenium_canvas = Canvas()
    _canvas = Window._telenium_canvas

    Window.canvas.remove(_canvas)
    Window.canvas.add(_canvas)

    _canvas.clear()
    with _canvas:
        Color(1, 0, 0, 0.5)
        for widget, bounds in results:
            left, bottom, right, top = bounds
            Rectangle(pos=(left, bottom), size=(right - left, top - bottom))
Пример #28
0
    def _highlight(self, results):
        from kivy.graphics import Color, Rectangle, Canvas
        from kivy.core.window import Window
        if not hasattr(self, "_canvas"):
            self._canvas = Canvas()

        Window.canvas.remove(self._canvas)
        Window.canvas.add(self._canvas)

        self._canvas.clear()
        with self._canvas:
            Color(1, 0, 0, 0.5)
            for widget, bounds in results:
                left, bottom, right, top = bounds
                Rectangle(pos=(left, bottom),
                          size=(right - left, top - bottom))
Пример #29
0
 def build(self):
     #self.load_kv('MyApp.kv')
     self.title = "Graphic Test Framework"
     widget = MyWidget()
     widget.add_widget(Label(text="prueba"))
     myCanvas = Canvas()
     myCanvas.add(Rectangle(size=(350, 1), pos=(0, 500)))
     widget.canvas = myCanvas
     widget.add_widget(Button(text="Boton", pos=(100, 500)))
     return widget
     return MyWidget()
     return PageLayout()
     return StackLayout()
     return BoxLayout()
     return GridLayout()
     return FloatLayout()
     return CustomWidget()
Пример #30
0
    def __init__(self, **kwargs):
        self.register_event_type('on_touch_hover')
        self.chooser = None
        self.popup = None

        self.skeletons = []
        self.states = []

        # self.batch = PolygonSpriteBatch()

        self.renderer = SkeletonRenderer()
        self.debugRenderer = SkeletonRendererDebug()

        self.draw_canvas = Canvas()

        super().__init__(**kwargs)
        self.canvas.add(self.draw_canvas)