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


Python glfw.destroy_window方法代码示例

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


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

示例1: close

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def close(self):
        """
        Destroys the open window and renders (pun intended) the viewer useless.
        """
        glfw.destroy_window(self.viewer.window)
        self.viewer = None 
开发者ID:StanfordVL,项目名称:robosuite,代码行数:8,代码来源:mujoco_py_renderer.py

示例2: _close_viewer_window

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def _close_viewer_window(self):
        """Close viewer window.

        Unfortunately, some gym environments don't close the viewer windows
        properly, which leads to "out of memory" issues when several of
        these environments are tested one after the other.
        This method searches for the viewer object of type MjViewer, Viewer
        or SimpleImageViewer, based on environment, and if the environment
        is wrapped in other environment classes, it performs depth search
        in those as well.
        This method can be removed once OpenAI solves the issue.
        """
        # We need to do some strange things here to fix-up flaws in gym
        # pylint: disable=import-outside-toplevel
        if self.env.spec:
            if any(package in getattr(self.env.spec, 'entry_point', '')
                   for package in KNOWN_GYM_NOT_CLOSE_MJ_VIEWER):
                # This import is not in the header to avoid a MuJoCo dependency
                # with non-MuJoCo environments that use this base class.
                try:
                    from mujoco_py.mjviewer import MjViewer
                    import glfw
                except ImportError:
                    # If we can't import mujoco_py, we must not have an
                    # instance of a class that we know how to close here.
                    return
                if (hasattr(self.env, 'viewer')
                        and isinstance(self.env.viewer, MjViewer)):
                    glfw.destroy_window(self.env.viewer.window)
            elif any(package in getattr(self.env.spec, 'entry_point', '')
                     for package in KNOWN_GYM_NOT_CLOSE_VIEWER):
                if hasattr(self.env, 'viewer'):
                    from gym.envs.classic_control.rendering import (
                        Viewer, SimpleImageViewer)
                    if (isinstance(self.env.viewer,
                                   (SimpleImageViewer, Viewer))):
                        self.env.viewer.close() 
开发者ID:rlworkgroup,项目名称:garage,代码行数:39,代码来源:garage_env.py

示例3: _close_mjviewer_window

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def _close_mjviewer_window(self):
        """
        Close the MjViewer window.

        Unfortunately, the gym environments using MuJoCo don't close the viewer
        windows properly, which leads to "out of memory" issues when several
        of these environments are tested one after the other.
        This method searches for the viewer object of type MjViewer, and if the
        environment is wrapped in other environment classes, it performs depth
        search in those as well.
        This method can be removed once OpenAI solves the issue.
        """
        if self.env.spec:
            if any(package in self.env.spec._entry_point
                   for package in KNOWN_GYM_NOT_CLOSE_VIEWER):
                # This import is not in the header to avoid a MuJoCo dependency
                # with non-MuJoCo environments that use this base class.
                from mujoco_py.mjviewer import MjViewer
                if (hasattr(self.env, "viewer")
                        and isinstance(self.env.viewer, MjViewer)):
                    glfw.destroy_window(self.env.viewer.window)
                else:
                    env_itr = self.env
                    while hasattr(env_itr, "env"):
                        env_itr = env_itr.env
                        if (hasattr(env_itr, "viewer")
                                and isinstance(env_itr.viewer, MjViewer)):
                            glfw.destroy_window(env_itr.viewer.window)
                            break 
开发者ID:rlworkgroup,项目名称:gym-sawyer,代码行数:31,代码来源:base.py

示例4: stop

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def stop(self):
        if self.viewer is not None:
            v = self.viewer
            self.viewer = None
            glfw.destroy_window(v.window)
            del v 
开发者ID:MushroomRL,项目名称:mushroom-rl,代码行数:8,代码来源:mujoco.py

示例5: dispose_gl

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def dispose_gl(self):
        if self.window:
            glfw.make_context_current(self.window)
            if self.renderer:
                self.renderer.dispose_gl()
        glfw.destroy_window(self.window)
        glfw.terminate()
        self._is_initialized = False 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:10,代码来源:glfw_app.py

示例6: close

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def close(self):
        if self.viewer is not None:
            glfw.destroy_window(self.viewer.window)
            self.viewer = None 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:6,代码来源:mujoco_env.py

示例7: close

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def close(env):
    if env.viewer is not None:
        # self.viewer.finish()
        glfw.destroy_window(env.viewer.window)
    env.viewer = None 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:7,代码来源:demo_sawyer.py

示例8: sample_sawyer_pick_and_place

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_pick_and_place():
    env = SawyerPickAndPlaceEnv()
    env.reset()
    for _ in range(200):
        env.render()
        env.step(env.action_space.sample())
        time.sleep(0.05)
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:10,代码来源:demo_sawyer.py

示例9: sample_sawyer_pick_and_place_wsg

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_pick_and_place_wsg():
    env = SawyerPickAndPlaceWsgEnv()
    env.reset()
    for _ in range(100):
        env.render()
        env.step(np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]))
        time.sleep(0.05)
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:10,代码来源:demo_sawyer.py

示例10: sample_sawyer_push_and_reach_two_pucks

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_push_and_reach_two_pucks():
    env = SawyerPushAndReachXYZDoublePuckEnv()
    env.reset()
    for i in range(100):
        env.render()
        env.set_goal({'state_desired_goal': np.array([1, 1, 1, 1, 1, 1, 1])})
        env.step(env.action_space.sample())
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:10,代码来源:demo_sawyer.py

示例11: sample_sawyer_push_multiobj

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_push_multiobj():
    env = SawyerTwoObjectEnv()
    for _ in range(100):
        env.render()
        env.step(np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]))
        time.sleep(0.05)
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:9,代码来源:demo_sawyer.py

示例12: sample_sawyer_push_nips

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_push_nips():
    env = SawyerPushAndReachXYEasyEnv()
    for _ in range(100):
        env.render()
        env.step(env.action_space.sample())
        time.sleep(0.05)
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:9,代码来源:demo_sawyer.py

示例13: sample_sawyer_reach

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_reach():
    env = SawyerReachXYZEnv()
    for i in range(100):
        if i % 100 == 0:
            env.reset()
        env.step(np.array([0, 1, 1]))
        env.render()
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:10,代码来源:demo_sawyer.py

示例14: sample_sawyer_reach_push_pick_place

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_reach_push_pick_place():
    env = SawyerReachPushPickPlaceEnv()
    for i in range(100):
        if i % 100 == 0:
            env.reset()
        env.step(np.array([0, 1, 1]))
        env.render()
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:10,代码来源:demo_sawyer.py

示例15: sample_sawyer_rope

# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import destroy_window [as 别名]
def sample_sawyer_rope():
    env = SawyerRopeEnv()
    env.reset()
    for _ in range(50):
        env.render()
        env.step(env.action_space.sample())
        time.sleep(0.05)
    glfw.destroy_window(env.viewer.window) 
开发者ID:rlworkgroup,项目名称:metaworld,代码行数:10,代码来源:demo_sawyer.py


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