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


Python key.symbol_string函数代码示例

本文整理汇总了Python中pyglet.window.key.symbol_string函数的典型用法代码示例。如果您正苦于以下问题:Python symbol_string函数的具体用法?Python symbol_string怎么用?Python symbol_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _key_callback

    def _key_callback(self, symbol, modifiers, event_time):
        # check the key and time (if this is needed)
        keys = val(self.keys)
        correct_resp = val(self.correct_resp)
        sym_str = key.symbol_string(symbol)
        if None in keys or sym_str in keys:
            # it's all good!, so save it
            self.pressed = sym_str
            self.press_time = event_time

            # fill the base time val
            self.base_time = val(self.base_time_src)
            if self.base_time is None:
                # set it to the state time
                self.base_time = self.state_time
            
            # calc RT if something pressed
            self.rt = event_time['time']-self.base_time

            if self.pressed in correct_resp:
                self.correct = True

            # let's leave b/c we're all done
            #self.interval = 0
            self.leave()
开发者ID:chadillac2313,项目名称:smile,代码行数:25,代码来源:keyboard.py

示例2: test_certain_modifier_key_presses_do_not_change_state

    def test_certain_modifier_key_presses_do_not_change_state(self):
        app = MockApp()
        state = dispatcher.init_state(dispatcher.default_state, app, None)
        state.send(NormalEvent(ON_KEY_PRESS, pkey.M))
        current_state = state.gi_frame.f_locals['current_state']
        self.assertEqual(current_state.__name__, 'marking')

        keys = [
            pkey.LSHIFT, pkey.RSHIFT,
            pkey.LCTRL, pkey.RCTRL,
            pkey.CAPSLOCK,
            pkey.LMETA, pkey.RMETA,
            pkey.LALT, pkey.RALT,
            pkey.LWINDOWS, pkey.RWINDOWS,
            pkey.LCOMMAND, pkey.RCOMMAND,
            pkey.LOPTION, pkey.ROPTION
        ]

        for key in keys:
            state.send(NormalEvent(ON_KEY_PRESS, key))
            current_state = state.gi_frame.f_locals['current_state']
            self.assertIsNotNone(current_state,
                    msg="{} has changed the state".format(pkey.symbol_string(key)))
            self.assertEqual(current_state.__name__, 'marking',
                    msg="current_state was changed by {}".format(pkey.symbol_string(key)))
开发者ID:bracket,项目名称:VIctor,代码行数:25,代码来源:normal_dispatcher_test.py

示例3: on_key_release

 def on_key_release(self, inp, modifers):
     if symbol_string(inp) == "LEFT":
         self.sprite.dx = 0
         print("release left, dx:", self.sprite.dx)
     if symbol_string(inp) == "RIGHT":
         self.sprite.dx = 0
         print("release right, dx:", self.sprite.dx)
开发者ID:dangillet,项目名称:etc_code,代码行数:7,代码来源:start.py

示例4: on_key_press

def on_key_press(symbol, modifiers):
    if key.symbol_string(symbol) == 'SPACE':
        environment.active = not environment.active
    if key.symbol_string(symbol) == 'S':
        environment.mode = 'S'
    if key.symbol_string(symbol) == 'C':
        environment.mode = 'C'
开发者ID:kayak0806,项目名称:pretty-pictures,代码行数:7,代码来源:vertexies_verbose.py

示例5: save_exp

    def save_exp(self, rest_time=1):
        name = inspect.getouterframes(inspect.currentframe())[1][1] #get the file path that called save_exp
        name = name.rsplit('/')[-1].rsplit('.')[0]                  #get its name without '.py'
        self.names.append(name)

        # experiment class
        self.curr_experiment.name = name

        # there is at least one test, so
        # this is not a rest file, so assign a key
        if self.curr_experiment.tests != []: 
            self.experiments.append(self.curr_experiment)
            ind = len(self.experiments)-1
            curr_key = [key._1, key._2, key._3, key._4, key._5,
                        key._6, key._7, key._8, key._9][ind]
            if ind<=8:
                self.window.add_key_action(curr_key, self.begin_experiment, ind)
            if ind==0: print '\nScheduler key assignments:'
            print key.symbol_string(curr_key) + ' - ' + name

        # since this is not a test file and there is at least one
        # rest, add it to rests and make it the default rest
        elif self.curr_experiment.rest != []:
            self.rests.append(self.curr_experiment)
            print 'rest - ' + name

        self.curr_experiment = None #clear it for the next save
开发者ID:npalermo10,项目名称:holocube,代码行数:27,代码来源:oldschedulers3.py

示例6: on_key_press

    def on_key_press(self, key, modifiers):
        if symbol_string(key) == "T":
            self.do(Twirl(amplitude=5, duration=2))

        elif symbol_string(key) == "W":
            self.do(Reverse(Waves(duration=2)))

        elif symbol_string(key) == "F":
            self.do(FlipX3D(duration=1) + FlipY3D(duration=1) + Reverse(FlipY3D(duration=1)))
开发者ID:MagicPwn,项目名称:cocos2d-python-tutorials,代码行数:9,代码来源:effects.py

示例7: on_key_release

 def on_key_release(self, symbol, modifiers):
     letter = key.symbol_string(symbol)
     if self.verbose: print("release:",letter,key.modifiers_string(modifiers))
     
     _keyboard.remove(key.symbol_string(symbol))
     if self.keyrelease is not None:
         kwargs = {
         "window":self,
         "symbol":key.symbol_string(symbol),
         "modifiers":key.modifiers_string(modifiers)
         }
         self.keyrelease(**kwargs)
开发者ID:Faore,项目名称:bin-packing,代码行数:12,代码来源:ez.py

示例8: on_key_press

 def on_key_press(self, symbol, modifiers):
     letter = key.symbol_string(symbol)
     if self.verbose:
         print("press:",letter,key.modifiers_string(modifiers))
     _keyboard.add(key.symbol_string(symbol))
     if self.keypress is not None:
         kwargs = {
         "window":self,
         "symbol":key.symbol_string(symbol),
         "modifiers":key.modifiers_string(modifiers)
         }
         self.keypress(**kwargs)
开发者ID:Faore,项目名称:bin-packing,代码行数:12,代码来源:ez.py

示例9: on_key_press

    def on_key_press(self, key, modifiers):
        # First I create a move action because we programmers are lazy and hate having to retype code!
        move_left = MoveBy((-50, 0), .5)

        # Here's where that Pyglet symbol_string() function comes in handy
        # Rather than having to interpret an inconsistent code, I can simply interpret the word LEFT and RIGHT
        if symbol_string(key) == "LEFT":
            self.sprite.do(move_left)

        # Now I need to tell the layer what to do if the user inputs RIGHT
        if symbol_string(key) == "RIGHT":
            # This is a pretty awesome feature built into Cocos
            # I only wrote code for moving left, but I can use the Reverse() function instead of rewriting code
            # Reverse() simply tells Cocos to do the reverse action of whatever you pass into it.
            self.sprite.do(Reverse(move_left))
开发者ID:alexeygolovin5587,项目名称:dashboard,代码行数:15,代码来源:Code.py

示例10: get_key_string

 def get_key_string(self, value):
     value = key.symbol_string(value)
     if value.startswith('_'):
         value = value[1:]
     if value == 'LCTRLREAL':
         return 'LCTRL'
     return value
开发者ID:carriercomm,项目名称:anaconda,代码行数:7,代码来源:Keyboard.py

示例11: on_key_release

 def on_key_release(self, key, modifiers):
     k = symbol_string(key)
     status = False
     if k == "LEFT":
         self.key_pressed_left = status
     elif k == "RIGHT":
         self.key_pressed_right = status
开发者ID:lhwd521,项目名称:pythongame,代码行数:7,代码来源:main.py

示例12: on_key_press

 def on_key_press(self, key, modifiers):
     k = symbol_string(key)
     status = True
     if k == "LEFT":
         self.key_pressed_left = status
     elif k == "RIGHT":
         self.key_pressed_right = status
     elif k == "SPACE" and self.life == 1:
         if self.jump_count > 0:
             x, y = self.sprite.position
             try:
                 self.remove(self.jump1)
             except:
                 pass
             # jump效果图
             self.jump1 = Sprite("images/jump.png")
             self.jump1.opacity = 250
             self.jump1.position = (x, y-100)
             self.add(self.jump1)
             self.jump_speed = 20
             self.jump_y = y
             self.key_pressed_up = True
             self.jump_count -= 1
     elif k == "DOWN":
         self.key_pressed_down = status
     elif k == "SPACE" and self.life == 0:
         scene = Scene(GameLayer())
         director.replace(SplitColsTransition(scene))
开发者ID:lhwd521,项目名称:pythongame,代码行数:28,代码来源:main.py

示例13: on_key_press

    def on_key_press(self, symbol, modifiers):
        if pymterm.debug_log:
            LOGGER.debug('on_key_press:{}, {}'.format(
                key.symbol_string(symbol),
                key.modifiers_string(modifiers)))

        key_state = KeyState(symbol, modifiers)

        if symbol == key.Q and \
           (modifiers == key.MOD_COMMAND or modifiers == key.MOD_CTRL):
            self.close()
            return

        if self.session.terminal.process_key(key_state):
            if pymterm.debug_log:
                LOGGER.debug(' processed by pyterm')
            return

        v, handled = term.term_keyboard.translate_key(self.session.terminal,
                                                      key_state)

        if len(v) > 0:
            self.session.send(v)

        self._key_first_down = True
开发者ID:stonewell,项目名称:pymterm,代码行数:25,代码来源:window_base.py

示例14: key

 def key(self, symbol, modifiers):
     """ Key pressed event handler.
     """
     if symbol == key.F1:
         self.mode = 1
         self.default()
         print "Projection: Pyglet default"
     if symbol == key.NUM_0:
         global correction_rmatrix1, zero_rmatrix, rmatrix1
         correction_rmatrix1 = np.dot(zero_rmatrix, np.linalg.inv(rmatrix1))
     elif symbol == key.F2:
         print "Projection: 3D Isometric"
         self.mode = 2
         self.isometric()
     elif symbol == key.F3:
         print "Projection: 3D Perspective"
         self.mode = 3
         self.perspective()
     elif self.mode == 3 and symbol == key.NUM_SUBTRACT:
         self.fov -= 1
         self.perspective()
     elif self.mode == 3 and symbol == key.NUM_ADD:
         self.fov += 1
         self.perspective()
     else:
         print "KEY " + key.symbol_string(symbol)
开发者ID:khalednasr,项目名称:bcra,代码行数:26,代码来源:simulation.py

示例15: print_keypress_actions

 def print_keypress_actions(self):
     items = sorted(self.keypress_actions.items())
     for keypress, action in items:
         keysymbol = key.symbol_string(keypress[0]).lstrip(' _')
         modifiers = key.modifiers_string(keypress[1]).replace('MOD_', '').replace('|', ' ').lstrip(' ')
         func, args, kwargs = action[0].__name__, action[1], action[2]
         print('{:<10} {:<6} --- {:<30}({}, {})'.format(modifiers, keysymbol, func, args, kwargs))
开发者ID:npalermo10,项目名称:holocube,代码行数:7,代码来源:windows.py


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