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


Python Scene.push_handlers方法代码示例

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


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

示例1: WilliamsEnvironment

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import push_handlers [as 别名]
class WilliamsEnvironment(object):
    
    title = "The Williams' Search Task"
        
    def __init__(self):
        
        if not os.path.exists("data"): os.mkdir("data")
        
        pyglet.resource.path.append('resources')
        pyglet.resource.reindex()
        pyglet.resource.add_font('Pipe_Dream.ttf')
        pyglet.resource.add_font('cutouts.ttf')
        
        director.set_show_FPS(False)
        director.init(fullscreen=True, caption=self.title, visible=True, resizable=True)

        width = director.window.width
        height = director.window.height

        director.window.set_fullscreen(False)
        director.window.set_size(int(width * .75), int(height * .75))

        director.window.pop_handlers()
        director.window.push_handlers(Handler())

        director.settings = {'seed':'1',
                             'eyetracker': True,
                             'eyetracker_ip': '127.0.0.1',
                             'eyetracker_out_port': '4444',
                             'eyetracker_in_port': '5555',
                             'player': 'Human',
                             'players': ['Human'],
                             'mode': 'Insane',
                             'modes': ['Easy', 'Moderate', 'Hard', 'Insane', 'Experiment']}
        
        self.client = None
        self.client_actr = None
        
        if ACTR6:
            director.settings['players'].append("ACT-R")
            #director.settings['player'] = "ACT-R"
            director.settings['eyetracker'] = False
            self.client_actr = JNI_Server(self)
            self.listener_actr = reactor.listenTCP(6666, self.client_actr)
        elif eyetracking:
            self.client = iViewXClient(director.settings['eyetracker_ip'], int(director.settings['eyetracker_out_port']))
            self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client) 
        
        if platform.system() != 'Windows':
            director.window.set_icon(pyglet.resource.image('logo.png'))
            cursor = director.window.get_system_mouse_cursor(director.window.CURSOR_HAND)
            director.window.set_mouse_cursor(cursor)
        
        # Intro scene and its layers        
        self.introScene = Scene()
                    
        self.mainMenu = MainMenu()
        self.optionsMenu = OptionsMenu()
        self.participantMenu = ParticipantMenu()
        self.introBackground = BackgroundLayer()
        self.eyetrackerScrim = EyetrackerScrim()
        
        self.introScene.add(self.introBackground)
        self.mplxLayer = MultiplexLayer(self.mainMenu, self.optionsMenu, self.participantMenu)
        self.introScene.add(self.mplxLayer, 1)
        
        self.introScene.register_event_type('start_task')
        self.introScene.register_event_type('eyetracker_info_changed')
        self.introScene.push_handlers(self)
        
        # Task scene and its layers
        self.taskScene = Scene()
        
        self.taskBackgroundLayer = TaskBackground()
        self.taskLayer = Task(self.client, self.client_actr)
        self.actrScrim = ACTRScrim()
        
        if self.client:
            self.calibrationLayer = CalibrationLayer(self.client)
            self.calibrationLayer.register_event_type('show_headposition')
            self.calibrationLayer.register_event_type('hide_headposition')
            self.calibrationLayer.push_handlers(self)
            self.headpositionLayer = HeadPositionLayer(self.client)
        
        self.taskLayer.register_event_type('new_trial')
        self.taskLayer.push_handlers(self.taskBackgroundLayer)
        self.taskLayer.register_event_type('start_calibration')
        self.taskLayer.register_event_type('stop_calibration')
        self.taskLayer.register_event_type('show_headposition')
        self.taskLayer.register_event_type('hide_headposition')
        self.taskLayer.register_event_type('actr_wait_connection')
        self.taskLayer.register_event_type('actr_wait_model')
        self.taskLayer.register_event_type('actr_running')
        self.taskLayer.push_handlers(self)
        
        self.taskScene.add(self.taskBackgroundLayer)
        self.taskScene.add(self.taskLayer, 1)
        self.actrScrim.visible = False
        self.taskScene.add(self.actrScrim, 3)
        
#.........这里部分代码省略.........
开发者ID:CogWorks,项目名称:WilliamsTask,代码行数:103,代码来源:main.py

示例2: WhackAMole

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import push_handlers [as 别名]
class WhackAMole(object):
    
    title = "Whack A Mole"
        
    def __init__(self):
        
        if not os.path.exists("data"): os.mkdir("data")
            
        pyglet.resource.path.append('resources')
        pyglet.resource.reindex()
        pyglet.resource.add_font('cutouts.ttf')
        pyglet.resource.add_font('scoreboard.ttf')
        
        director.init(width=int(1024*1.0), height=int(768*1.1),
                  caption=self.title, visible=False, resizable=True)
        director.window.set_size(int(1024*1.0), int(768*1.1))
        
        director.window.pop_handlers()
        director.window.push_handlers(DefaultHandler())
                    
        director.settings = {'overlay': False,
                             'eyetracker': True,
                             'eyetracker_ip': '127.0.0.1',
                             'eyetracker_out_port': '4444',
                             'eyetracker_in_port': '5555',
                             'calibration_speed': 1,
                             'calibration_wait': 1,
                             'calibration_random': 1,
                             'calibration_level': 3,
                             'calibration_auto': 1,
                             'calibration_points': 2,
                             'calibration_eye': 0
                            }
        
        self.client = None
        
        self.client = iViewXClient(director.settings['eyetracker_ip'], int(director.settings['eyetracker_out_port']))
        self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client)

        director.set_show_FPS(False)
        director.window.set_fullscreen(False)
        if director.settings['eyetracker']:
            director.window.set_mouse_visible(False)
        else:
            director.window.set_mouse_visible(True)
                
        # Intro scene and its layers        
        self.introScene = Scene()
                    
        self.mainMenu = MainMenu()
        self.optionsMenu = OptionsMenu()
        self.eyetrackerScrim = EyetrackerScrim()
        
        self.mplxLayer = MultiplexLayer(self.mainMenu, self.optionsMenu)
        self.introScene.add(self.mplxLayer, 1)
        
        self.introScene.register_event_type('start_task')
        self.introScene.register_event_type('eyetracker_info_changed')
        self.introScene.push_handlers(self)
                
        # Task scene and its layers
        self.taskScene = Scene()
        self.taskLayer = Task(self.client)

        self.calibrationLayer = CalibrationLayer(self.client)
        self.calibrationLayer.register_event_type('show_headposition')
        self.calibrationLayer.register_event_type('hide_headposition')
        self.calibrationLayer.push_handlers(self)
        
        self.taskLayer.register_event_type('new_trial')
        self.taskLayer.register_event_type('start_calibration')
        self.taskLayer.register_event_type('stop_calibration')
        self.taskLayer.push_handlers(self)
                
        self.taskScene.add(self.taskLayer, 1)
        
        self.taskScene.register_event_type('show_intro_scene')
        self.taskScene.push_handlers(self)
            
        director.window.set_visible(True)
        
    def start_calibration(self, on_success, on_failure):
        self.calibrationLayer.on_success = on_success
        self.calibrationLayer.on_failure = on_failure
        self.calibrationLayer.points = director.settings['calibration_points']
        self.calibrationLayer.eye = director.settings['calibration_eye']
        self.calibrationLayer.level = director.settings['calibration_level']
        self.calibrationLayer.speed = director.settings['calibration_speed']
        self.calibrationLayer.auto = director.settings['calibration_auto']
        self.calibrationLayer.wait = director.settings['calibration_wait']
        self.calibrationLayer.random = director.settings['calibration_random']
        self.taskScene.add(self.calibrationLayer, 2)
        
    def stop_calibration(self):
        self.taskScene.remove(self.calibrationLayer)
            
    def eyetracker_listen(self, _):
        self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client)
        self.introScene.remove(self.eyetrackerScrim)
        self.introScene.enable_handlers(True)
#.........这里部分代码省略.........
开发者ID:CogWorks,项目名称:WhackAMole,代码行数:103,代码来源:whack_a_mole.py

示例3: SnakeEnvironment

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import push_handlers [as 别名]
class SnakeEnvironment(object):
    
    title = "Snake"
        
    def __init__(self):
        
        if not os.path.exists("data"): os.mkdir("data")
        
        pyglet.resource.path.append('resources')
        pyglet.resource.reindex()
        pyglet.resource.add_font('Pipe_Dream.ttf')
        pyglet.resource.add_font('cutouts.ttf')
        pyglet.resource.add_font('scoreboard.ttf')
        
        p = pyglet.window.get_platform()
        d = p.get_default_display()
        s = d.get_default_screen()
        
        director.init(width=s.width, height=s.height,
                  caption=self.title, visible=False, resizable=True)
        director.window.set_size(int(s.width * .75), int(s.height * .75))
        
        director.window.pop_handlers()
        director.window.push_handlers(DefaultHandler())
            
        director.settings = {'eyetracker': True,
                             'eyetracker_ip': '127.0.0.1',
                             'eyetracker_out_port': '4444',
                             'eyetracker_in_port': '5555',
                             'board_size': '31',
                             'speed_factor': '0.990',
                             'fixation_overlay': False,
                             'player': 'Human',
                             'players': ['Human']}
        
        self.client = None
        self.client_actr = None
        
        if ACTR6:
            director.settings['players'].append("ACT-R")
            #director.settings['player'] = "ACT-R"
            director.settings['eyetracker'] = False
            self.client_actr = JNI_Server(self)
            self.listener_actr = reactor.listenTCP(6666, self.client_actr)
        if eyetracking:
            self.client = iViewXClient(director.settings['eyetracker_ip'], int(director.settings['eyetracker_out_port']))
            self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client) 
        
        director.fps_display = clock.ClockDisplay(font=font.load('', 18, bold=True))
        #fps_display = FPSDisplay(director.window)
        #fps_display.label.font_size = 12
        #director.fps_display = fps_display

        director.set_show_FPS(True)
        director.window.set_fullscreen(False)
        director.window.set_mouse_visible(False)
        
        if platform.system() != 'Windows':
            director.window.set_icon(pyglet.resource.image('logo.png'))
        
        # Intro scene and its layers        
        self.introScene = Scene()
                    
        self.mainMenu = MainMenu()
        self.optionsMenu = OptionsMenu()
        self.participantMenu = ParticipantMenu()
        self.introBackground = BackgroundLayer()
        self.eyetrackerScrim = EyetrackerScrim()
        
        self.introScene.add(self.introBackground)
        self.mplxLayer = MultiplexLayer(self.mainMenu, self.optionsMenu, self.participantMenu)
        self.introScene.add(self.mplxLayer, 1)
        
        self.introScene.register_event_type('start_task')
        self.introScene.register_event_type('eyetracker_info_changed')
        self.introScene.push_handlers(self)
        
        # Task scene and its layers
        self.taskScene = Scene()
        
        self.taskBackgroundLayer = TaskBackground()
        self.taskLayer = Task(self.client, self.client_actr)
        self.scoreLayer = self.taskLayer.score_layer
        self.actrScrim = ACTRScrim()
        
        if self.client:
            self.calibrationLayer = CalibrationLayer(self.client)
            self.calibrationLayer.register_event_type('show_headposition')
            self.calibrationLayer.register_event_type('hide_headposition')
            self.calibrationLayer.push_handlers(self)
            self.headpositionLayer = HeadPositionLayer(self.client)
            self.fixationLayer = FixationLayer(self.client)
        
        self.taskLayer.register_event_type('new_trial')
        self.taskLayer.push_handlers(self.taskBackgroundLayer)
        self.taskLayer.register_event_type('start_calibration')
        self.taskLayer.register_event_type('stop_calibration')
        self.taskLayer.register_event_type('show_headposition')
        self.taskLayer.register_event_type('hide_headposition')
        self.taskLayer.register_event_type('show_fixation')
#.........这里部分代码省略.........
开发者ID:CogWorks,项目名称:pySnake,代码行数:103,代码来源:main.py


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