def __init__(self, *, size=None, title=None):
        super().__init__()

        # Handle inputs
        if not size:
            size = 640, 480
        title = str(title or "")

        # Set window hints
        glfw.window_hint(glfw.CLIENT_API, glfw.NO_API)
        glfw.window_hint(glfw.RESIZABLE, True)
        # see https://github.com/FlorianRhiem/pyGLFW/issues/42
        # Alternatively, from pyGLFW 1.10 one can set glfw.ERROR_REPORTING='warn'
        if sys.platform.startswith("linux"):
            if "wayland" in os.getenv("XDG_SESSION_TYPE", "").lower():
                glfw.window_hint(glfw.FOCUSED, False)  # prevent Wayland focus error

        # Create the window (the initial size may not be in logical pixels)
        self._window = glfw.create_window(int(size[0]), int(size[1]), title, None, None)

        # Register ourselves
        self._need_draw = True
        all_glfw_canvases.add(self)

        # Register callbacks. We may get notified too often, but that's
        # ok, they'll result in a single draw.
        glfw.set_window_content_scale_callback(self._window, self._on_pixelratio_change)
        glfw.set_framebuffer_size_callback(self._window, self._on_size_change)
        glfw.set_window_close_callback(self._window, self._on_close)
        glfw.set_window_refresh_callback(self._window, self._on_window_dirty)
        glfw.set_window_focus_callback(self._window, self._on_window_dirty)
        glfw.set_window_maximize_callback(self._window, self._on_window_dirty)
        # Initialize the size
        self.set_logical_size(*size)
Esempio n. 2
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        if not glfw.init():
            raise ValueError("Failed to initialize glfw")

        # Configure the OpenGL context
        glfw.window_hint(glfw.CONTEXT_CREATION_API, glfw.NATIVE_CONTEXT_API)
        glfw.window_hint(glfw.CLIENT_API, glfw.OPENGL_API)
        glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, self.gl_version[0])
        glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, self.gl_version[1])
        glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
        glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
        glfw.window_hint(glfw.RESIZABLE, self.resizable)
        glfw.window_hint(glfw.DOUBLEBUFFER, True)
        glfw.window_hint(glfw.DEPTH_BITS, 24)
        glfw.window_hint(glfw.SAMPLES, self.samples)
        glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)

        monitor = None
        if self.fullscreen:
            self._set_fullscreen(True)

        self._window = glfw.create_window(self.width, self.height, self.title,
                                          monitor, None)
        self._has_focus = True

        if not self._window:
            glfw.terminate()
            raise ValueError("Failed to create window")

        self.cursor = self._cursor

        self._buffer_width, self._buffer_height = glfw.get_framebuffer_size(
            self._window)
        glfw.make_context_current(self._window)

        if self.vsync:
            glfw.swap_interval(1)
        else:
            glfw.swap_interval(0)

        glfw.set_key_callback(self._window, self.glfw_key_event_callback)
        glfw.set_cursor_pos_callback(self._window,
                                     self.glfw_mouse_event_callback)
        glfw.set_mouse_button_callback(self._window,
                                       self.glfw_mouse_button_callback)
        glfw.set_scroll_callback(self._window, self.glfw_mouse_scroll_callback)
        glfw.set_window_size_callback(self._window,
                                      self.glfw_window_resize_callback)
        glfw.set_char_callback(self._window, self.glfw_char_callback)
        glfw.set_window_focus_callback(self._window, self.glfw_window_focus)
        glfw.set_cursor_enter_callback(self._window, self.glfw_cursor_enter)
        glfw.set_window_iconify_callback(self._window,
                                         self.glfw_window_iconify)
        glfw.set_window_close_callback(self._window, self.glfw_window_close)

        self.init_mgl_context()
        self.set_default_viewport()
Esempio n. 3
0
	def set_callbacks(self):
		glfw.set_window_close_callback(self.window, self.window_close_callback)
		glfw.set_window_size_callback(self.window, self.window_resize_callback)
		glfw.set_key_callback(self.window, self.keyboard_callback)
		glfw.set_char_callback(self.window, self.key_typed_callback)
		glfw.set_mouse_button_callback(self.window, self.mouse_callback)
		glfw.set_scroll_callback(self.window, self.scroll_callback)
		glfw.set_cursor_pos_callback(self.window, self.cursor_pos_callback)
Esempio n. 4
0
 def _register_callbacks(self, window):
     glfw.set_window_size_callback(window, self._on_set_window_size)
     glfw.set_window_pos_callback(window, self._on_set_window_pos)
     glfw.set_framebuffer_size_callback(window,
                                        self._on_set_frame_buffer_size)
     glfw.set_mouse_button_callback(window, self._on_set_mouse_button)
     glfw.set_cursor_pos_callback(window, self._on_set_cursor_pos)
     glfw.set_scroll_callback(window, self._on_set_scroll)
     glfw.set_window_close_callback(window, self._on_set_window_close)
Esempio n. 5
0
    def __init__(
        self,
        size_pix=(760, 760),
        colour=(0.5, 0.5, 0.5),
        event_buffer_size=20,
        gamma=None,
        close_on_exit=True,
        global_quit=True,
    ):

        self._global_quit = global_quit

        self.close_on_exit = close_on_exit

        self._event_buffer = collections.deque(maxlen=event_buffer_size)

        glfw.init()

        glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
        glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
        glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, 1)

        glfw.window_hint(glfw.DOUBLEBUFFER, glfw.TRUE)

        self.monitor = glfw.get_primary_monitor()

        self._orig_gamma = glfw.get_gamma_ramp(self.monitor)

        if gamma is not None:
            glfw.set_gamma(monitor=self.monitor, gamma=gamma)

        self.win = glfw.create_window(
            width=size_pix[0],
            height=size_pix[1],
            title="window",
            monitor=None,
            share=None,
        )

        glfw.make_context_current(self.win)

        glfw.swap_interval(0)

        glfw.set_key_callback(self.win, self.key_event_callback)

        glfw.set_window_close_callback(self.win, self.window_close_callback)

        self.colour = colour

        self.flip()

        glfw.set_time(0.0)

        self.nests = 0
Esempio n. 6
0
    def open_window(self):
        if not self._window:

            monitor = None
            # open with same aspect ratio as surface
            surface_aspect_ratio = (self.surface.real_world_size["x"] /
                                    self.surface.real_world_size["y"])
            win_h = 640
            win_w = int(win_h / surface_aspect_ratio)

            self._window = glfw.create_window(
                win_h,
                win_w,
                "Reference Surface: " + self.surface.name,
                monitor,
                glfw.get_current_context(),
            )

            glfw.set_window_pos(
                self._window,
                self.window_position_default[0],
                self.window_position_default[1],
            )

            self.trackball = gl_utils.trackball.Trackball()
            self.input = {"down": False, "mouse": (0, 0)}

            # Register callbacks
            glfw.set_framebuffer_size_callback(self._window, self.on_resize)
            glfw.set_key_callback(self._window, self.on_window_key)
            glfw.set_window_close_callback(self._window, self.on_close)
            glfw.set_mouse_button_callback(self._window,
                                           self.on_window_mouse_button)
            glfw.set_cursor_pos_callback(self._window, self.on_pos)
            glfw.set_scroll_callback(self._window, self.on_scroll)

            self.on_resize(self._window,
                           *glfw.get_framebuffer_size(self._window))

            # gl_state settings
            active_window = glfw.get_current_context()
            glfw.make_context_current(self._window)
            gl_utils.basic_gl_setup()
            gl_utils.make_coord_system_norm_based()

            # refresh speed settings
            glfw.swap_interval(0)

            glfw.make_context_current(active_window)
Esempio n. 7
0
    def setup(self):
        # get glfw started
        glfw.init()
        self.window = glfw.create_window(self.width, self.height, "Python NanoVG Demo", None, None)
        glfw.set_window_pos(self.window, 0, 0)

        # Register callbacks window
        glfw.set_window_size_callback(self.window, self.on_resize)
        glfw.set_window_close_callback(self.window, self.on_close)
        glfw.set_key_callback(self.window, self.on_key)
        glfw.set_mouse_button_callback(self.window, self.on_button)

        self.basic_gl_setup()

        # glfwSwapInterval(0)
        glfw.make_context_current(self.window)
Esempio n. 8
0
    def setup(self):
        # get glfw started
        glfw.init()
        self.window = glfw.create_window(self.width, self.height, "Python NanoVG Demo", None, None)
        glfw.set_window_pos(self.window, 0, 0)

        # Register callbacks window
        glfw.set_window_size_callback(self.window, self.on_resize)
        glfw.set_window_close_callback(self.window, self.on_close)
        glfw.set_key_callback(self.window, self.on_key)
        glfw.set_mouse_button_callback(self.window, self.on_button)

        self.basic_gl_setup()

        # glfwSwapInterval(0)
        glfw.make_context_current(self.window)
Esempio n. 9
0
    def gui_thread(self):
        # Initialize glwf
        if not glfw.init():
            raise "Glfw initialization error"

        # Create window with hints
        # glfw.window_hint(glfw.DECORATED, False)
        glfw.window_hint(glfw.FOCUSED, True)
        glfw.window_hint(glfw.RESIZABLE, False)
        glfw.window_hint(glfw.VISIBLE, False)

        self._window = glfw.create_window(get_config().window_px_width,
                                          get_config().window_px_height,
                                          "Bar game", None, None)
        if not self._window:
            glfw.terminate()
            raise "Can not create window"

        # Disable close button
        glfw.set_window_close_callback(self._window, window_close_callback)

        # Make the window's context current
        glfw.make_context_current(self._window)

        # setup viewport
        gl.glViewport(0, 0,
                      get_config().window_px_width,
                      get_config().window_px_height)

        # Setup projection matrix
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, 1, 0, 1, 1, -1)
        # Setup modelview matrix
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()

        # Loop until the user closes the window
        while not glfw.window_should_close(self._window):
            # Poll for and process events
            glfw.poll_events()

            # Render here, e.g. using pyOpenGL
            if self._process_queue():
                break

        glfw.terminate()
Esempio n. 10
0
 def _open_output_window(self, w, h, monitor=None, video_mode=None):
     glfw.default_window_hints()
     glfw.window_hint(glfw.VISIBLE, True)
     glfw.window_hint(glfw.CONTEXT_ROBUSTNESS, glfw.NO_RESET_NOTIFICATION)
     glfw.window_hint(glfw.CONTEXT_RELEASE_BEHAVIOR,
                      glfw.RELEASE_BEHAVIOR_FLUSH)
     glfw.window_hint(glfw.DOUBLEBUFFER, 1)
     if video_mode:
         glfw.window_hint(glfw.REFRESH_RATE, video_mode[2])
         glfw.window_hint(glfw.RED_BITS, video_mode[1][0])
         glfw.window_hint(glfw.GREEN_BITS, video_mode[1][1])
         glfw.window_hint(glfw.BLUE_BITS, video_mode[1][2])
     self.output_window = glfw.create_window(w, h, "Output", monitor,
                                             self.offscreen_window)
     self.pano_renderer.setOutputWindow(self._to_swig(self.output_window))
     glfw.set_key_callback(self.output_window, self._key_event)
     glfw.set_window_close_callback(self.output_window, self._close_event)
    def open_window(self):
        if not self._window:
            if self.fullscreen:
                try:
                    monitor = glfw.get_monitors()[self.monitor_idx]
                except Exception:
                    logger.warning(
                        "Monitor at index %s no longer availalbe using default"
                        % idx)
                    self.monitor_idx = 0
                    monitor = glfw.get_monitors()[self.monitor_idx]
                mode = glfw.get_video_mode(monitor)
                height, width = mode.size.height, mode.size.width
            else:
                monitor = None
                height, width = 640, 480

            self._window = glfw.create_window(
                height,
                width,
                "Calibration",
                monitor,
                glfw.get_current_context(),
            )
            if not self.fullscreen:
                # move to y = 31 for windows os
                glfw.set_window_pos(self._window, 200, 31)

            # Register callbacks
            glfw.set_framebuffer_size_callback(self._window, on_resize)
            glfw.set_key_callback(self._window, self.on_window_key)
            glfw.set_window_close_callback(self._window, self.on_close)
            glfw.set_mouse_button_callback(self._window,
                                           self.on_window_mouse_button)

            on_resize(self._window, *glfw.get_framebuffer_size(self._window))

            # gl_state settings
            active_window = glfw.get_current_context()
            glfw.make_context_current(self._window)
            basic_gl_setup()
            glfw.make_context_current(active_window)

            self.clicks_to_close = 5
Esempio n. 12
0
    def __init__(self, width, height, name, monitor=None, shared=None, **kwargs):
        super().__init__()
        # in case shared window exists, need to get context from it
        self.__context = ContextManager(width, height, name, monitor, shared, window=self)
        self.__name = name

        with self.__context.gl as gl:
            gl.glEnable(gl.GL_SCISSOR_TEST)
            gl.glEnable(gl.GL_DEPTH_TEST)
            gl.glDepthFunc(gl.GL_LESS)

            gl.glEnable(gl.GL_BLEND)
            gl.glBlendEquation(gl.GL_FUNC_ADD)
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

            gl.glEnable(gl.GL_PROGRAM_POINT_SIZE)

            gl.glEnable(gl.GL_PRIMITIVE_RESTART_FIXED_INDEX)

            # glfw.swap_interval(1)

        with self.__context.glfw as glfw_window:
            glfw.set_window_close_callback(glfw_window, self.__close_window)
            glfw.set_input_mode(self.context.glfw_window, glfw.STICKY_MOUSE_BUTTONS, glfw.TRUE)

        # make view object
        self.__glyph = GlyphNode(0, 0, width, height, None, None, None, None)

        self._render_thread = threading.Thread(target=self.__run, name=name)
        self._pipelines = []

        self.__fps = 30
        self.__timer = FPSTimer(self.__fps)
        self.__num_draw_frame = None
        self.__frame_count = 0

        self.__device_manager = DeviceMaster(self)

        self.__flag_indraw = False
Esempio n. 13
0
    def __init__(self, title, width, height, msaa=1):
        self._width = width
        self._height = height

        if not glfw.init():
            raise Exception('Failed to initialise GLFW.')

        glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
        glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
        glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
        glfw.window_hint(glfw.SAMPLES, msaa)
        self.window = glfw.create_window(width, height, title, None, None)
        self.context = Context(self.window)
        self.context.make_current()

        self.keyboard = Keyboard()
        self.mouse = Mouse()

        glfw.set_window_size_callback(self.window, self._reshape)
        glfw.set_window_close_callback(self.window, self._close)
        glfw.set_key_callback(self.window, self._key)
        glfw.set_mouse_button_callback(self.window, self._mouse_button)
        glfw.set_cursor_pos_callback(self.window, self._cursor_pos)
Esempio n. 14
0
    def __init__(self, vispy_canvas, **kwargs):
        BaseCanvasBackend.__init__(self, vispy_canvas)
        p = self._process_backend_kwargs(kwargs)
        self._initialized = False

        # Deal with config
        _set_config(p.context.config)
        # Deal with context
        p.context.shared.add_ref('glfw', self)
        if p.context.shared.ref is self:
            share = None
        else:
            share = p.context.shared.ref._id

        glfw.window_hint(glfw.REFRESH_RATE, 0)  # highest possible
        glfw.window_hint(glfw.RESIZABLE, int(p.resizable))
        glfw.window_hint(glfw.DECORATED, int(p.decorate))
        glfw.window_hint(glfw.VISIBLE, 0)  # start out hidden
        glfw.window_hint(glfw.FLOATING, int(p.always_on_top))
        if p.fullscreen is not False:
            self._fullscreen = True
            if p.fullscreen is True:
                monitor = glfw.get_primary_monitor()
            else:
                monitor = glfw.get_monitors()
                if p.fullscreen >= len(monitor):
                    raise ValueError('fullscreen must be <= %s' % len(monitor))
                monitor = monitor[p.fullscreen]
            use_size = glfw.get_video_mode(monitor)[:2]
            if use_size != tuple(p.size):
                logger.debug('Requested size %s, will be ignored to '
                             'use fullscreen mode %s' % (p.size, use_size))
            size = use_size
        else:
            self._fullscreen = False
            monitor = None
            size = p.size

        self._id = glfw.create_window(width=size[0],
                                      height=size[1],
                                      title=p.title,
                                      monitor=monitor,
                                      share=share)
        if not self._id:
            raise RuntimeError('Could not create window')

        glfw.make_context_current(self._id)
        glfw.swap_interval(1 if p.vsync else 0)  # needs a valid context

        _VP_GLFW_ALL_WINDOWS.append(self)
        self._mod = list()

        # Register callbacks
        glfw.set_window_refresh_callback(self._id, self._on_draw)
        glfw.set_window_size_callback(self._id, self._on_resize)
        glfw.set_key_callback(self._id, self._on_key_press)
        glfw.set_char_callback(self._id, self._on_key_char)
        glfw.set_mouse_button_callback(self._id, self._on_mouse_button)
        glfw.set_scroll_callback(self._id, self._on_mouse_scroll)
        glfw.set_cursor_pos_callback(self._id, self._on_mouse_motion)
        glfw.set_window_close_callback(self._id, self._on_close)
        self._vispy_canvas_ = None
        self._needs_draw = False
        self._vispy_canvas.set_current()
        if p.position is not None:
            self._vispy_set_position(*p.position)
        if p.show:
            glfw.show_window(self._id)

        # Init
        self._initialized = True
        self._next_key_events = []
        self._next_key_text = {}
        self._vispy_canvas.set_current()
        self._vispy_canvas.events.initialize()
        self._on_resize(self._id, size[0], size[1])
Esempio n. 15
0
w = glfw.create_window(800, 600, 'test', None, None)

#print("OpenGL version: %d.%d.%d\n" % glfw.get_gl_version())

#glfw.ext.set_icons([(icon_data, icon_width, icon_height)])
glfw.set_window_title(w, "pyglfw test")
#glfw.disable(w, glfw.AUTO_POLL_EVENTS)
#glfw.enable(w, glfw.KEY_REPEAT)

center_x = int(vm[0][0] / 2 - glfw.get_window_size(w)[0] / 2)
center_y = int(vm[0][1] / 2 - glfw.get_window_size(w)[1] / 2)
print( "new window position: {!s}, {!s}".format(center_x, center_y) )
glfw.set_window_pos(w, center_x, center_y)

glfw.set_window_size_callback(w, on_resize)
glfw.set_window_close_callback(w, on_close)
glfw.set_window_refresh_callback(w, on_refresh)
glfw.set_key_callback(w, on_key)
glfw.set_char_callback(w, on_char)
glfw.set_mouse_button_callback(w, on_button)
glfw.set_cursor_pos_callback(w, on_pos)
glfw.set_scroll_callback(w, on_scroll)

while not glfw.window_should_close(w):
    glfw.poll_events()
    
    if glfw.get_key(w, glfw.KEY_E) == glfw.PRESS:
        break
    
    glClear(GL_COLOR_BUFFER_BIT)
    glfw.swap_buffers(w)
Esempio n. 16
0
w = glfw.create_window(800, 600, 'test', None, None)

#print("OpenGL version: %d.%d.%d\n" % glfw.get_gl_version())

#glfw.ext.set_icons([(icon_data, icon_width, icon_height)])
glfw.set_window_title(w, "pyglfw test")
#glfw.disable(w, glfw.AUTO_POLL_EVENTS)
#glfw.enable(w, glfw.KEY_REPEAT)

center_x = int(vm[0][0] / 2 - glfw.get_window_size(w)[0] / 2)
center_y = int(vm[0][1] / 2 - glfw.get_window_size(w)[1] / 2)
print("new window position: {!s}, {!s}".format(center_x, center_y))
glfw.set_window_pos(w, center_x, center_y)

glfw.set_window_size_callback(w, on_resize)
glfw.set_window_close_callback(w, on_close)
glfw.set_window_refresh_callback(w, on_refresh)
glfw.set_key_callback(w, on_key)
glfw.set_char_callback(w, on_char)
glfw.set_mouse_button_callback(w, on_button)
glfw.set_cursor_pos_callback(w, on_pos)
glfw.set_scroll_callback(w, on_scroll)

while not glfw.window_should_close(w):
    glfw.poll_events()

    if glfw.get_key(w, glfw.KEY_E) == glfw.PRESS:
        break

    glClear(GL_COLOR_BUFFER_BIT)
    glfw.swap_buffers(w)
Esempio n. 17
0
def demo():
    global quit
    quit = False

    # Callback functions
    def on_resize(window, w, h):
        h = max(h, 1)
        w = max(w, 1)
        hdpi_factor = (glfw.get_framebuffer_size(window)[0] /
                       glfw.get_window_size(window)[0])
        w, h = w * hdpi_factor, h * hdpi_factor
        gui.update_window(w, h)
        active_window = glfw.get_current_context()
        glfw.make_context_current(active_window)
        # norm_size = normalize((w,h),glfw.get_window_size(window))
        # fb_size = denormalize(norm_size,glfw.get_framebuffer_size(window))
        adjust_gl_view(w, h, window)
        glfw.make_context_current(active_window)

    def on_iconify(window, iconfied):
        pass

    def on_key(window, key, scancode, action, mods):
        gui.update_key(key, scancode, action, mods)

        if action == glfw.PRESS:
            if key == glfw.KEY_ESCAPE:
                on_close(window)
            if mods == glfw.MOD_SUPER:
                if key == 67:
                    # copy value to system clipboard
                    # ideally copy what is in our text input area
                    test_val = "copied text input"
                    glfw.set_clipboard_string(window, test_val)
                    print("set clipboard to: %s" % (test_val))
                if key == 86:
                    # copy from system clipboard
                    clipboard = glfw.get_clipboard_string(window)
                    print("pasting from clipboard: %s" % (clipboard))

    def on_char(window, char):
        gui.update_char(char)

    def on_button(window, button, action, mods):
        gui.update_button(button, action, mods)
        # pos = normalize(pos,glfw.get_window_size(window))
        # pos = denormalize(pos,(frame.img.shape[1],frame.img.shape[0]) ) # Position in img pixels

    def on_pos(window, x, y):
        hdpi_factor = float(
            glfw.get_framebuffer_size(window)[0] /
            glfw.get_window_size(window)[0])
        x, y = x * hdpi_factor, y * hdpi_factor
        gui.update_mouse(x, y)

    def on_scroll(window, x, y):
        gui.update_scroll(x, y)

    def on_close(window):
        global quit
        quit = True
        logger.info("Process closing from window")

    # get glfw started
    glfw.init()

    window = glfw.create_window(width, height, "pyglui demo", None, None)
    if not window:
        exit()

    glfw.set_window_pos(window, 0, 0)
    # Register callbacks for the window
    glfw.set_window_size_callback(window, on_resize)
    glfw.set_window_close_callback(window, on_close)
    glfw.set_window_iconify_callback(window, on_iconify)
    glfw.set_key_callback(window, on_key)
    glfw.set_char_callback(window, on_char)
    glfw.set_mouse_button_callback(window, on_button)
    glfw.set_cursor_pos_callback(window, on_pos)
    glfw.set_scroll_callback(window, on_scroll)
    # test out new paste function

    glfw.make_context_current(window)
    init()
    basic_gl_setup()

    print(glGetString(GL_VERSION))

    class Temp(object):
        """Temp class to make objects"""
        def __init__(self):
            pass

    foo = Temp()
    foo.bar = 34
    foo.sel = "mi"
    foo.selection = ["€", "mi", u"re"]

    foo.mytext = "some text"
    foo.T = True
    foo.L = False

    def set_text_val(val):
        foo.mytext = val
        # print 'setting to :',val

    def pr():
        print("pyglui version: %s" % (ui.__version__))

    gui = ui.UI()
    gui.scale = 1.0
    thumbbar = ui.Scrolling_Menu("ThumbBar",
                                 pos=(-80, 0),
                                 size=(0, 0),
                                 header_pos="hidden")
    menubar = ui.Scrolling_Menu("MenueBar",
                                pos=(-500, 0),
                                size=(-90, 0),
                                header_pos="left")

    gui.append(menubar)
    gui.append(thumbbar)

    T = ui.Growing_Menu("T menu", header_pos="headline")
    menubar.append(T)
    L = ui.Growing_Menu("L menu", header_pos="headline")
    menubar.append(L)
    M = ui.Growing_Menu("M menu", header_pos="headline")
    menubar.append(M)

    def toggle_menu(collapsed, menu):
        menubar.collapsed = collapsed
        for m in menubar.elements:
            m.collapsed = True
        menu.collapsed = collapsed

    thumbbar.append(
        ui.Thumb(
            "collapsed",
            T,
            label="T",
            on_val=False,
            off_val=True,
            setter=lambda x: toggle_menu(x, T),
        ))
    thumbbar.append(
        ui.Thumb(
            "collapsed",
            L,
            label="L",
            on_val=False,
            off_val=True,
            setter=lambda x: toggle_menu(x, L),
        ))
    thumbbar.append(
        ui.Thumb(
            "collapsed",
            M,
            label="M",
            on_val=False,
            off_val=True,
            setter=lambda x: toggle_menu(x, M),
        ))

    # thumbbar.elements[-1].order = -10.0
    print("order" + str(thumbbar.elements[-1].order))
    T.append(ui.Button("T test", pr))
    T.append(
        ui.Info_Text(
            "T best finerfpiwnesdco'n wfo;ineqrfo;inwefo'qefr voijeqfr'p9qefrp'i 'iqefr'ijqfr eqrfiqerfn'ioer"
        ))
    L.append(ui.Button("L test", pr))
    L.append(ui.Button("L best", pr))
    M.append(ui.Button("M test", pr))
    M.append(ui.Button("M best", pr))
    MM = ui.Growing_Menu("MM menu", pos=(0, 0), size=(0, 400))
    M.append(MM)
    for x in range(20):
        MM.append(ui.Button("M test%s" % x, pr))
    M.append(ui.Button("M best", pr))
    M.append(ui.Button("M best", pr))
    M.append(ui.Button("M best", pr))
    M.append(ui.Button("M best", pr))
    M.append(ui.Button("M best", pr))
    M.append(ui.Button("M best", pr))
    M.append(ui.Button("M best", pr))
    # label = 'Ï'
    # label = 'R'
    # gui.append(
    import os
    import psutil

    pid = os.getpid()
    ps = psutil.Process(pid)
    ts = time.time()

    from pyglui import graph

    print(graph.__version__)
    cpu_g = graph.Line_Graph()
    cpu_g.pos = (50, 100)
    cpu_g.update_fn = ps.cpu_percent
    cpu_g.update_rate = 5
    cpu_g.label = "CPU %0.1f"

    fps_g = graph.Line_Graph()
    fps_g.pos = (50, 100)
    fps_g.update_rate = 5
    fps_g.label = "%0.0f FPS"
    fps_g.color[:] = 0.1, 0.1, 0.8, 0.9

    on_resize(window, *glfw.get_window_size(window))

    while not quit:
        gui.update()
        # print(T.collapsed,L.collapsed,M.collapsed)
        # T.collapsed = True
        # glfw.make_context_current(window)
        glfw.swap_buffers(window)
        glfw.poll_events()
        # adjust_gl_view(1280,720,window)
        glClearColor(0.3, 0.4, 0.1, 1)
        glClear(GL_COLOR_BUFFER_BIT)

    gui.terminate()
    glfw.terminate()
    logger.debug("Process done")