Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
app-pyaudioplayer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
santiago duque
app-pyaudioplayer
Commits
f52d9ebb
Commit
f52d9ebb
authored
Jan 14, 2025
by
santiago duque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added second button and logic to stop events as a test
parent
b7ed47b8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
main.py
main.py
+11
-7
No files found.
main.py
View file @
f52d9ebb
...
@@ -17,7 +17,7 @@ window = pygame.display.set_mode((winW, winH))
...
@@ -17,7 +17,7 @@ window = pygame.display.set_mode((winW, winH))
# window.fill((205,100,100))
# window.fill((205,100,100))
# pygame.display.update()
# pygame.display.update()
clock
=
pygame
.
time
.
Clock
()
#
clock = pygame.time.Clock()
def
reset_sounds
():
def
reset_sounds
():
...
@@ -53,9 +53,6 @@ def play_sound(index):
...
@@ -53,9 +53,6 @@ def play_sound(index):
global
current_sound_index
global
current_sound_index
global
channel
global
channel
global
sound_array
global
sound_array
global
btn_array
btn_array
[
index
]
.
when_pressed
=
None
if
not
cut_current_sound
:
if
not
cut_current_sound
:
current_sound_index
=
index
current_sound_index
=
index
...
@@ -117,16 +114,23 @@ current_sound_index = -1
...
@@ -117,16 +114,23 @@ current_sound_index = -1
# run setup
# run setup
setup_paths
(
False
)
setup_paths
(
False
)
def
btn_pressed
(
index
):
global
btn_array
btn_array
[
index
]
.
when_pressed
=
None
print
(
'btn pressed'
)
play_sound
(
index
)
def
resetBtn
(
index
):
def
resetBtn
(
index
):
global
btn_array
global
btn_array
btn_array
[
index
]
.
when_pressed
=
lambda
:
play_sound
(
index
)
btn_array
[
index
]
.
when_pressed
=
lambda
:
play_sound
(
index
)
btn1
=
Button
(
21
)
btn1
=
Button
(
21
)
btn1
.
when_pressed
=
lambda
:
play_soun
d
(
0
)
btn1
.
when_pressed
=
lambda
:
btn_presse
d
(
0
)
btn1
.
when_released
=
lambda
:
resetBtn
(
0
)
btn1
.
when_released
=
lambda
:
resetBtn
(
0
)
btn2
=
Button
(
13
)
btn2
=
Button
(
13
)
btn2
.
when_pressed
=
lambda
:
play_soun
d
(
1
)
btn2
.
when_pressed
=
lambda
:
btn_presse
d
(
1
)
btn2
.
when_released
=
lambda
:
resetBtn
(
1
)
btn2
.
when_released
=
lambda
:
resetBtn
(
1
)
btn_array
=
[
btn1
,
btn2
]
btn_array
=
[
btn1
,
btn2
]
...
@@ -135,7 +139,7 @@ btn_array = [btn1, btn2]
...
@@ -135,7 +139,7 @@ btn_array = [btn1, btn2]
run
=
True
run
=
True
while
run
:
while
run
:
clock
.
tick
(
25
)
#
clock.tick(25)
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
pygame
.
QUIT
:
if
event
.
type
==
pygame
.
QUIT
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment