Modules et programme principal

Modules et programme principal - Python - Programmation

Marsh Posté le 10-09-2005 à 18:25:18    

J'ai créé un module graph qui appelle Tkinter et qui définie la fonction cercle(). Elle doit dessiner un cercle dans le canevas appelé "can". Mais le problème: il ne peut pas accéder aux éléemnts programme principal (canevas). La fonction est:  
def cercle(x, y, r, coul=black):
          can.create_oval(x-r, y-r, x+r, y+r, fill=coul)
 

Reply

Marsh Posté le 10-09-2005 à 18:25:18   

Reply

Marsh Posté le 11-09-2005 à 10:06:04    

tu lui files une référence vers le canevas [:petrus75]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 11-09-2005 à 11:20:01    

??? C'est à dire ?

Reply

Marsh Posté le 11-09-2005 à 11:37:46    

ben si ta fonction cercle n'a pas accès au canevas, comment tu veux qu'elle y trace quoi que ce soit [:petrus dei]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 11-09-2005 à 13:58:46    

Justement, comment faire pour qu'elle y ai accès ?

Reply

Marsh Posté le 11-09-2005 à 14:12:58    

ben tu files une référence à ton canevas en paramètre de ta fonction [:petrus75]
 
Ou alors tu fais en sorte que la fonction soit une méthode du canevas (et dans ce cas au lieu d'appeler "cercle" tu appelles "canevas.cercle" )


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 11-09-2005 à 14:37:03    

Ah. Je comprends. Je vais essayer. Merci

Reply

Marsh Posté le 11-09-2005 à 14:39:42    

Ouinn: Erreur sur le point.

Reply

Marsh Posté le 11-09-2005 à 14:40:09    

(sintax error)

Reply

Marsh Posté le 11-09-2005 à 15:40:05    

mégné?


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 11-09-2005 à 15:40:05   

Reply

Marsh Posté le 13-09-2005 à 18:05:23    

On peut reprendr depuis le début ?
Je veux créer une fonction dans un module appelé graph appelée cercle() qui accède à une fenêtre du programme principale appelé fen, puis à son widget esclve, un canevas appelé can.

Reply

Marsh Posté le 13-09-2005 à 18:17:22    

Ah, ben ouais, tu fais en sorte que ta fonction cercle() prenne un canevas en paramètre [:spamafote]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 14-09-2005 à 11:52:27    

oui, je peux l'enregistrer dans une variable can mais comment l'utiliser après ?

Reply

Marsh Posté le 14-09-2005 à 13:30:44    

[:petrus75]

def cercle(canevas, x, y, r, coul=black):
          canevas.create_oval(x-r, y-r, x+r, y+r, fill=coul)


C'est vraiment à ce point compliqué [:petrus dei]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Marsh Posté le 15-09-2005 à 08:55:43    

C'est... que je suis plutôt débutant... :p

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed