當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。