Hide button when disabled
parent
9e487481e4
commit
f76851ba23
|
@ -16,6 +16,7 @@ class Button:
|
||||||
self.rect.topleft = topleft
|
self.rect.topleft = topleft
|
||||||
|
|
||||||
self.pressed = False
|
self.pressed = False
|
||||||
|
self.enabled = True
|
||||||
|
|
||||||
def draw_on(self, screen):
|
def draw_on(self, screen):
|
||||||
if self.pressed:
|
if self.pressed:
|
||||||
|
@ -47,7 +48,8 @@ class CaptureButton(Button):
|
||||||
self.count = 0
|
self.count = 0
|
||||||
|
|
||||||
def draw_on(self, screen):
|
def draw_on(self, screen):
|
||||||
super(CaptureButton, self).draw_on(screen)
|
if self.enabled:
|
||||||
|
super(CaptureButton, self).draw_on(screen)
|
||||||
if self.capture_mode:
|
if self.capture_mode:
|
||||||
if self.elapsed >= CaptureButton.countdown:
|
if self.elapsed >= CaptureButton.countdown:
|
||||||
text = "CLIC!"
|
text = "CLIC!"
|
||||||
|
@ -61,6 +63,7 @@ class CaptureButton(Button):
|
||||||
def run(self):
|
def run(self):
|
||||||
pygame.event.set_blocked((pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP))
|
pygame.event.set_blocked((pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP))
|
||||||
self.capture_mode = True
|
self.capture_mode = True
|
||||||
|
self.enabled = False
|
||||||
|
|
||||||
capture = Capture(self.count)
|
capture = Capture(self.count)
|
||||||
self.count += 1
|
self.count += 1
|
||||||
|
@ -81,6 +84,7 @@ class CaptureButton(Button):
|
||||||
pygame.time.wait(1000)
|
pygame.time.wait(1000)
|
||||||
pygame.event.set_allowed((pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP))
|
pygame.event.set_allowed((pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP))
|
||||||
self.capture_mode = False
|
self.capture_mode = False
|
||||||
|
self.enabled = True
|
||||||
|
|
||||||
|
|
||||||
class Capture:
|
class Capture:
|
||||||
|
|
Loading…
Reference in New Issue