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


Python pygame.USEREVENT属性代码示例

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


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

示例1: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def __init__(self):
        # Init pygame
        pygame.init()

        # Creat pygame window
        pygame.display.set_caption("Tello video stream")
        self.screen = pygame.display.set_mode([960, 720])

        # Init Tello object that interacts with the Tello drone
        self.tello = Tello()

        # Drone velocities between -100~100
        self.for_back_velocity = 0
        self.left_right_velocity = 0
        self.up_down_velocity = 0
        self.yaw_velocity = 0
        self.speed = 10

        self.send_rc_control = False

        # create update timer
        pygame.time.set_timer(pygame.USEREVENT + 1, 1000 // FPS) 
开发者ID:damiafuentes,项目名称:DJITelloPy,代码行数:24,代码来源:manual-control-pygame.py

示例2: todo_test_set_timer

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def todo_test_set_timer(self):

        # __doc__ (as of 2008-08-02) for pygame.time.set_timer:

          # pygame.time.set_timer(eventid, milliseconds): return None
          # repeatedly create an event on the event queue
          #
          # Set an event type to appear on the event queue every given number of
          # milliseconds. The first event will not appear until the amount of
          # time has passed.
          #
          # Every event type can have a separate timer attached to it. It is
          # best to use the value between pygame.USEREVENT and pygame.NUMEVENTS.
          #
          # To disable the timer for an event, set the milliseconds argument to 0.

        self.fail() 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:19,代码来源:time_test.py

示例3: test_Event

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_Event(self):
        """Ensure an Event object can be created."""
        e = pygame.event.Event(pygame.USEREVENT, some_attr=1, other_attr='1')

        self.assertEqual(e.some_attr, 1)
        self.assertEqual(e.other_attr, "1")

        # Event now uses tp_dictoffset and tp_members: request 62
        # on Motherhamster Bugzilla.
        self.assertEqual(e.type, pygame.USEREVENT)
        self.assertIs(e.dict, e.__dict__)

        e.some_attr = 12

        self.assertEqual(e.some_attr, 12)

        e.new_attr = 15

        self.assertEqual(e.new_attr, 15)

        # For Python 2.x a TypeError is raised for a readonly member;
        # for Python 3.x it is an AttributeError.
        self.assertRaises((TypeError, AttributeError), setattr, e, 'type', 0)
        self.assertRaises((TypeError, AttributeError), setattr, e, 'dict', None)

        # Ensure attributes are visible to dir(), part of the original
        # posted request.
        d = dir(e)
        attrs = ('type', 'dict', '__dict__', 'some_attr', 'other_attr',
                 'new_attr')

        for attr in attrs:
            self.assertIn(attr, d) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:35,代码来源:event_test.py

示例4: test_get

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_get(self):
        pygame.event.get()
        pygame.event.get(None)
        pygame.event.get(None, True)

        pygame.event.get(pump=False)
        pygame.event.get(pump=True)
        pygame.event.get(eventtype=None)
        pygame.event.get(eventtype=pygame.USEREVENT,
                         pump=False) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:12,代码来源:event_test.py

示例5: test_event_attribute

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_event_attribute(self):
        e1 = pygame.event.Event(pygame.USEREVENT, attr1='attr1')
        self.assertEqual(e1.attr1, 'attr1') 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:5,代码来源:event_test.py

示例6: test_post_large_user_event

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_post_large_user_event(self):
        pygame.event.post(pygame.event.Event(pygame.USEREVENT, {'a': "a" * 1024}))
        e = pygame.event.poll()

        self.assertEqual(e.type, pygame.USEREVENT)
        self.assertEqual(e.a, "a" * 1024) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:8,代码来源:event_test.py

示例7: test_get_type

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_get_type(self):
        ev = pygame.event.Event(pygame.USEREVENT)
        pygame.event.post(ev)
        queue = pygame.event.get(pygame.USEREVENT)
        self.assertEqual(len(queue), 1)
        self.assertEqual(queue[0].type, pygame.USEREVENT) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:8,代码来源:event_test.py

示例8: test_event_name

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_event_name(self):
        """Ensure event_name() returns the correct event name."""
        self.assertEqual(pygame.event.event_name(pygame.KEYDOWN), "KeyDown")
        self.assertEqual(pygame.event.event_name(pygame.USEREVENT),
                         "UserEvent") 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:7,代码来源:event_test.py

示例9: test_post

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_post(self):

        # __doc__ (as of 2008-08-02) for pygame.fastevent.post:

          # pygame.fastevent.post(Event) -> None
          # place an event on the queue
          #
          # This will post your own event objects onto the event queue.
          # You can past any event type you want, but some care must be
          # taken. For example, if you post a MOUSEBUTTONDOWN event to the
          # queue, it is likely any code receiving the event will expect
          # the standard MOUSEBUTTONDOWN attributes to be available, like
          # 'pos' and 'button'.
          #
          # Because pygame.fastevent.post() may have to wait for the queue
          # to empty, you can get into a dead lock if you try to append an
          # event on to a full queue from the thread that processes events.
          # For that reason I do not recommend using this function in the
          # main thread of an SDL program.

        for _ in range(1, 11):
            fastevent.post(event.Event(pygame.USEREVENT))

        self.assertListEqual([e.type for e in event.get()],
                             [pygame.USEREVENT] * 10,
                             race_condition_notification)

        try:
            # Special case for post: METH_O.
            fastevent.post(1)
        except TypeError:
            e = geterror()
            msg = ("argument 1 must be %s, not %s" %
                   (fastevent.Event.__name__, type(1).__name__))
            self.assertEqual(str(e), msg)
        else:
            self.fail() 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:39,代码来源:fastevent_test.py

示例10: test_post__clear

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_post__clear(self):
        """Ensure posted events can be cleared."""
        for _ in range(10):
            fastevent.post(event.Event(pygame.USEREVENT))

        event.clear()

        self.assertListEqual(fastevent.get(), [])
        self.assertListEqual(event.get(), []) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:11,代码来源:fastevent_test.py

示例11: test_clear

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_clear(self):
        pygame.event.clear()
        pygame.event.clear(None)
        pygame.event.clear(None, True)

        pygame.event.clear(pump=False)
        pygame.event.clear(pump=True)
        pygame.event.clear(eventtype=None)
        pygame.event.clear(eventtype=pygame.USEREVENT,
                           pump=False) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:12,代码来源:event_test.py

示例12: test_post__and_poll

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_post__and_poll(self):
        """Ensure events can be posted to the queue."""
        e1 = pygame.event.Event(pygame.USEREVENT, attr1='attr1')
        pygame.event.post(e1)
        posted_event = pygame.event.poll()

        self.assertEqual(e1.attr1, posted_event.attr1,
                         race_condition_notification)

        # fuzzing event types
        for i in range(1, 11):
            pygame.event.post(pygame.event.Event(events[i]))

            self.assertEqual(pygame.event.poll().type, events[i],
                             race_condition_notification) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:17,代码来源:event_test.py

示例13: test_get

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_get(self):
        # __doc__ (as of 2008-08-02) for pygame.fastevent.get:

          # pygame.fastevent.get() -> list of Events
          # get all events from the queue

        for _ in range(1, 11):
            event.post(event.Event(pygame.USEREVENT))

        self.assertListEqual([e.type for e in fastevent.get()],
                             [pygame.USEREVENT] * 10,
                             race_condition_notification) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:14,代码来源:fastevent_test.py

示例14: test_peek

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import USEREVENT [as 别名]
def test_peek(self):
        pygame.event.peek()
        pygame.event.peek(None)
        pygame.event.peek(None, True)

        pygame.event.peek(pump=False)
        pygame.event.peek(pump=True)
        pygame.event.peek(eventtype=None)
        pygame.event.peek(eventtype=pygame.USEREVENT,
                          pump=False) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:12,代码来源:event_test.py


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