python类MOUSEBUTTONDOWN的实例源码

rigeditor.py 文件源码 项目:renpy-shader 作者: bitsawer 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def handleEvents(self):
        self.mouse = self.get(MOUSE)

        for event, pos in self.context.events:
            self.mouse = pos

            handled = self.mode.handleEvent((event, pos))
            if not handled:
                if event.type == pygame.MOUSEBUTTONDOWN:
                    self.handleMouseDown(event, pos)
                elif event.type == pygame.MOUSEMOTION:
                    self.handleMouseMotion(pos)
                elif event.type == pygame.MOUSEBUTTONUP:
                    self.handleMouseUp(pos)

        if self.mouse:
            self.set(MOUSE, self.mouse)
pixelarray.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def show (image):
    screen = pygame.display.get_surface()
    screen.fill ((255, 255, 255))
    screen.blit (image, (0, 0))
    pygame.display.flip ()
    while 1:
        event = pygame.event.wait ()
        if event.type == pygame.QUIT:
            raise SystemExit
        if event.type == pygame.MOUSEBUTTONDOWN:
            break
game_app.py 文件源码 项目:pygame_cards 作者: vannov 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def process_events(self):
        """ Processes mouse events and quit event """
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                self.stopped = True
                self.render_thread.join()
                self.game_controller.cleanup()
                sys.exit()
            elif event.type == pygame.MOUSEBUTTONUP:
                self.process_mouse_event(False, self.is_double_click())
            elif event.type == pygame.MOUSEBUTTONDOWN:
                self.process_mouse_event(True)
game_functions.py 文件源码 项目:alien_invasion 作者: samnew 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets):
    """?????????"""
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            stats.save_high_score()
            sys.exit()

        elif event.type == pygame.KEYDOWN:
            check_keydown_events(event, ai_settings, screen, stats,sb, ship, aliens, bullets)
        elif event.type == pygame.KEYUP:
            check_keyup_events(event, ship)
        elif event.type == pygame.MOUSEBUTTONDOWN:
            mouse_x, mouse_y = pygame.mouse.get_pos()
            check_play_button(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets, mouse_x, mouse_y)
MainMenuNew.py 文件源码 项目:opseilen 作者: Baal221 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def Update(self, events):
        for event in events:
            if event.type == pygame.MOUSEMOTION:
                if self.Rect.collidepoint(event.pos):                    
                    self.Text = (pygame.font.Font(None, 40)).render(self.DefaultText, 1, (255, 190, 0))            
                else:
                    self.Text = (pygame.font.Font(None, 40)).render(self.DefaultText, 1, (130, 130, 130))
            elif event.type == pygame.MOUSEBUTTONDOWN:
                if self.Rect.collidepoint(event.pos):                    
                    return self.Action()
        return self
process_ev.py 文件源码 项目:opseilen 作者: Baal221 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def process_events():
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        if event.type == pygame.MOUSEBUTTONDOWN:
            button.click(event.pos)
    return False
game_scene.py 文件源码 项目:PyCut 作者: FOSSRIT 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def ProcessInput(self, events, pressed_keys):
        """
        Process input from user
        Inherits from SceneBase
                Args:   self
                        events - pygame events
                        pressed_keys
        """

        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                # Move to the next scene when the user pressed Enter
                pass

            if event.type == pygame.MOUSEBUTTONDOWN:
                for button in self.buttons:
                    button.isClicked(event)
                if self.leveling_up:
                    self.continue_button.isClicked(event)

            if event.type == pygame.MOUSEBUTTONUP:
                for button in self.buttons:
                    button.isClicked(event)
                if self.leveling_up:
                    self.continue_button.isClicked(event)

            if event.type == pygame.MOUSEMOTION:
                #for button in self.buttons:
                #    button.isHovered(event)
                if self.leveling_up:
                    self.continue_button.isHovered(event)
event.py 文件源码 项目:PyCut 作者: FOSSRIT 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _mousedown_cb(self, widget, event):
        self.__button_state[event.button-1] = 1
        return self._mouseevent(widget, event, pygame.MOUSEBUTTONDOWN)
ui.py 文件源码 项目:mqtt-control-panel 作者: colinodell 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def process_input(self):
        # Process touchscreen input
        from alarmpanel.button import STATE_PRESSED
        for event in pygame.event.get():
            if event.type is pygame.MOUSEBUTTONDOWN:
                pos = pygame.mouse.get_pos()
                for b in self._buttons:
                    if b.down(pos): break
            elif event.type is pygame.MOUSEBUTTONUP:
                pos = pygame.mouse.get_pos()
                for b in self._buttons:
                    if b.up(pos): pass
                    # Redraw other buttons which might be stuck in the down position
                    elif b.state == STATE_PRESSED:
                        b.set_state(STATE_DEFAULT)
game_functions.py 文件源码 项目:Galaxian-Against-COMP140 作者: tomjlw 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets):
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        elif event.type == pygame.KEYDOWN:
            check_keydown_events(event, ai_settings, screen, ship, bullets)
        elif event.type == pygame.KEYUP:
            check_keyup_events(event, ship)
        elif event.type == pygame.MOUSEBUTTONDOWN:
            mouse_x, mouse_y = pygame.mouse.get_pos()
            check_play_button(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets, mouse_x, mouse_y)
Button.py 文件源码 项目:LD39 作者: Bobsleigh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def notify(self, event):
        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == MOUSE_LEFT:
                if self.rect.collidepoint(event.pos):
                    self.method()
inputBox.py 文件源码 项目:LD39 作者: Bobsleigh 项目源码 文件源码 阅读 50 收藏 0 点赞 0 评论 0
def notify(self, event):
        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1:
                self.onLeftClick(event)
        elif self.selected:
            self.input.update(event)
button.py 文件源码 项目:LD39 作者: Bobsleigh 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def notify(self, event):
        if event.type == pygame.MOUSEBUTTONDOWN:
            if self.rect.collidepoint(event.pos):
                self.callback()
remote_ctrl.py 文件源码 项目:photobooth 作者: LoiX07 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def handle_event(self, event):
        """ Handle events of the GUI"""
        if event.type == pygame.MOUSEBUTTONUP:
            log.debug('Received a new event: %s', str(event))
            pos = pygame.mouse.get_pos()
            self.handle_mouseup(pos)
        elif event.type == pygame.MOUSEBUTTONDOWN:
            log.debug('Received a new event: %s', str(event))
            pos = pygame.mouse.get_pos()
            self.handle_mousedown(pos)
        elif event.type == pygame.KEYDOWN:
            log.debug('Received a new event: %s', str(event))
            self.handle_key_pressed(event.key)
universe.py 文件源码 项目:oficina2017 作者: helioh2 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def big_bang(inic, tela,
             quando_tick=lambda e: e, \
             frequencia=28, \
             desenhar=lambda e: pg.Surface((0,0)), \
             quando_tecla=lambda e, k: e, \
             quando_mouse=lambda e, x, y, ev: e, \
             parar_quando=lambda e: False):

    pg.init()
    estado = inic
    clock = pg.time.Clock()


    while True:

        pg.display.flip()

        if parar_quando(estado):
            print(estado)
            sys.exit(0)

        for event in pg.event.get():
            if event.type == pg.QUIT:
                print(estado)
                sys.exit(0)

            if event.type == pg.KEYDOWN:
                estado = quando_tecla(estado, event.key)

            elif event.type in [pg.MOUSEBUTTONDOWN, pg.MOUSEBUTTONUP, pg.MOUSEMOTION]:
                x, y = pg.mouse.get_pos()
                estado = quando_mouse(estado, x, y, event.type)

        estado = quando_tick(estado)

        tela.fill(COR_BRANCO)
        desenhar(estado)

        clock.tick(frequencia)
widgets.py 文件源码 项目:PyGameWidgets 作者: EricsonWillians 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def on_click(self, event, function, *args):
        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1:
                if self.rect.R.collidepoint(event.pos):
                    function(*args) if args else function()
widgets.py 文件源码 项目:PyGameWidgets 作者: EricsonWillians 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def on_mouse_button_click(self, event, mouse_button, function, *args):
        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == mouse_button:
                if self.rect.R.collidepoint(event.pos):
                    function(*args) if args else function()
nodes.py 文件源码 项目:wargame 作者: maximinus 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self, text, signal, align=Align.NONE):
        # make a label of the text - but we only want the image
        label = GuiLabel(text, (0, 0, 0), (214, 214, 214)).image
        # get the contents to render themselves
        border = Resources.configs.get(self.border_config)
        image = add_border(label, border, Resources.get_image(border.image))
        rect = pygame.Rect(0, 0, image.get_width(), image.get_height())
        super().__init__(rect, image, align, False)
        self.messages = [pygame.MOUSEMOTION, pygame.MOUSEBUTTONUP, pygame.MOUSEBUTTONDOWN]
        self.highlight = self.get_highlight()
        self.normal_image = self.image
        self.signal = signal
        self.changed = False
sprite.py 文件源码 项目:rpi_lcars 作者: tobykurien 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def handleEvent(self, event, clock):
        handled = False
        if not self.visible:
            self.focussed = False
            return handled

        if self.groups()[0].UI_PLACEMENT_MODE:
            if event.type == pygame.MOUSEBUTTONDOWN:
                self.pressed_time = pygame.time.get_ticks()
                self.focussed = True

            if event.type == pygame.MOUSEMOTION:
                if (self.focussed and pygame.time.get_ticks() - self.pressed_time > 1000):
                    self.long_pressed = True
                    self.rect.top = event.pos[1]
                    self.rect.left = event.pos[0]
                    self.dirty = 1            

            if event.type == pygame.MOUSEBUTTONUP:
                if self.handler:
                    self.handler(self, event, clock)
                    handled = True

                if self.focussed and self.long_pressed:
                    print event.pos[1], event.pos[0]

                self.pressed_time = 0
                self.long_pressed = False
                self.focussed = False

        return handled
main.py 文件源码 项目:rpi_lcars 作者: tobykurien 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def handleEvents(self, event, fpsClock):
        if event.type == pygame.MOUSEBUTTONDOWN:
            self.beep1.play()

        if event.type == pygame.MOUSEBUTTONUP:
            return False


问题


面经


文章

微信
公众号

扫码关注公众号