def open(self,
             size=(800, 800),
             pos=(50, 50),
             gui_scale=1.0,
             ui_config=None):
        if self._window:
            return

        glfw.glfwInit()
        glfw.glfwWindowHint(glfw.GLFW_SCALE_TO_MONITOR, glfw.GLFW_TRUE)
        # Window name needs to be equal to `StartupWMClass` field in Linux .desktop file
        # else the icon will not show correctly on Linux!
        self._window = glfw.glfwCreateWindow(*size,
                                             "Pupil Invisible Monitor",
                                             monitor=None,
                                             share=None)
        glfw.glfwSetWindowSizeLimits(self._window, 200, 200,
                                     glfw.GLFW_DONT_CARE, glfw.GLFW_DONT_CARE)
        glfw.glfwSetWindowPos(self._window, *pos)
        glfw.glfwMakeContextCurrent(self._window)

        cygl.utils.init()

        self.gui = ui.UI()
        self.gui_user_scale = gui_scale

        # Adding an intermediate container fixes a pylgui display bug
        self.cont = ui.Container((0, 0), (0, 0), (0, 0))
        self.quickbar = ui.Horizontally_Stretching_Menu(
            "Quick Bar", (0.0, -120.0), (0.0, 0.0))
        self.cont.append(self.quickbar)
        self.gui.append(self.cont)

        # Register callbacks main_window
        glfw.glfwSetFramebufferSizeCallback(self._window,
                                            self.on_framebuffer_resize)
        glfw.glfwSetKeyCallback(self._window, self.on_window_key)
        glfw.glfwSetCharCallback(self._window, self.on_window_char)
        glfw.glfwSetMouseButtonCallback(self._window,
                                        self.on_window_mouse_button)
        glfw.glfwSetCursorPosCallback(self._window, self.on_pos)
        glfw.glfwSetScrollCallback(self._window, self.on_scroll)
        self.gui.configuration = ui_config or {}
        gl_utils.basic_gl_setup()

        # Perform an initial window size setup
        self.manual_resize()
Esempio n. 2
0
 def set_position(self, x, y):
     glfw.glfwSetWindowPos(self._native_window, x, y)
     self._x, self._y = glfw.glfwGetWindowPos(self._native_window)