当前位置: 首页>>代码示例>>Python>>正文


Python glfw.KEY_ESCAPE属性代码示例

本文整理汇总了Python中glfw.KEY_ESCAPE属性的典型用法代码示例。如果您正苦于以下问题:Python glfw.KEY_ESCAPE属性的具体用法?Python glfw.KEY_ESCAPE怎么用?Python glfw.KEY_ESCAPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在glfw的用法示例。


在下文中一共展示了glfw.KEY_ESCAPE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: key_callback

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_callback(self, window, key, scancode, action, mods):
        if action == glfw.PRESS:
            tgt = self.keypress
        elif action == glfw.RELEASE:
            tgt = self.keyup
        elif action == glfw.REPEAT:
            tgt = self.keyrepeat
        else:
            return
        if tgt.get(key):
            for fn in tgt[key]:
                fn(window, key, scancode, action, mods)
        if tgt.get("any"):
            for fn in tgt["any"]:
                fn(window, key, scancode, action, mods)
            # retain functionality for closing the viewer
            if key == glfw.KEY_ESCAPE:
                super().key_callback(window, key, scancode, action, mods)
        else:
            # only use default mujoco callbacks if "any" callbacks are unset
            super().key_callback(window, key, scancode, action, mods) 
开发者ID:StanfordVL,项目名称:robosuite,代码行数:23,代码来源:mujoco_py_renderer.py

示例2: _map_keys

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def _map_keys(self):
        key_map = self.io.key_map

        key_map[imgui.KEY_TAB] = glfw.KEY_TAB
        key_map[imgui.KEY_LEFT_ARROW] = glfw.KEY_LEFT
        key_map[imgui.KEY_RIGHT_ARROW] = glfw.KEY_RIGHT
        key_map[imgui.KEY_UP_ARROW] = glfw.KEY_UP
        key_map[imgui.KEY_DOWN_ARROW] = glfw.KEY_DOWN
        key_map[imgui.KEY_PAGE_UP] = glfw.KEY_PAGE_UP
        key_map[imgui.KEY_PAGE_DOWN] = glfw.KEY_PAGE_DOWN
        key_map[imgui.KEY_HOME] = glfw.KEY_HOME
        key_map[imgui.KEY_END] = glfw.KEY_END
        key_map[imgui.KEY_DELETE] = glfw.KEY_DELETE
        key_map[imgui.KEY_BACKSPACE] = glfw.KEY_BACKSPACE
        key_map[imgui.KEY_ENTER] = glfw.KEY_ENTER
        key_map[imgui.KEY_ESCAPE] = glfw.KEY_ESCAPE
        key_map[imgui.KEY_A] = glfw.KEY_A
        key_map[imgui.KEY_C] = glfw.KEY_C
        key_map[imgui.KEY_V] = glfw.KEY_V
        key_map[imgui.KEY_X] = glfw.KEY_X
        key_map[imgui.KEY_Y] = glfw.KEY_Y
        key_map[imgui.KEY_Z] = glfw.KEY_Z 
开发者ID:swistakm,项目名称:pyimgui,代码行数:24,代码来源:glfw.py

示例3: key_input_clb

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_input_clb(window, key, scancode, action, mode):
    global left, right, forward, backward
    if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
        glfw.set_window_should_close(window, True)

    if key == glfw.KEY_W and action == glfw.PRESS:
        forward = True
    elif key == glfw.KEY_W and action == glfw.RELEASE:
        forward = False
    if key == glfw.KEY_S and action == glfw.PRESS:
        backward = True
    elif key == glfw.KEY_S and action == glfw.RELEASE:
        backward = False
    if key == glfw.KEY_A and action == glfw.PRESS:
        left = True
    elif key == glfw.KEY_A and action == glfw.RELEASE:
        left = False
    if key == glfw.KEY_D and action == glfw.PRESS:
        right = True
    elif key == glfw.KEY_D and action == glfw.RELEASE:
        right = False


# do the movement, call this function in the main loop 
开发者ID:totex,项目名称:Learn-OpenGL-in-python,代码行数:26,代码来源:ep21_texturing_from_framebuffers.py

示例4: key_callback

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_callback(self, window, key, scancode, action, mods):
        # Trigger on keyup only:
        if action != glfw.RELEASE:
            return
        if key == glfw.KEY_ESCAPE:
            self.env.close()

        # Increment experiment seed
        elif key == glfw.KEY_N:
            self.seed[0] += 1
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        # Decrement experiment trial
        elif key == glfw.KEY_P:
            self.seed = [max(self.seed[0] - 1, 0)]
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        if key == glfw.KEY_A:
            if isinstance(self.env.action_space, Box):
                self.action[self.action_mod_index] -= 0.05
        elif key == glfw.KEY_Z:
            if isinstance(self.env.action_space, Box):
                self.action[self.action_mod_index] += 0.05
        elif key == glfw.KEY_K:
            self.action_mod_index = (self.action_mod_index + 1) % self.num_action
        elif key == glfw.KEY_J:
            self.action_mod_index = (self.action_mod_index - 1) % self.num_action

        super().key_callback(window, key, scancode, action, mods) 
开发者ID:openai,项目名称:mujoco-worldgen,代码行数:33,代码来源:env_viewer.py

示例5: keyboard_callback

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def keyboard_callback(self, window, key, scancode, action, mods):
    self.impl.keyboard_callback(window, key, scancode, action, mods)

    if not imgui.get_io().want_capture_keyboard:
      if key == glfw.KEY_B or key == glfw.KEY_LEFT:
        self.currentTimestep = self.sliderValue = max(0, self.currentTimestep - 1)

      if key == glfw.KEY_N or key == glfw.KEY_RIGHT:
        self.currentTimestep = self.sliderValue = min(self.num_scans - 1, self.currentTimestep + 1)

      if key == glfw.KEY_Q or key == glfw.KEY_ESCAPE:
        exit(0) 
开发者ID:PRBonn,项目名称:semantic-kitti-api,代码行数:14,代码来源:visualize_voxels.py

示例6: key_input_clb

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_input_clb(window, key, scancode, action, mode):
    global left, right, forward, backward
    if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
        glfw.set_window_should_close(window, True)

    if key == glfw.KEY_W and action == glfw.PRESS:
        forward = True
    elif key == glfw.KEY_W and action == glfw.RELEASE:
        forward = False
    if key == glfw.KEY_S and action == glfw.PRESS:
        backward = True
    elif key == glfw.KEY_S and action == glfw.RELEASE:
        backward = False
    if key == glfw.KEY_A and action == glfw.PRESS:
        left = True
    elif key == glfw.KEY_A and action == glfw.RELEASE:
        left = False
    if key == glfw.KEY_D and action == glfw.PRESS:
        right = True
    elif key == glfw.KEY_D and action == glfw.RELEASE:
        right = False
    # if key in [glfw.KEY_W, glfw.KEY_S, glfw.KEY_D, glfw.KEY_A] and action == glfw.RELEASE:
    #     left, right, forward, backward = False, False, False, False


# do the movement, call this function in the main loop 
开发者ID:totex,项目名称:Learn-OpenGL-in-python,代码行数:28,代码来源:ep18_camera_WASD.py

示例7: key_input_clb

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_input_clb(window, key, scancode, action, mode):
    if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
        glfw.set_window_should_close(window, True)


# the mouse position callback function 
开发者ID:totex,项目名称:Learn-OpenGL-in-python,代码行数:8,代码来源:ep17_camera_mouse_capture.py

示例8: key_callback

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_callback(self, window, key, scancode, action, mods):
        "press ESCAPE to quit the application"
        if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
            glfw.set_window_should_close(self.window, True) 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:6,代码来源:glfw_app.py

示例9: key_callback

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_callback(self, window, key, _scan_code, action, _mods):
        if action == glfw.PRESS:
            if key == glfw.KEY_ESCAPE:
                glfw.set_window_should_close(window, True)
            if key == glfw.KEY_C:
                self.show_cubes = not self.show_cubes 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:8,代码来源:hellovr_glfw.py

示例10: key_callback

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import KEY_ESCAPE [as 别名]
def key_callback(self, window, key, scancode, action, mods):
        # Trigger on keyup only:
        if action != glfw.RELEASE:
            return
        if key == glfw.KEY_ESCAPE:
            self.env.close()

        # Increment experiment seed
        elif key == glfw.KEY_N:
            self.seed[0] += 1
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        # Decrement experiment trial
        elif key == glfw.KEY_P:
            self.seed = [max(self.seed[0] - 1, 0)]
            self.env.seed(self.seed)
            self.env_reset()
            self.action = self.zero_action(self.env.action_space)
        current_action_space = self.env.action_space.spaces[self.action_types[self.action_type_mod_index]].spaces[0]
        if key == glfw.KEY_A:
            if isinstance(current_action_space, Box):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] -= 0.05
            elif isinstance(current_action_space, Discrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] - 1) % current_action_space.n
            elif isinstance(current_action_space, MultiDiscrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] - 1) \
                    % current_action_space.nvec[self.action_mod_index]
        elif key == glfw.KEY_Z:
            if isinstance(current_action_space, Box):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] += 0.05
            elif isinstance(current_action_space, Discrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] + 1) % current_action_space.n
            elif isinstance(current_action_space, MultiDiscrete):
                self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] = \
                    (self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] + 1) \
                    % current_action_space.nvec[self.action_mod_index]
        elif key == glfw.KEY_K:
            self.action_mod_index = (self.action_mod_index + 1) % self.num_action[self.action_type_mod_index]
        elif key == glfw.KEY_J:
            self.action_mod_index = (self.action_mod_index - 1) % self.num_action[self.action_type_mod_index]
        elif key == glfw.KEY_Y:
            self.agent_mod_index = (self.agent_mod_index + 1) % self.n_agents
        elif key == glfw.KEY_U:
            self.agent_mod_index = (self.agent_mod_index - 1) % self.n_agents
        elif key == glfw.KEY_G:
            self.action_type_mod_index = (self.action_type_mod_index + 1) % self.num_action_types
            self.action_mod_index = 0
        elif key == glfw.KEY_B:
            self.action_type_mod_index = (self.action_type_mod_index - 1) % self.num_action_types
            self.action_mod_index = 0

        super().key_callback(window, key, scancode, action, mods) 
开发者ID:openai,项目名称:multi-agent-emergence-environments,代码行数:58,代码来源:env_viewer.py


注:本文中的glfw.KEY_ESCAPE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。