How to use the kivy.core.window.Window function in Kivy

To help you get started, we’ve selected a few Kivy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kivy / kivy / examples / shader / shadertree.py View on Github external
def __init__(self, **kwargs):
        # Instead of using canvas, we will use a RenderContext,
        # and change the default shader used.
        self.canvas = RenderContext(use_parent_projection=True)

        # We create a framebuffer at the size of the window
        # FIXME: this should be created at the size of the widget
        with self.canvas:
            self.fbo = Fbo(size=Window.size, use_parent_projection=True)

        # Set the fbo background to black.
        with self.fbo:
            Color(0, 0, 0)
            Rectangle(size=Window.size)

        # call the constructor of parent
        # if they are any graphics object, they will be added on our new canvas
        super(ShaderWidget, self).__init__(**kwargs)

        # We'll update our glsl variables in a clock
        Clock.schedule_interval(self.update_glsl, 0)

        # Don't forget to set the texture property to the texture
        # of framebuffer
        self.texture = self.fbo.texture
github Zogg / FishLife / main.py View on Github external
def __init__(self):
        super(FishLifeScore, self).__init__()
        self.pos = (Window.width/2 - self.width/2, Window.height/2 - self.height/2)
        self.box_layout.pos = self.pos
        self.box_layout.size = self.size
github chaosbuffalolabs / ParticlePanda / main.py View on Github external
def cancel(self):
        self.load_save_widget.new_file_popup.dismiss()
        Window.release_all_keyboards()
github Blue9 / AudioJack-GUI / audiojack_gui.py View on Github external
def build(self):
        self.gui = MainGUI()
        self.initialize_widgets()
        Clock.schedule_interval(self.check_cb, 1)
        inspector.create_inspector(Window, self.gui)
        return self.gui
github ntoll / pypercard / pypercard / core.py View on Github external
def _draw_text(self):
        """
        Encompasses the drawing of a single textual block onto the card.
        """
        self.text_label = Label(
            text=self.text, font_size=self.font_size, markup=True
        )
        self.text_label.color = list(self.text_color)
        self.text_label.padding = 10, 10
        self.text_label.text_size = (Window.width, Window.height)
        self.text_label.valign = "middle"
        self.text_label.halign = "center"
        self.layout.add_widget(self.text_label)
github kivy / kivy / examples / shader / shadertree.py View on Github external
# prepare shader list
        available_shaders = (
            shader_pulse, shader_postprocessing, shader_monochrome)
        self.shader_index = 0

        # create our widget tree
        root = FloatLayout()
        sw = ShaderWidget()
        root.add_widget(sw)

        # add a button and scatter image inside the shader widget
        btn = Button(text='Hello world', size_hint=(None, None),
                     pos_hint={'center_x': .25, 'center_y': .5})
        sw.add_widget(btn)

        center = Window.width * 0.75 - 256, Window.height * 0.5 - 256
        scatter = ScatterImage(source='tex3.jpg', size_hint=(None, None),
                               size=(512, 512), pos=center)
        sw.add_widget(scatter)

        # create a button outside the shader widget, to change the current used
        # shader
        btn = Button(text='Change fragment shader', size_hint=(1, None),
                     height=50)

        def change(*largs):
            sw.fs = available_shaders[self.shader_index]
            self.shader_index = ((self.shader_index + 1) %
                                 len(available_shaders))
        btn.bind(on_release=change)
        root.add_widget(btn)
        return root
github kivy / kivy / examples / canvas / multitexture.py View on Github external
def update_glsl(self, *largs):
        # This is needed for the default vertex shader.
        self.canvas['projection_mat'] = Window.render_context['projection_mat']
        self.canvas['modelview_mat'] = Window.render_context['modelview_mat']
github HeaTTheatR / KivyMD / kivymd / uix / toolbar.py View on Github external
def __init__(self, **kwargs):
        self.action_button = MDActionBottomAppBarButton()
        super().__init__(**kwargs)
        self.register_event_type("on_action_button")
        self.action_button.bind(
            on_release=lambda x: self.dispatch("on_action_button")
        )
        self.action_button.x = Window.width / 2 - self.action_button.width / 2
        self.action_button.y = (
            (self.center[1] - self.height / 2)
            + self.theme_cls.standard_increment / 2
            + self._shift
        )
        if not self.icon_color:
            self.icon_color = self.theme_cls.primary_color
        Window.bind(on_resize=self._on_resize)
        self.bind(specific_text_color=self.update_action_bar_text_colors)
        Clock.schedule_once(
            lambda x: self.on_left_action_items(0, self.left_action_items)
        )
        Clock.schedule_once(
            lambda x: self.on_right_action_items(0, self.right_action_items)
        )
github kivy / kivent / examples / 2_basic_app / main.py View on Github external
def draw_some_stuff(self):
        init_entity = self.gameworld.init_entity
        for x in range(2000):
            pos = randint(0, Window.width), randint(0, Window.height)
            model_key = choice(['star1-4', 'star1-4-2'])
            create_dict = {
                'position': pos,
                'renderer': {'texture': 'star1',
                    'model_key': model_key},
            }
            ent = init_entity(create_dict, ['position', 'renderer'])
        #If you do not set Renderer.force_update to True, call update_trigger
github kivy-garden / garden.rotabox / Visual Editor / rotaboxer.py View on Github external
def save_window(self):
        """ Saves the json based configuration settings
        """
        config = {'width': Window.width,
                  'height': Window.height,
                  'left': Window.left,
                  'top': Window.top,
                  'last dir': self.last_dir}
        try:
            with open('rotaboxer/settings.json', 'w+') as settings:
                json.dump(config, settings)
        except IOError as er:
            print('On save_window: ', er)