|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Voilà je débute en python je viens de terminer les leçon du cours Rur-
ple ( http://rur-ple.sourceforge.net/en/rur.htm ) très instructif on y apprend en s'amusant des trucs comme - - def , if , else elif , pass , not while , from and import object oriented programing , tulpe , global , list , append , pop , dictionnary , str , int , class , del , return , for .. in , for ... in .. range() , join , len , designing new class , designing new class for change the base of an existing class : __init__ , from 'module' import 'fonction' , from 'module' import * (all function of that module ) , try ,- Même si je maitrise pas encore tout La premier programme que jesouhaite faire est un inutilitaire qui m'a bien fait rire il y a quelque années mais dont j'ai pas encore vue l'équivalent en sous Linux . Ce soft a pour but simplement différent sons prédéfinie (Ahh , Ohh , Wow .. ) lors qu'on clique sur un bouton . Rien de bien sorcier j'ai commencer à faire l'interface en TK , et voila lorsque j'essaye de lui faire lire un sons (wav ou ogg ) rien ne sort . J'ai testé différent module pyogg , pyvorbis , puis j'ai testé libsnack ( http://www.speech.kth.se/snack/) . Il semblerait lorsque je lance les commande dans le prompt cela le lit (en ouvrant xmms en meme temps je n'ai pas de sons car /dev/dsp occupé ) , sinon lorsque je lance le script il me donne une erreur de syntaxe : soundtest():^ SyntaxError: invalid syntax Script terminated. , voici mon code : import sys from Tkinter import * root = Tk() import tkSnack tkSnack.initializeSnack(root) mysound = tkSnack.Sound(load='/usr/share/xulrunner/res/samples/ test.wav') soundtest(): mysound.play fen = Tk() fen.title("Fenêtre composée à l'aide de frames") fen.geometry("157x178") f1 = Frame(fen,bd =2, ) f1.pack(side = LEFT) bou1=Button(f1, text='Ah') bou1.pack() bou2 =Button(f1, text='BoOOoo',command=soundtest) bou2.pack() bou3=Button(f1, text='Clapping') bou3.pack() bou4=Button(f1, text='Huh ? ') bou4.pack() f2 = Frame(fen, bd =2, ) f2.pack(side =RIGHT) bou5=Button(f2, text='Bouton') bou5.pack() bou6=Button(f2, text='Bouton') bou6.pack() bou7=Button(f2, text='Bouton') bou7.pack() bou8=Button(f2, text='Bouton') bou8.pack() f3 = Frame(fen, bd =2, ) f3.pack(side = BOTTOM) bou9=Button(f3, text='hello') bou9.pack() fen.mainloop() merci d'avance |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Wed, 22 Aug 2007 19:57:34 +0200, <firelink.east@gmail.com> wrote:
> lorsque je lance le > script il me donne une erreur de syntaxe : soundtest():^ > SyntaxError: invalid syntax > Script terminated. , voici mon code : (...) > soundtest(): > mysound.play (...) On dirait qu'il manque un "def" avant soundtest. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
firelink.east@gmail.com a écrit :
<zip...> > J'ai > testé différent module pyogg , pyvorbis , puis j'ai testé libsnack > ( http://www.speech.kth.se/snack/) . Au cas où, pyGame a des modules pour jouer un fichier, régler le volume... http://www.pygame.org/docs/ref/music.html <zip...> |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 23 août, 07:47, "Alex Marandon" <a...@invalid.org> wrote:
> On Wed, 22 Aug 2007 19:57:34 +0200, <firelink.e...@gmail.com> wrote: > > lorsque je lance le > > script il me donne une erreur de syntaxe : soundtest():^ > > SyntaxError: invalid syntax > > Script terminated. , voici mon code : > (...) > > soundtest(): > > mysound.play > > (...) > > On dirait qu'il manque un "def" avant soundtest. Oui , juste , après definition lorsque j'appuye sur le bouton BooOoo il n'y a aucun sons qui sort , est ce normal ? |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On 23 août, 09:11, Laurent Pointal <laurent.poin...@limsi.fr> wrote:
> firelink.e...@gmail.com a écrit : > <zip...> > > > J'ai > > testé différent module pyogg , pyvorbis , puis j'ai testé libsnack > > (http://www.speech.kth.se/snack/) . > > Au cas où, pyGame a des modules pour jouer un fichier, régler le volume... > > http://www.pygame.org/docs/ref/music.html > > <zip...> en remplacant le code de libsnack par pygame : import pygame from pygame.locals import * pygame.init() def soundtest(): pygame.mixer.music.load('/home/me/dangers.ogg') pygame.mixer.music.play(loops=0, start=0.0) celui ci me renvoye une erreur lorsqu'on appuye sur le bouton correspondant TypeError : play() takes no keywords arguments .. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 23 août, 11:35, firelink.e...@gmail.com wrote:
> On 23 août, 07:47, "Alex Marandon" <a...@invalid.org> wrote: > > > On Wed, 22 Aug 2007 19:57:34 +0200, <firelink.e...@gmail.com> wrote: > > > lorsque je lance le > > > script il me donne une erreur de syntaxe : soundtest():^ > > > SyntaxError: invalid syntax > > > Script terminated. , voici mon code : > > (...) > > > soundtest(): > > > mysound.play > > > (...) > > > On dirait qu'il manque un "def" avant soundtest. > > Oui , juste , après definition lorsque j'appuye sur le bouton BooOoo > il n'y a aucun sons qui sort , est ce normal ? > > (...) > > > On dirait qu'il manque un "def" avant soundtest. > > Oui , juste , après definition lorsque j'appuye sur le bouton BooOoo > il n'y a aucun sons qui sort , est ce normal ? je me répond , ca marche maintenant (j avais oublier de mettre la parenthese pour la fonction mysound.play() ) en tout cas pour le wav , l'ogg donne des sons brouillés , ca du au fait qu'il faut surement le décoder avant .. Au fait comment est ce que je peux lister toute les fonctions d'un module en python ? comment definir la taille d'un bouton sous python pour Tk pour que celui ci ne dépende pas de la taille du texte à l'intérieur , merci |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Bonjour
-snip- firelink.east@gmail.com wrote: > Au fait comment est ce que je peux lister > toute les fonctions d'un module en python ? >>> import string >>> dir(string) |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On 23 août, 13:30, Jerome <jer...@nospam.com> wrote:
> Bonjour > > -snip- > > firelink.e...@gmail.com wrote: > > Au fait comment est ce que je peux lister > > toute les fonctions d'un module en python ? > > >>> import string > >>> dir(string) merci voila j'ai quasi fini le soft , reste juste quelque détails : j'aimerais à la fois mettre les wav dans un répértoire , séparer du script . et à la fois que le script puisse s'éxecuter autant sous Linux que windows et Mac os x . le problème vient du fait que la syntaxe des répértoire diffère sous windows de Linux et Mac os x .(slash et backslash ) . j'aimerais mettre un bouton exit en tout en dessous , j'avais créer une nouvelle frame , mais le bouton se met toujours a coté . (right) au lieu d en bas bien que j'ai defini la nouvelle frame avec side = BOTTOM quelqu'un a t-il déjà utilisé Py2exe ? pour transformer un py en .exe même chose pour Mac os x ( Py2app ) Même chose pour Linux (pour gerer les dependance ) autopackage peut etre ? voici le code : import sys from Tkinter import * root = Tk() import tkSnack tkSnack.initializeSnack(root) def Aaah(): AhhSound = tkSnack.Sound(load='/home/me/resource/crowd.exe.remake/ wav/crowd.exe.remake.0.2.Aaahh.wav') AhhSound.play() def Oohh(): OohhSound = tkSnack.Sound(load='/home/me/resource/crowd.exe.remake/ wav/crowd.exe.remake.0.2.Oohh.wav') OohhSound.play() def BOo(): BOoSound = tkSnack.Sound(load='/home/me/resource/crowd.exe.remake/ wav/crowd.exe.remake.0.1.BOo.wav') BOoSound.play() def WOW(): WOWsound = tkSnack.Sound(load='/home/me/resource/crowd.exe.remake/ wav/crowd.exe.remake.0.1.WOW.wav') WOWsound.play() def Clapping(): ClappingSound = tkSnack.Sound(load='/home/me/resource/ crowd.exe.remake/wav/crowd.exe.remake.0.1.Clapping.wav') ClappingSound.play() def Laughing(): LaughingSound = tkSnack.Sound(load='/home/me/resource/ crowd.exe.remake/wav/crowd.exe.remake.0.1.laughing.wav') LaughingSound.play() def Huh(): HuhSound = tkSnack.Sound(load='/home/me/resource/crowd.exe.remake/ wav/crowd.exe.remake.0.1.Huh.wav') HuhSound.play() def Yeah(): YeahSound = tkSnack.Sound(load='/home/me/resource/crowd.exe.remake/ wav/crowd.exe.remake.0.1.Yeah.wav') YeahSound.play() def Cool(): YeahSound = tkSnack.Sound(load='/home/me/resource/crowd.exe.remake/ wav/crowd.exe.remake.0.1.Yeah.wav') YeahSound.play() root.title("Foule controle") root.geometry("157x178") f1 = Frame(root, width=78 , height= 138, bg="",bd=4 ) f1.pack(side = LEFT) bou1=Button(f1, width =6,height=1, text='Aaah',command=Aaah) bou1.pack() bou2 =Button(f1, width =6,height=1, text='BoOOoo',command=BOo) bou2.pack() bou3=Button(f1, width =6,height=1,text='Clapping',command = Clapping) bou3.pack() bou4=Button(f1, width =6,height=1,text='Huh ? ',command = Huh) bou4.pack() f2 = Frame(root, width=78 , height= 138, bg="") f2.pack(side =LEFT) bou5=Button(f2, width =6,height=1,text='Oohh', command = Oohh) bou5.pack() bou6=Button(f2, width =6,height=1, text='WOW !',command = WOW) bou6.pack() bou7=Button(f2, width =6,height=1, text='Laughing',command = Laughing) bou7.pack() bou8=Button(f2, width =6,height=1,text='Yeah',command=Yeah) bou8.pack() # frame pour accueillir le bouton exit f3 = Frame(fen, width=145, height=50 ) f3.pack(side = BOTTOM) # def Cool , encore besoin du code pour l exit bou9=Button(f3, text='exit', command=Cool) bou9.pack(side = BOTTOM) root.mainloop() |
|
![]() |
| Outils de la discussion | |
|
|