Beispiel #1
0
 def reload_css(self):
     """Called when css want to be reloaded from scratch"""
     self.style = {}
     style = css_get_style(widget=self)
     self.apply_css(style)
     if len(self._inline_style):
         self.apply_css(self._inline_style)
Beispiel #2
0
    def __init__(self, **kwargs):

        kwargs.setdefault("force", False)
        kwargs.setdefault("config", None)
        kwargs.setdefault("show_fps", False)
        kwargs.setdefault("style", {})

        # don't init window 2 times,
        # except if force is specified
        if self.__initialized and not kwargs.get("force"):
            return

        super(BaseWindow, self).__init__()

        # init privates
        self._modifiers = []
        self._size = (0, 0)
        self._rotation = 0

        # event subsystem
        self.register_event_type("on_flip")
        self.register_event_type("on_rotate")
        self.register_event_type("on_draw")
        self.register_event_type("on_update")
        self.register_event_type("on_resize")
        self.register_event_type("on_close")
        self.register_event_type("on_touch_down")
        self.register_event_type("on_touch_move")
        self.register_event_type("on_touch_up")
        self.register_event_type("on_mouse_down")
        self.register_event_type("on_mouse_move")
        self.register_event_type("on_mouse_up")
        self.register_event_type("on_keyboard")
        self.register_event_type("on_key_down")
        self.register_event_type("on_key_up")

        # set out window as the main pymt window
        setWindow(self)

        # apply styles for window
        self.style = {}
        style = css_get_style(widget=self)
        self.apply_css(style)

        # apply inline css
        self._inline_style = kwargs.get("style")
        if len(kwargs.get("style")):
            self.apply_css(kwargs.get("style"))

        self.children = SafeList()
        self.parent = self
        self.visible = True

        # add view
        if "view" in kwargs:
            self.add_widget(kwargs.get("view"))

        # get window params, user options before config option
        params = {}

        if "fullscreen" in kwargs:
            params["fullscreen"] = kwargs.get("fullscreen")
        else:
            params["fullscreen"] = pymt.pymt_config.get("graphics", "fullscreen")
            if params["fullscreen"] not in ("auto", "fake"):
                params["fullscreen"] = params["fullscreen"].lower() in ("true", "1", "yes", "yup")

        if "width" in kwargs:
            params["width"] = kwargs.get("width")
        else:
            params["width"] = pymt.pymt_config.getint("graphics", "width")

        if "height" in kwargs:
            params["height"] = kwargs.get("height")
        else:
            params["height"] = pymt.pymt_config.getint("graphics", "height")

        if "vsync" in kwargs:
            params["vsync"] = kwargs.get("vsync")
        else:
            params["vsync"] = pymt.pymt_config.getint("graphics", "vsync")

        if "fps" in kwargs:
            params["fps"] = kwargs.get("fps")
        else:
            params["fps"] = pymt.pymt_config.getint("graphics", "fps")

        if "rotation" in kwargs:
            params["rotation"] = kwargs.get("rotation")
        else:
            params["rotation"] = pymt.pymt_config.getint("graphics", "rotation")

        params["position"] = pymt.pymt_config.get("graphics", "position", "auto")
        if "top" in kwargs:
            params["position"] = "custom"
            params["top"] = kwargs.get("top")
        else:
            params["top"] = pymt.pymt_config.getint("graphics", "top")

        if "left" in kwargs:
            params["position"] = "custom"
            params["left"] = kwargs.get("left")
        else:
            params["left"] = pymt.pymt_config.getint("graphics", "left")

        # show fps if asked
        self.show_fps = kwargs.get("show_fps")
        if pymt.pymt_config.getboolean("pymt", "show_fps"):
            self.show_fps = True

        # configure the window
        self.create_window(params)

        # init some gl
        self.init_gl()

        # attach modules + listener event
        pymt_modules.register_window(self)
        touch_event_listeners.append(self)

        # mark as initialized
        self.__initialized = True
Beispiel #3
0
    def __init__(self, **kwargs):

        kwargs.setdefault('force', False)
        kwargs.setdefault('config', None)
        kwargs.setdefault('show_fps', False)
        kwargs.setdefault('style', {})

        # don't init window 2 times,
        # except if force is specified
        if self.__initialized and not kwargs.get('force'):
            return

        super(BaseWindow, self).__init__()

        # init privates
        self._modifiers = []
        self._size = (0, 0)

        # event subsystem
        self.register_event_type('on_flip')
        self.register_event_type('on_draw')
        self.register_event_type('on_update')
        self.register_event_type('on_resize')
        self.register_event_type('on_close')
        self.register_event_type('on_touch_down')
        self.register_event_type('on_touch_move')
        self.register_event_type('on_touch_up')
        self.register_event_type('on_mouse_down')
        self.register_event_type('on_mouse_move')
        self.register_event_type('on_mouse_up')
        self.register_event_type('on_keyboard')
        self.register_event_type('on_key_down')
        self.register_event_type('on_key_up')

        # set out window as the main pymt window
        setWindow(self)

        # apply styles for window
        self.style = {}
        style = css_get_style(widget=self)
        self.apply_css(style)

        # apply inline css
        self._inline_style = kwargs.get('style')
        if len(kwargs.get('style')):
            self.apply_css(kwargs.get('style'))

        self.children = SafeList()
        self.parent = self
        self.visible = True

        # add view
        if 'view' in kwargs:
            self.add_widget(kwargs.get('view'))

        # get window params, user options before config option
        params = {}

        if 'fullscreen' in kwargs:
            params['fullscreen'] = kwargs.get('fullscreen')
        else:
            params['fullscreen'] = pymt.pymt_config.get('graphics', 'fullscreen')
            if params['fullscreen'] not in ('auto', 'fake'):
                params['fullscreen'] = params['fullscreen'].lower() in \
                    ('true', '1', 'yes', 'yup')

        if 'width' in kwargs:
            params['width'] = kwargs.get('width')
        else:
            params['width'] = pymt.pymt_config.getint('graphics', 'width')

        if 'height' in kwargs:
            params['height'] = kwargs.get('height')
        else:
            params['height'] = pymt.pymt_config.getint('graphics', 'height')

        if 'vsync' in kwargs:
            params['vsync'] = kwargs.get('vsync')
        else:
            params['vsync'] = pymt.pymt_config.getint('graphics', 'vsync')


        params['position'] = pymt.pymt_config.get(
            'graphics', 'position', 'auto')
        if 'top' in kwargs:
            params['position'] = 'custom'
            params['top'] = kwargs.get('top')
        else:
            params['top'] = pymt.pymt_config.getint('graphics', 'top')

        if 'left' in kwargs:
            params['position'] = 'custom'
            params['left'] = kwargs.get('left')
        else:
            params['left'] = pymt.pymt_config.getint('graphics', 'left')

        # show fps if asked
        self.show_fps = kwargs.get('show_fps')
        if pymt.pymt_config.getboolean('pymt', 'show_fps'):
            self.show_fps = True

        # configure the window
        self.create_window(params)

        # init some gl
        self.init_gl()

        # attach modules + listener event
        pymt_modules.register_window(self)
        touch_event_listeners.append(self)

        # mark as initialized
        self.__initialized = True