Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ef963593
Kaydet (Commit)
ef963593
authored
May 19, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Small improvements everywhere; added info field to the display.
üst
157e3f8a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
25 deletions
+40
-25
jukebox.py
Demo/stdwin/jukebox.py
+40
-25
No files found.
Demo/stdwin/jukebox.py
Dosyayı görüntüle @
ef963593
...
...
@@ -19,17 +19,19 @@
#
# Most sound file formats recognized by SOX or SFPLAY are recognized.
# Since conversion is costly, converted files are cached in
# /usr/tmp/@j* until the user quits.
# /usr/tmp/@j* until the user quits or changes the sampling rate via
# the Rate menu.
import
commands
import
getopt
import
os
from
stat
import
*
import
rand
import
stdwin
from
stdwinevents
import
*
import
string
import
sys
import
tempfile
import
sndhdr
from
WindowParent
import
WindowParent
from
Buttons
import
PushButton
...
...
@@ -96,13 +98,17 @@ def main():
killchild
()
# Entries in Rate menu:
rates
=
[
'default'
,
\
rates
=
[
'default'
,
'7350'
,
\
'8000'
,
'11025'
,
'16000'
,
'22050'
,
'32000'
,
'41000'
,
'48000'
]
def
maineventloop
():
mouse_events
=
WE_MOUSE_DOWN
,
WE_MOUSE_MOVE
,
WE_MOUSE_UP
while
G
.
windows
:
type
,
w
,
detail
=
event
=
stdwin
.
getevent
()
try
:
type
,
w
,
detail
=
event
=
stdwin
.
getevent
()
except
KeyboardInterrupt
:
killchild
()
continue
if
w
==
G
.
cw
.
win
:
if
type
==
WE_CLOSE
:
return
...
...
@@ -185,14 +191,22 @@ def openlistwindow(dirname):
list
.
sort
()
i
=
0
while
i
<
len
(
list
):
if
list
[
i
]
==
'.'
or
list
[
i
]
==
'.
.'
:
if
list
[
i
]
[
0
]
==
'
.'
:
del
list
[
i
]
else
:
i
=
i
+
1
for
i
in
range
(
len
(
list
)):
name
=
list
[
i
]
if
os
.
path
.
isdir
(
os
.
path
.
join
(
dirname
,
name
)):
list
[
i
]
=
list
[
i
]
+
'/'
fullname
=
os
.
path
.
join
(
dirname
,
list
[
i
])
if
os
.
path
.
isdir
(
fullname
):
info
=
'/'
else
:
try
:
size
=
os
.
stat
(
fullname
)[
ST_SIZE
]
info
=
`(size + 1023)/1024`
+
'k'
except
IOError
:
info
=
'???'
info
=
'('
+
info
+
')'
list
[
i
]
=
list
[
i
],
info
width
=
maxwidth
(
list
)
# width = width + stdwin.textwidth(' ') # XXX X11 stdwin bug workaround
height
=
len
(
list
)
*
stdwin
.
lineheight
()
...
...
@@ -211,8 +225,8 @@ def openlistwindow(dirname):
def
maxwidth
(
list
):
width
=
1
for
name
in
list
:
w
=
stdwin
.
textwidth
(
name
)
for
name
,
info
in
list
:
w
=
stdwin
.
textwidth
(
name
+
' '
+
info
)
if
w
>
width
:
width
=
w
return
width
...
...
@@ -222,8 +236,12 @@ def drawlistwindow(w, area):
d
.
erase
((
0
,
0
),
(
1000
,
10000
))
lh
=
d
.
lineheight
()
h
,
v
=
0
,
0
for
name
in
w
.
list
:
d
.
text
((
h
,
v
),
name
)
for
name
,
info
in
w
.
list
:
if
info
==
'/'
:
text
=
name
+
'/'
else
:
text
=
name
+
' '
+
info
d
.
text
((
h
,
v
),
text
)
v
=
v
+
lh
showselection
(
w
,
d
)
d
.
close
()
...
...
@@ -257,22 +275,17 @@ def mouselistwindow(w, type, detail):
d
.
close
()
if
type
==
WE_MOUSE_DOWN
and
clicks
>=
2
and
i
>=
0
:
setcursors
(
'watch'
)
name
=
os
.
path
.
join
(
w
.
dirname
,
w
.
list
[
i
])
if
name
[
-
1
:]
==
'/'
:
name
,
info
=
w
.
list
[
i
]
fullname
=
os
.
path
.
join
(
w
.
dirname
,
name
)
if
info
==
'/'
:
if
clicks
==
2
:
G
.
windows
.
append
(
openlistwindow
(
name
[:
-
1
]
))
G
.
windows
.
append
(
openlistwindow
(
fullname
))
else
:
playfile
(
name
)
playfile
(
full
name
)
setcursors
(
'cross'
)
def
closelistwindow
(
w
):
remove
(
G
.
windows
,
w
)
def
remove
(
list
,
item
):
for
i
in
range
(
len
(
list
)):
if
list
[
i
]
==
item
:
del
list
[
i
]
break
G
.
windows
.
remove
(
w
)
def
setcursors
(
cursor
):
for
w
in
G
.
windows
:
...
...
@@ -298,7 +311,6 @@ validrates = (8000, 11025, 16000, 22050, 32000, 44100, 48000)
def
playfile
(
filename
):
killchild
()
import
sndhdr
tuple
=
sndhdr
.
what
(
filename
)
raw
=
0
if
tuple
:
...
...
@@ -338,6 +350,10 @@ def playfile(filename):
print
cmd
print
'Exit status'
,
sts
stdwin
.
fleep
()
try
:
os
.
unlink
(
tempname
)
except
:
pass
return
cache
[
filename
]
=
tempname
if
raw
:
...
...
@@ -352,7 +368,6 @@ def playfile(filename):
G
.
cw
.
win
.
settimer
(
1
)
def
sfplayraw
(
filename
,
tuple
):
import
sndhdr
args
=
[
'-i'
]
type
,
rate
,
channels
,
frames
,
bits
=
tuple
if
type
==
'ul'
:
...
...
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